Skip to content

child_process: improve ipc performance

These commits reduce/improve nextTick() usage in the child_process IPC implementation.

I should point out that I wasn't sure if we should ever need nextTick() when receiving/emitting messages, so for now I just made sure that both all internal messages and only the first non-internal message in a group are emitted within the same tick.

There is a substantial performance improvement when removing nextTick() altogether for emitted messages. My thought was that these messages should always happen on at least the next tick anyway, so perhaps it would be safe to remove it completely? All tests pass with nextTick() completely removed from handleMessage().

Results with the current changes with the included benchmark:

                                                                           improvement confidence      p.value
 cluster/echo.js n=100000 sendsPerBroadcast=1 payload="object" workers=1      15.62 %        *** 1.440552e-08
 cluster/echo.js n=100000 sendsPerBroadcast=1 payload="string" workers=1      18.59 %        *** 3.478095e-10
 cluster/echo.js n=100000 sendsPerBroadcast=10 payload="object" workers=1     25.71 %        *** 6.436977e-26
 cluster/echo.js n=100000 sendsPerBroadcast=10 payload="string" workers=1     33.88 %        *** 1.812799e-22

CI: https://ci.nodejs.org/job/node-test-pull-request/8473/

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

Merge request reports

Loading