Skip to content

src: rewrite task runner in c++

This is a rewrite of the task runner in C++. The benchmark speaks for themselves with a caveat of removing support for --env-file and related CLI flags in the task runner. I think the performance can be improved further more since somehow we still interact with V8.

While moving the implementation to C++, I've moved the tests for escapeShell to C++ as well, since we can't write a unit test running on JS side anymore. (Ref: please take a look at cctest/test_node_task_runner.cc

I'll investigate further after this pull-request to reduce the task runner to around ~5ms.

❯ hyperfine '../node/main-branch --run test' '../node/cpp-rewrite --run test' 'npm run test' -i
Benchmark 1: ../node/main-branch --run test
  Time (mean ± σ):      28.9 ms ±   0.9 ms    [User: 24.2 ms, System: 3.4 ms]
  Range (min … max):    27.5 ms …  31.7 ms    96 runs

  Warning: Ignoring non-zero exit code.

Benchmark 2: ../node/cpp-rewrite --run test
  Time (mean ± σ):      18.3 ms ±   0.6 ms    [User: 16.0 ms, System: 1.5 ms]
  Range (min … max):    17.5 ms …  20.8 ms    139 runs

  Warning: Ignoring non-zero exit code.

Benchmark 3: npm run test
  Time (mean ± σ):     148.8 ms ±   2.0 ms    [User: 131.9 ms, System: 22.1 ms]
  Range (min … max):   145.3 ms … 154.5 ms    19 runs

  Warning: Ignoring non-zero exit code.

Summary
  ../node/cpp-rewrite --run test ran
    1.58 ± 0.07 times faster than ../node/main-branch --run test
    8.14 ± 0.29 times faster than npm run test

cc @nodejs/performance

Merge request reports

Loading