-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
src: improve StreamBase read throughput #23797
Conversation
Improve performance by providing JS with the raw ingridients for the read data, i.e. an `ArrayBuffer` + offset + length fields, instead of creating `Buffer` instances in C++ land.
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.
Are there benchmark results available?
Environment* env = env_; | ||
|
||
#ifdef DEBUG | ||
CHECK_EQ(static_cast<int32_t>(nread), nread); | ||
CHECK_EQ(static_cast<int32_t>(offset), offset); |
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.
Maybe also assert that offset
is 0 and nread
is less than 0 if ab
is empty?
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.
IIUC this will also allow us to remove
// TODO(bnoordhuis) Check that nread > 0.
https://github.com/nodejs/node/pull/23797/files#diff-f45eb699237c2e38dc9b49b588933c11R497.
in channel.onread
Edit: that is if we add a reverse check of ab
non-empty -> nread
> 0
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.
I’m not sure we can guarantee nread > 0
, but nread >= 0
should make sense.
It looks like benchmark/net/tcp-raw-c2s.js needs to be fixed. |
2350bd1
to
18069e4
Compare
Done! With more iterations this time: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/250/ (edit: aborted, took too long. sorry… the other benchmarks results are pretty good, though.)
|
Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/251/console It looks like benchmark/net/tcp-raw-pipe.js needs to be updated (further):
|
@mscdex That’s happening because the modified benchmark and the previous version of it are incompatible, because they expect different function signatures… I’m going to open a PR to remove those |
Resume CI (sigh): https://ci.nodejs.org/job/node-test-pull-request/18097/ |
Landed in 1365f65 |
Improve performance by providing JS with the raw ingridients for the read data, i.e. an `ArrayBuffer` + offset + length fields, instead of creating `Buffer` instances in C++ land. PR-URL: #23797 Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: James M Snell <[email protected]>
Improve performance by providing JS with the raw ingridients for the read data, i.e. an `ArrayBuffer` + offset + length fields, instead of creating `Buffer` instances in C++ land. PR-URL: #23797 Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: James M Snell <[email protected]>
Hello! Could you tell us what the actual is changing? Is it only the signature of those files and nothing else? |
@p3x-robot I’ve commented on the linked issue, hope that’s helpful |
found it, thanks very much! |
Should this be backported to |
Improve performance by providing JS with the raw ingredients
for the read data, i.e. an
ArrayBuffer
+ offset + lengthfields, instead of creating
Buffer
instances in C++ land.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes