Repository navigation
ci(benchmarks): enable NODE_COMPILE_CACHE for CodSpeed jobs - #9004
schiller-manuel wants to merge 1 commit into
Conversation
Each TanStack Router benchmark file starts a fresh Vitest worker that recompiles jsdom, Vitest and their dependencies under valgrind. A job-local Node compile cache lets later workers reuse V8 code cache. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
View your CI Pipeline Execution ↗ for commit 612244f
💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗ ☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version PreviewNo changeset entries found. Merging this PR will not cause a version bump for any packages. |
Sheraff
left a comment
There was a problem hiding this comment.
seems like it doesn't change test timings, so if it makes them faster then awesome
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
612244f3530a6625fc02252220a5cd521e9ba561↑ Branch CPU repeatability holds: worst spread 0.50 % over 5 runs, inside the ~0.6 % bound from #8248
↑ Total median runner time across the 12 jobs drops 8.8 %, mostly in ssr React and client-nav
↓ Criterion (b) fails: 54 of 152 CPU benchmarks shift outside both runs' ranges, up to −1.21 %, and instruction counts move too
↓ memory-server peak memory shifts −25.5 % (serialization-payload vue) and −15.3 % (error-paths redirect react), with spreads under 0.1 %
↓ A per-job cache leaves the first bench file of each job cold, and client-nav/ssr file order varies between runs
🎯 Changes
Enables Node's module compile cache for the CodSpeed benchmark jobs.
Why: every bench file runs in a fresh Vitest worker. In CI the Vitest isolate hint reports 9–12 s of startup per file, most of it importing jsdom (about 1,100–1,260 modules) under valgrind. Locally, the compile cache cut jsdom's import CPU by 22–30 %. CI is where that CPU is inflated, so this PR tests it there.
Cache scope: per job, not restored across runs. No
actions/cache. Results can't depend on cache state from another run or branch, and nothing needs invalidating on Node or dependency bumps. A per-job cache still helps, because bench files run serially in their own workers: the second and later workers reuse what the first one compiled.How it reaches the workers:
$GITHUB_ENVmakes it visible to the Prepare and CodSpeed steps.process.env.bce03f77in simulation,730412d8in memory mode), separate from the main Vitest/Nx processes (310b2ce3).What gets cached: only modules that Node itself loads from disk. A local
NODE_DEBUG_NATIVE=COMPILE_CACHErun of client-nav (React) showed accepted hits in workers for jsdom, css-tree, undici, parse5, whatwg-url, Vitest and so on.dist/app.jsgoes through Vitest's module runner (vm), so it's never code-cached. SSR workers cache only 54–81 files, i.e. Vitest plus the server bundle's Node-loaded externals, and those externals run inside the measured region.The
Report Node compile cache usagestep costs well under a second. It's the evidence that the cache is used, so it stays while this is a trial.Cache usage (from the diagnostic step)
Vitest's isolate hint per file, median of 5 runs, main → branch: client-nav React 11.7 → 9.3 s, Solid 9.1 → 7.2 s, Vue 9.8 → 7.7 s; memory-client 4.8 → 3.3–4.2 s.
A/A check: does not pass
Method from #8248 and
benchmarks/README.md("Repeatability checks"). The branch head612244fran 5 times viaworkflow_dispatch, one run at a time.mainat10b22c276e, which differs only by this workflow change, ran 5 times: its push run plus 4 dispatches, interleaved with the branch runs. Every run has all 152 CPU and 48 memory results, none inherited (each result's id is newer than its run). Per-benchmark values come from CodSpeed's public GraphQL API (repository.run(id).results).Spread =
100 × (max / min − 1)over 5 runs. Shift = branch median vs main median. "Separated" means the 5 branch values fall entirely outside the range of the 5 main values; by chance this happens for about 1 benchmark in 152. Many memory-server metrics are exactly deterministic, so any change there counts as separated.total 0.36%
calls 0.77%
total 0.36%
calls 3.00%
total +0.03%
calls +0.06%
total -4.18%
calls -2.36%
total 5/10
calls 6/10
total 0.62%
calls 2.97%
total 1.68%
calls 1.19%
total -0.02%
calls -0.14%
total +1.12%
calls -1.04%
total 6/10
calls 6/10
total 0.74%
calls 1.05%
total 1.39%
calls 1.03%
total -0.13%
calls -0.06%
total -5.34%
calls +1.36%
total 5/10
calls 5/10
total 1.51%
calls 2.00%
total 1.79%
calls 1.76%
total -0.06%
calls -0.02%
total none
calls none
total 0/6
calls 0/6
total 2.27%
calls 0.65%
total 1.46%
calls 1.94%
total -0.07%
calls +0.02%
total none
calls none
total 0/6
calls 0/6
total 1.22%
calls 0.53%
total 0.72%
calls 0.39%
total +0.03%
calls +0.05%
total +0.32%
calls +0.04%
total 2/6
calls 1/6
Instruction counts move as well as the simulated cache misses, so this isn't only a memory-layout artifact. Merging would reset these baselines once.
There's a second, structural concern. With a per-job cache the first bench file in each job runs cold and the rest run warm. client-nav and ssr file order changes from run to run (only the base React client-nav file is reliably first). The A/A spreads don't show a cold/warm effect yet, but measured values now depend on cache state built by earlier workers in the same job.
CI time
Medians of 5 runs per side. Total runner time across the 12 jobs drops from 85.1 to 77.6 min (−8.8 %). ssr React saves 3.6 min (−24 %), client-nav saves 0.7–1.0 min per job (−7 to −11 %), and ssr Solid, memory-server React and memory-server Vue are within noise. Wall time for the whole workflow, set by the slowest ssr job, drops by about 2 min.
Recommendation
Do not merge as is. Repeatability holds, but the cache changes what CodSpeed measures: CPU shifts up to 1.2 % and memory-server peak shifts up to 25 %. It also makes measured values depend on file order within a job. About 9 % of runner time isn't worth a baseline reset plus that coupling. If the saving matters later, it could come from cutting jsdom's import cost upstream (lazy-loading
undici/css-tree), which doesn't touch the measured code.Runs
Branch (
612244f): 46016515419, 46018433748, 46020513908, 46022840376, 46024949719. CodSpeed:6b09947e40dceb70df55aac9,6b099780c05a65ca4ab173d6,6b099ad7d63771a6e79960c1,6b099e5ef6d6c6db80b519c9,6b09a2476f4b9126ee53318d.Main (
10b22c276e): 46010214510 (push), 46016521135, 46019149175, 46021209129, 46023324124. CodSpeed:6b098a8a7881658aca8efc93,6b09949b40dceb70df55aacf,6b0998b56f4b9126ee533075,6b099be312fca4aeb496ea56,6b099fc2f6d6c6db80b51a26.AI disclosure: this PR, including the measurements, was written by an AI agent (GitHub Copilot).
✅ Checklist
🚀 Release Impact
Summary by CodeRabbit