Skip to content

process: faster next tick

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

process

Moves the nextTick implementation to a series of fixed size circular arrays instead of the linked list. The size for each array is fixed at 2048, which seems to provide the best perf.

Since streams are big nextTick users these days, I added a pipe benchmark also to see the impact.

NextTick benchmark
node benchmark/compare.js --old ./node-master --new ./out/Release/node --filter next-tick process > next-tick.csv
cat next-tick.csv | Rscript benchmark/compare.R
                                              confidence improvement accuracy (*)   (**)  (***)
 process/next-tick-breadth-args.js millions=4        ***     40.11 %       ±1.23% ±1.64% ±2.14%
 process/next-tick-breadth.js millions=4             ***      7.16 %       ±3.50% ±4.67% ±6.11%
 process/next-tick-depth-args.js millions=12         ***      5.46 %       ±0.91% ±1.22% ±1.59%
 process/next-tick-depth.js millions=12              ***     23.26 %       ±2.51% ±3.36% ±4.40%
 process/next-tick-exec-args.js millions=5           ***     38.64 %       ±1.16% ±1.55% ±2.01%
 process/next-tick-exec.js millions=5                ***     77.20 %       ±1.63% ±2.18% ±2.88%

Be aware that when doing many comparisions the risk of a false-positive
result increases. In this case there are 6 comparisions, you can thus
expect the following amount of false-positive results:
  0.30 false positives, when considering a   5% risk acceptance (*, **, ***),
  0.06 false positives, when considering a   1% risk acceptance (**, ***),
  0.01 false positives, when considering a 0.1% risk acceptance (***)
Streams benchmark
node benchmark/compare.js --old ./node-master --new ./out/Release/node stream > stream.csv
cat stream.csv | Rscript benchmark/compare.R
                                                       confidence improvement accuracy (*)   (**)  (***)
 streams/pipe-object-mode.js n=5000000                        ***     21.85 %       ±0.76% ±1.01% ±1.32%
 streams/pipe.js n=5000000                                    ***     20.30 %       ±0.59% ±0.79% ±1.02%
 streams/readable-bigread.js n=1000                                    0.00 %       ±0.67% ±0.89% ±1.16%
 streams/readable-bigunevenread.js n=1000                             -0.10 %       ±0.69% ±0.92% ±1.20%
 streams/readable-boundaryread.js type="buffer" n=2000                -0.71 %       ±0.87% ±1.15% ±1.50%
 streams/readable-boundaryread.js type="string" n=2000                 0.04 %       ±0.91% ±1.21% ±1.58%
 streams/readable-readall.js n=5000                                   -0.21 %       ±1.86% ±2.48% ±3.22%
 streams/readable-unevenread.js n=1000                                -0.18 %       ±0.47% ±0.63% ±0.81%
 streams/transform-creation.js n=1000000                               0.21 %       ±0.59% ±0.79% ±1.02%
 streams/writable-manywrites.js n=2000000                     ***     55.44 %       ±2.41% ±3.21% ±4.20%

Be aware that when doing many comparisions the risk of a false-positive
result increases. In this case there are 10 comparisions, you can thus
expect the following amount of false-positive results:
  0.50 false positives, when considering a   5% risk acceptance (*, **, ***),
  0.10 false positives, when considering a   1% risk acceptance (**, ***),
  0.01 false positives, when considering a 0.1% risk acceptance (***)

Merge request reports

Loading