| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Optional, but given the extent of the changes, it would be good to run a test coverage report and make sure this doesn't decrease coverage for lib/zlib.js etc. (and if it does, then hopefully add some tests to fully cover the new code). |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM for the streams parts.
Sorry, something went wrong.
There was a problem hiding this comment.
would you mind adding a comment that this matches both null and undefined, and it is done on purpose?
Sorry, something went wrong.
There was a problem hiding this comment.
Comments added.
Sorry, something went wrong.
|
As any changes in streams, a run through CITGM would be nice. |
Sorry, something went wrong.
There was a problem hiding this comment.
why not Object.assign ? still too slow?
Sorry, something went wrong.
There was a problem hiding this comment.
Yes.
Sorry, something went wrong.
There was a problem hiding this comment.
any numbers?
Sorry, something went wrong.
There was a problem hiding this comment.
I don't have any handy, no. We could always flip it to be a whitelist in the future I suppose if we run into issues. Using a whitelist would allow us to just specify an object inline and avoid any expensive copying-related operations.
Sorry, something went wrong.
|
This needs a rebase. |
Sorry, something went wrong.
|
Rebased. |
Sorry, something went wrong.
There was a problem hiding this comment.
can we try to use bind here? It might be slightly faster as we don't keep the context alive.
Sorry, something went wrong.
There was a problem hiding this comment.
As discussed and checked with @mcollina, this can be really fast using bind, especially once this CL lands in V8. The CL should apply cleanly to 6.0, but also 5.9.
Here's a simple micro-benchmark:
function bar() {}
function A() { this.x = (x) => bar(x); }
function Ab() { this.x = bar.bind(undefined); }
function c() { return new A(); }
function cb() { return new Ab(); }
function l() { return {x: (x) => bar(x)}; }
function lb() { return {x: bar.bind(undefined)}; }
const N = 10000000;
function test(fn, n) {
for (var i = 0; i < n; ++i) {
fn.call(this);
}
}
const FNS = [c, cb, l, lb];
for (const fn of FNS) {
test(fn, 100);
}
for (const fn of FNS) {
console.time(fn.name);
test(fn, N);
console.timeEnd(fn.name);
}
Sorry, something went wrong.
There was a problem hiding this comment.
I think we should see if you can bring those improvements also to _readableState and _writableState, as allocating those are a hot path whenever using node streams.
Sorry, something went wrong.
There was a problem hiding this comment.
I just copied the state object as-is without really paying attention. I will look into adding bind()...
Sorry, something went wrong.
There was a problem hiding this comment.
I've now incorporated bind() and it doesn't seem to have negatively affected performance, so it's fine.
Sorry, something went wrong.
There was a problem hiding this comment.
As discussed and checked with @mcollina, this can be really fast using bind, especially once this CL lands in V8. The CL should apply cleanly to 6.0, but also 5.9.
Here's a simple micro-benchmark:
function bar() {}
function A() { this.x = (x) => bar(x); }
function Ab() { this.x = bar.bind(undefined); }
function c() { return new A(); }
function cb() { return new Ab(); }
function l() { return {x: (x) => bar(x)}; }
function lb() { return {x: bar.bind(undefined)}; }
const N = 10000000;
function test(fn, n) {
for (var i = 0; i < n; ++i) {
fn.call(this);
}
}
const FNS = [c, cb, l, lb];
for (const fn of FNS) {
test(fn, 100);
}
for (const fn of FNS) {
console.time(fn.name);
test(fn, N);
console.timeEnd(fn.name);
}
Sorry, something went wrong.
|
Let's let #13374 land first, then get this rebased and landed after that. |
Sorry, something went wrong.
|
:-( |
Sorry, something went wrong.
|
I understand the :-( but I'd like to get #13374 landed and pulled into a quick 8.x patch or minor release next week while letting this PR sit for a few weeks before pulling it in. |
Sorry, something went wrong.
When the input to Function.prototype.bind is a known function, we can inline the allocation of the JSBoundFunction into TurboFan, which provides a 2x speed-up for several hot functions in Node streams (as discovered by Matteo Collina). One of example of this can be found in nodejs/node#13322, which can be optimized and made more readable using bind instead of closures. R=jarin@chromium.org Review-Url: https://codereview.chromium.org/2916063002 Cr-Commit-Position: refs/heads/master@{#45679}
|
Rebased. |
Sorry, something went wrong.
|
Still LGTM |
Sorry, something went wrong.
|
CITGM with READABLE_STREAM=disable: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/858/ |
Sorry, something went wrong.
Sorry, something went wrong.
|
Benchmark results with V8 5.9 in master: improvement confidence p.value streams/transform-creation.js n=1000000 693.97 % *** 2.539023e-41 zlib/creation.js n=1000000 options="false" type="Deflate" 14.76 % *** 1.049980e-22 zlib/creation.js n=1000000 options="true" type="Deflate" 12.35 % *** 2.782802e-20 zlib/deflate.js n=400000 inputLen=1024 method="createDeflate" 3.35 % *** 2.227584e-09 zlib/deflate.js n=400000 inputLen=1024 method="deflateSync" 27.42 % *** 3.447520e-43 zlib/deflate.js n=100000 inputLen=1024 method="deflate" 28.95 % *** 1.054469e-34 |
Sorry, something went wrong.
PR-URL: #13322 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
PR-URL: #13322 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
PR-URL: #13322 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
PR-URL: #13322 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
PR-URL: #13322 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
PR-URL: #13322 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
PR-URL: #13322 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
PR-URL: #13322 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
PR-URL: #13322 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
|
I’ve removed this from the 8.2.0 proposal and labelled it dont-land so we can wait for #14161 to be resolved. |
Sorry, something went wrong.
|
So this should have likely been reverted as soon as we noticed issues in zlib. At this point there is a whole bunch of code that has landed on top of this PR in zlib.js and it is extremely hard to revert without a TON of conflicts /cc @nodejs/tsc |
Sorry, something went wrong.
|
@MylesBorins I have add4b0a reverted and all tests running successfully. Most of the conflicts were due to the new internal error stuff. I'll open a PR. Any idea if e5dc934 needs to be reverted too (or perhaps even instead)? |
Sorry, something went wrong.
Sorry, something went wrong.
add4b0a made the assumption that compressed data would never lead to an empty decompressed stream. Fix that by explicitly checking the number of read bytes. Fixes: nodejs#17041 Refs: nodejs#13322
add4b0a made the assumption that compressed data would never lead to an empty decompressed stream. Fix that by explicitly checking the number of read bytes. PR-URL: #17042 Fixes: #17041 Refs: #13322 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
add4b0a made the assumption that compressed data would never lead to an empty decompressed stream. Fix that by explicitly checking the number of read bytes. PR-URL: #17042 Fixes: #17041 Refs: #13322 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
| Back | FazBrowse Home | New Git URL |
This PR brings various performance improvements to stream.Transform and zlib. A good chunk of the performance increases come from the inlining of stream.Transform state initialization during stream instantiation. The rest of the increases come from changes to zlib itself.
Here is an overview of the notable zlib-specific changes:
Here are some results with the included benchmarks:
CI: https://ci.nodejs.org/job/node-test-pull-request/8378/
Checklist
Affected core subsystem(s)