-
Notifications
You must be signed in to change notification settings - Fork 185
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 batch support in createReadStream #261
Add batch support in createReadStream #261
Conversation
My concern about this is related with the download progress. It's not the same to wait for a single message to be download than 100 messages. Maybe I could check if I have the range of messages downloaded for the batch I choose that option and if is not I use |
47376fa
to
df7723b
Compare
Now I check for the range downloaded and if is not downloaded it use |
@tinchoz49 perhaps we could do a more opportunistic thing where we just check how many messages we have on disk compared to where we are and let's say we have the next 100 messages already downloaded we use the batch api to get them out |
CHANGELOG.md
Outdated
@@ -9,3 +9,4 @@ See [UPGRADE.md](UPGRADE.md) for notes on breaking changes for downstream develo | |||
- Ease of use update to signatures, https://github.com/mafintosh/hypercore/issues/260 | |||
- Updates [noise-protocol](https://github.com/emilbayes/noise-protocol) to latest, which uses chacha instead of xchacha and moves avoid from the sodium kx api for better compatability with the rest of the Noise ecosystem. | |||
- Updates [sodium-native](https://github.com/sodium-friends/sodium-native) from 2 to 3 across the board. 3 uses n-api, so no more builds needed when Node is released. | |||
- Update the discovery key to hash in the protocol version for better migration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is from the first commit which i force pushed out. can you remove that commit as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
droped it
index.js
Outdated
@@ -1346,6 +1376,16 @@ Feed.prototype.createReadStream = function (opts) { | |||
read(size, cb) | |||
}) | |||
} | |||
|
|||
function setStart (value) { | |||
var _start = start |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_start -> prevStart
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
r.pipe(w).on('finish', function () { | ||
collect(feed2.createReadStream({ batch }), function (err, data) { | ||
t.error(err, 'no error') | ||
t.same(data, [bufferFrom('hello'), bufferFrom('world')]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to this PR this made me realise we need this #265
Looks GREAT @tinchoz49 !! Seems to be much faster as well. |
afaaaea
to
934a7e4
Compare
@tinchoz49 Thanks, I'll land and release this tmw :) If you wanna post your perf stats here we can include it in the changelog |
Awesome! thanks for taking the time to review this. Read 100000 Messages
|
I forgot to add the batch option to the readme |
It adds support for batch reading in createReadStream and improve the performance.
It's an initial idea and feedback is welcome.
Usage
Benchmark
Todo