★ wanayoo — archive 1999 https://github.com/nodejs/node/pull/23797Nouvelle recherche | Portail wanayoo
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

src: improve StreamBase read throughput #23797

Closed
wants to merge 4 commits into from

Conversation

Copy link
Member

@addaleax addaleax commented Oct 21, 2018

Improve performance by providing JS with the raw ingredients
for the read data, i.e. an ArrayBuffer + offset + length
fields, instead of creating Buffer instances in C++ land.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

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.
@nodejs-github-bot nodejs-github-bot added the lib / src label Oct 21, 2018
@addaleax addaleax added net performance labels Oct 21, 2018
@addaleax addaleax added this to To do in StreamBase refactor via automation Oct 21, 2018
Copy link
Member

@TimothyGu TimothyGu left a comment

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);
Copy link
Member

@TimothyGu TimothyGu Oct 21, 2018

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?

Copy link
Member

@lundibundi lundibundi Oct 22, 2018

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

Copy link
Member Author

@addaleax addaleax Oct 23, 2018

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.

@mscdex
Copy link
Contributor

@mscdex mscdex commented Oct 22, 2018

@mscdex
Copy link
Contributor

@mscdex mscdex commented Oct 22, 2018

It looks like benchmark/net/tcp-raw-c2s.js needs to be fixed.

@addaleax
Copy link
Member Author

@addaleax addaleax commented Oct 23, 2018

It looks like benchmark/net/tcp-raw-c2s.js needs to be fixed.

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.)

@mscdex
Copy link
Contributor

@mscdex mscdex commented Oct 23, 2018

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):

buffer.js:208
    throw new ERR_INVALID_ARG_TYPE('value', 'not number', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "value" argument must not be of type number. Received type number
    at Function.from (buffer.js:208:11)
    at TCP.clientHandle.onread (/home/iojs/build/workspace/benchmark-node-micro-benchmarks/benchmarking/experimental/benchmarks/community-benchmark/node/benchmark/net/tcp-raw-pipe.js:54:55)

@addaleax
Copy link
Member Author

@addaleax addaleax commented Oct 24, 2018

@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 raw benchmarks right after landing this anyway.

@addaleax
Copy link
Member Author

@addaleax addaleax commented Oct 24, 2018

@addaleax addaleax added the author ready label Oct 24, 2018
@addaleax
Copy link
Member Author

@addaleax addaleax commented Oct 24, 2018

Landed in 1365f65

@addaleax addaleax closed this Oct 24, 2018
StreamBase refactor automation moved this from To do to Done Oct 24, 2018
@addaleax addaleax deleted the net-throughput branch Oct 24, 2018
addaleax added a commit that referenced this issue Oct 24, 2018
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>
targos pushed a commit that referenced this issue Oct 24, 2018
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>
@p3x-robot
Copy link

@p3x-robot p3x-robot commented Nov 19, 2018

Hello!
We have a change that fails in SPDY since Node v11.1.0 (spdy-http2/node-spdy#350 (comment))

Could you tell us what the actual is changing? Is it only the signature of those files and nothing else?
image

@addaleax
Copy link
Member Author

@addaleax addaleax commented Nov 19, 2018

@p3x-robot I’ve commented on the linked issue, hope that’s helpful

@p3x-robot
Copy link

@p3x-robot p3x-robot commented Nov 19, 2018

found it, thanks very much!

@MylesBorins
Copy link
Member

@MylesBorins MylesBorins commented Nov 26, 2018

Should this be backported to v8.x-staging or v10.x-staging? If yes please follow the guide and raise a backport PR, if not let me know or add the dont-land-on label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready lib / src net performance
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

8 participants