Repository navigation
stream performance regression 12.6.0 vs 10.16.0 #28586
Copy link
Copy link
Closed
Labels
confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.performanceIssues and PRs related to the performance of Node.js.Issues and PRs related to the performance of Node.js.streamIssues and PRs related to Node.js streams.Issues and PRs related to Node.js streams.
Description
Seeing major performance regression, ~50% drop in throughput, in one of our benchmarks. I will work on creating a minimal repro. In the meantime though, here are some snippets of the profile outputs - it is pretty strange that 12.6.0 is spending ~70% of the time in shared library land (maybe there's an issue with the profile too?)
#uname -a
Linux ledion-vm 4.10.0-33-generic #37~16.04.1-Ubuntu SMP Fri Aug 11 14:07:24 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
10.16.0
[Shared libraries]:
ticks total nonlib name
1021 2.5% /lib/x86_64-linux-gnu/libc-2.23.so
724 1.8% /lib/x86_64-linux-gnu/libpthread-2.23.so
17 0.0% [vdso]
6 0.0% /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
[Summary]:
ticks total nonlib name
26260 63.9% 66.8% JavaScript
11860 28.9% 30.2% C++
947 2.3% 2.4% GC
1768 4.3% Shared libraries
1178 2.9% Unaccounted
[Bottom up (heavy) profile]:
ticks parent name
3566 8.7% Builtin: LoadIC
858 24.1% LazyCompile: *onwrite _stream_writable.js:450:17
358 41.7% LazyCompile: *afterTransform _stream_transform.js:78:24
349 97.5% LazyCompile: *Transform._read _stream_transform.js:185:37
349 100.0% LazyCompile: *Readable.read _stream_readable.js:377:35
348 99.7% LazyCompile: *pipeOnDrainFunctionResult _stream_reada
12.6.0
[Shared libraries]:
ticks total nonlib name
28413 64.4% /usr/local/bin/node
1845 4.2% /lib/x86_64-linux-gnu/libc-2.23.so
455 1.0% /lib/x86_64-linux-gnu/libpthread-2.23.so
7 0.0% [vdso]
6 0.0% /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
4 0.0% /lib/x86_64-linux-gnu/libm-2.23.so
[Summary]:
ticks total nonlib name
8697 19.7% 65.1% JavaScript
4515 10.2% 33.8% C++
1969 4.5% 14.7% GC
30730 69.7% Shared libraries
154 0.3% Unaccounted
ticks parent name
28413 64.4% /usr/local/bin/node
6958 24.5% LazyCompile: *Readable.read _stream_readable.js:394:35
6901 99.2% LazyCompile: *pipeOnDrainFunctionResult _stream_readable.js
6901 100.0% LazyCompile: *emit events.js:153:44
6901 100.0% LazyCompile: *EventEmitter.emit domain.js:460:39
6901 100.0% LazyCompile: *onwrite _stream_writable.js:445:17
3237 11.4% LazyCompile: *ondata _stream_readable.js:711:18
3237 100.0% LazyCompile: *emit events.js:153:44
3237 100.0% LazyCompile: *Readable.read _stream_readable.js:394:35
3214 99.3% LazyCompile: *pipeOnDrainFunctionResult _stream_readabl
3214 100.0% LazyCompile: *emit events.js:153:44
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.performanceIssues and PRs related to the performance of Node.js.Issues and PRs related to the performance of Node.js.streamIssues and PRs related to Node.js streams.Issues and PRs related to Node.js streams.
Activity
ledbit commentedon Jul 8, 2019
I believe I've isolated the problem to streams and
12.0.0seems to be first time when this appeared. See benchmark bench-stream.txt[-]performance regression 12.6.0 vs 10.16.0 [/-][+]stream performance regression 12.6.0 vs 10.16.0 [/+]ledbit commentedon Jul 19, 2019
Any ideas where to look for a potential root cause here? Happy to dig thru
Trott commentedon Jul 19, 2019
/ping @nodejs/streams
mcollina commentedon Jul 20, 2019
Would you mind adding a reproducible benchmark? It seems you are interactive with a native resource / the change might actually be there or due to somewhere else entirely (a change in v8 for example).
Check out https://clinicjs.org/flame/ to help you debug these (there is also an upload function in clinic, it will give you a link that you can paste here for example).
ledbit commentedon Jul 22, 2019
@mcollina happy to look at Clinic.js, seems pretty cool! In the meantime, I did include a benchmark above, not sure if you saw it or not (when saying that "you are interacting with a native resource") - the benchmark below uses just Node streams
mcollina commentedon Jul 23, 2019
I can reproduce the performance drop.
mcollina commentedon Jul 23, 2019
The main difference between the two is that 12 spends a lot of time in
__ZN2v88internalL47Builtin_Impl_Stats_CallSitePrototypeGetTypeNameEiPmPNS0_7IsolateE, which is a C++ in V8. @bmeurer wdyt? What could cause that?I have a hunch that it can be related to #27146.No, it's not due to that.I'll investigate more and report.
mcollina commentedon Jul 24, 2019
This regression was introduced when we updated to V8 7.3.492.25.
@nodejs/v8 would you like to chime in?
cc @hashseed @bmeurer @targos @ryzokuken
mcollina commentedon Jul 24, 2019
Please check out #28842, it should solve the regression.
stream: resolve perf regression introduced by V8 7.3
1 remaining item
addaleax commentedon Jul 26, 2019
I think this only applies to the one in
lib/zlib.js, besides streams. And there it may or may not be faster to test against not being an Uint8Array, because the comment in the zlib code is outdated (streams do support any typeof Uint8Array).stream: resolve perf regression introduced by V8 7.3
stream: resolve perf regression introduced by V8 7.3
stream: resolve perf regression introduced by V8 7.3
Please ignore this msg (#1)
ledbit commentedon Sep 7, 2019
hmm @mcollina, I'm still seeing a significant perf drop on 12.10.0
mcollina commentedon Sep 7, 2019
It got worse in 12.10.0 vs 12.9.0
addaleax commentedon Sep 7, 2019
@mcollina @mscdex I’ve investigated this. It looks like f4f8827 (#25461) only works on V8 7.7+ – on 7.6, creating the object literal the way that that PR does involves multiple calls into the V8 runtime (
v8::internal::Runtime_DefineDataPropertyInLiteral), whereas on 7.7 it doesn’t call into the runtime.I think that means we either have to revert f4f8827 on v12.x, or wait for the V8 update to 7.7 on v12.x (#29241), which should be ready next week.
mcollina commentedon Sep 8, 2019
I would revert it if we decide to do a release before V8 7.7 lands
mcollina commentedon Sep 26, 2019
This is solved again in 12.11.0: