rules_jest icon indicating copy to clipboard operation
rules_jest copied to clipboard

jest runtime slower then non-bazel

Open jbedard opened this issue 3 years ago • 4 comments

Mostly due to fs sandboxing. The readlinkSync call in nextHopSync fails and throws on most invocations causing substantial cpu usage calculating stack traces.

  1. Minimize work when calculating stack traces (reduced test time by 50%): https://github.com/aspect-build/rules_js/pull/546
  2. reduce directory traversing: https://github.com/aspect-build/rules_js/pull/569
  3. avoid work when outside the sandbox, cache more: https://github.com/aspect-build/rules_js/pull/1007

jbedard avatar Oct 20 '22 19:10 jbedard

Measure 3 things:

  • non-bazel
  • rules_js with patches and no sandbox
  • rules_nodejs with patches and no sandbox

gregmagolan avatar Nov 09 '22 17:11 gregmagolan

also measure: Is the patches overhead a one-time start-up cost or does is scale with number of test cases/specs

gregmagolan avatar Nov 09 '22 17:11 gregmagolan

Overall the times with vs without the patches scale along with the number of tests, which I assume means number of files loaded. With a single test it seems about 8% slower, with 2k tests it was about 5% slower (using the best times with ~5 tries, very inaccurate but consistent enough I'll trust them).

jbedard avatar Nov 13 '22 01:11 jbedard

Curious whether aspect's "mac as local dev" customers|partners|users prefer to disable sandboxing on mac per https://github.com/bazelbuild/bazel/issues/8230#issuecomment-491075400. Confirming that we also tried --experimental_reuse_sandbox_directories and it doesn't seem to help.

Some anecdata: one of our jest test suites (Glean closed source) running under aspect takes ~6x longer to execute with the sandbox enabled vs not. 1 minute vs 6 minutes.

rc-glean avatar Sep 01 '23 16:09 rc-glean