Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add close method #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

add close method #20

wants to merge 3 commits into from

Conversation

dominictarr
Copy link
Collaborator

I found this sitting uncommited in my dev directory.

I think it's needed because I added close to the benchmark, and the log tests?

index.js Outdated
@@ -13,7 +13,8 @@ module.exports = function (file, opts) {

var blockSize = opts.blockSize || 1024*16
var codec = opts.codec || {encode: id, decode: id, buffer: true}
var cache = opts.cache || Cache(1024)
var flags = opts.flags || 'a+'
var cache = opts.cache || Cache(8*1024)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to make append a bit slower but make random a lot faster. Are you seeing the same @dominictarr?

Before:

append, 60189.786, 8.994, 602259, 89.996, 10.006
stream, 43594.04, 6.514, 435984, 65.15, 10.001
stream no cache, 50536.246, 7.551, 505413, 75.525, 10.001
stream10, 43835.232, 6.55, 438440, 65.517, 10.002
random, 27497.85, 4.109, 275006, 41.094, 10.001

After:

append, 57312.068, 8.561, 573178, 85.624, 10.001
stream, 44599.44, 6.662, 446039, 66.632, 10.001
stream no cache, 52688.831, 7.87, 526941, 78.717, 10.001
stream10, 44091.79, 6.586, 440962, 65.873, 10.001
random, 34874.812, 5.209, 348783, 52.103, 10.001

Also tested 16 that seems to be almost the same as 8.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, I didn't mean to change the cache size. I'm gonna update PR to just not change that.

@@ -123,11 +127,14 @@ module.exports = function (blocks, frame, codec, file, cache) {
})
)).catch((err) => cb(err))
.then(() => cb(null))
},
close: function (cb) {
cb()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this meant to do anything or just provide a consistent api? if it's to make this module consistent with some interface, maybe add a comment saying "nothing to do when closing". anyway, seems innocent, but then there's other changes in this pull request that seem unrelated.

@dominictarr
Copy link
Collaborator Author

merged master into this and removed change to cache:

master:

name, ops/second, mb/second, ops, total-mb, seconds
append, 180069.923, 22.782, 1802680, 228.076, 10.011
stream, 123349.33, 15.606, 1233740, 156.094, 10.002
stream no cache, 147520.547, 18.664, 1475353, 186.663, 10.001
stream10, 151553.446, 19.174, 1517050, 191.934, 10.01
random, 22700.818, 2.872, 227553, 28.79, 10.024

close:

name, ops/second, mb/second, ops, total-mb, seconds
append, 181033.09, 22.904, 1810874, 229.112, 10.003
stream, 120267.692, 15.216, 1203158, 152.224, 10.004
stream no cache, 143455.754, 18.15, 1434701, 181.518, 10.001
stream10, 147191.646, 18.623, 1473094, 186.382, 10.008
random, 24554.644, 3.106, 245571, 31.069, 10.001

@dominictarr
Copy link
Collaborator Author

not a significant difference

@@ -13,6 +13,7 @@ module.exports = function (file, opts) {

var blockSize = opts.blockSize || 1024*16
var codec = opts.codec || {encode: id, decode: id, buffer: true}
var flags = opts.flags || 'a+'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we removed this in master on purpose but I can't remember why. Hmm.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember! it breaks your delete stuff. unfortunately there is no option that means "open a file for writing and reading and create the file if it does not exist" there is only error if it does not exist

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean that we should remove it from here? I don't remember, I can look into it (unless someone else beats me to it).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this patch should not change the file open flag, it's not about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants