src: improve StreamBase read throughput#23797
src: improve StreamBase read throughput#23797addaleax wants to merge 4 commits intonodejs:masterfrom
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.
TimothyGu
left a comment
There was a problem hiding this comment.
Are there benchmark results available?
|
|
||
| #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.
Maybe also assert that offset is 0 and nread is less than 0 if ab is empty?
There was a problem hiding this comment.
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.
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 <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
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 <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
|
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
Bufferinstances in C++ land.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes