Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

ci(benchmarks): enable NODE_COMPILE_CACHE for CodSpeed jobs - #9004

Open
schiller-manuel wants to merge 1 commit into
mainfrom
schiller-manuel-codspeed-compile-cache
Open

schiller-manuel wants to merge 1 commit into
mainfrom
schiller-manuel-codspeed-compile-cache

Conversation

@schiller-manuel

@schiller-manuel schiller-manuel commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 612244f3530a6625fc02252220a5cd521e9ba561

Dimension Assessment Rationale
Change confidence 3/10 ↑ The cache is used in every job: 1,163 worker cache files (7.2 MB) in client-nav and memory-client
↑ 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.

- name: Enable Node compile cache
  run: echo "NODE_COMPILE_CACHE=$RUNNER_TEMP/node-compile-cache" >> "$GITHUB_ENV"

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_ENV makes it visible to the Prepare and CodSpeed steps.
  • CodSpeed runner v5.2.1 forwards the full environment. Simulation runs valgrind with the inherited environment, and memory mode re-sources an exported environment file. Vitest forks inherit process.env.
  • Node keys cache subdirectories by Node version, arch, V8 flag hash and uid. Workers with the CodSpeed/CPU simulation flags get their own subdirectory (bce03f77 in simulation, 730412d8 in 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_CACHE run of client-nav (React) showed accepted hits in workers for jsdom, css-tree, undici, parse5, whatwg-url, Vitest and so on. dist/app.js goes 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 usage step 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)

Job Worker cache (benchmark flags) Main-process cache
client-nav (each framework) 7.2 MB, 1,163 files 18–25 MB, 2,014–3,087 files
memory-client (each framework) 7.2 MB, 1,163 files 14–16 MB, 1,461–1,781 files
ssr 0.9–1.3 MB, 54–81 files 19 MB, 2,083–2,169 files
memory-server 0.9–1.3 MB, 53–81 files 19 MB, 2,019–2,105 files

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 head 612244f ran 5 times via workflow_dispatch, one run at a time. main at 10b22c276e, 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.

Suite × framework Benchmarks Worst spread, branch Worst spread, main Median shift vs main Largest separated shift Separated (5 vs 5) Job time main → branch (median)
client-nav react 17 0.48% 1.08% -0.00% -1.21% 3/17 10.6 → 9.8 min (-7%)
client-nav solid 17 0.50% 0.52% +0.01% +0.69% 3/17 9.3 → 8.5 min (-9%)
client-nav vue 16 0.48% 0.78% -0.04% none 0/16 9.2 → 8.2 min (-11%)
ssr react 34 0.35% 0.46% -0.04% +0.76% 18/34 14.9 → 11.3 min (-24%)
ssr solid 34 0.28% 0.45% -0.06% -0.52% 20/34 11.7 → 11.6 min (-0%)
ssr vue 34 0.34% 1.99% -0.03% -0.95% 10/34 13.2 → 12.6 min (-5%)
memory-server react 10 peak 1.43%
total 0.36%
calls 0.77%
peak 0.39%
total 0.36%
calls 3.00%
peak +0.03%
total +0.03%
calls +0.06%
peak -15.32%
total -4.18%
calls -2.36%
peak 7/10
total 5/10
calls 6/10
2.9 → 2.9 min (-1%)
memory-server solid 10 peak 2.29%
total 0.62%
calls 2.97%
peak 4.69%
total 1.68%
calls 1.19%
peak -0.08%
total -0.02%
calls -0.14%
peak +2.17%
total +1.12%
calls -1.04%
peak 6/10
total 6/10
calls 6/10
2.9 → 2.7 min (-5%)
memory-server vue 10 peak 4.49%
total 0.74%
calls 1.05%
peak 4.37%
total 1.39%
calls 1.03%
peak -0.34%
total -0.13%
calls -0.06%
peak -25.48%
total -5.34%
calls +1.36%
peak 6/10
total 5/10
calls 5/10
2.8 → 2.9 min (+1%)
memory-client react 6 peak 9.27%
total 1.51%
calls 2.00%
peak 5.33%
total 1.79%
calls 1.76%
peak +0.00%
total -0.06%
calls -0.02%
peak none
total none
calls none
peak 0/6
total 0/6
calls 0/6
2.6 → 2.4 min (-8%)
memory-client solid 6 peak 5.61%
total 2.27%
calls 0.65%
peak 7.56%
total 1.46%
calls 1.94%
peak +0.12%
total -0.07%
calls +0.02%
peak +1.75%
total none
calls none
peak 2/6
total 0/6
calls 0/6
2.5 → 2.4 min (-5%)
memory-client vue 6 peak 4.52%
total 1.22%
calls 0.53%
peak 2.60%
total 0.72%
calls 0.39%
peak +0.06%
total +0.03%
calls +0.05%
peak +4.83%
total +0.32%
calls +0.04%
peak 1/6
total 2/6
calls 1/6
2.5 → 2.3 min (-8%)
  • (a) Same-commit repeatability: passes. The worst branch CPU spread is 0.50 % (client-nested-params, Solid), inside the ~0.6 % bound from test: stabilize CPU simulation with isolated SSR workers and explicit V8 settings #8248. Main exceeded it in the same window: 1.99 % (ssr control-flow unmatched 404, Vue) and 1.08 % (client-link-churn, React). Memory spreads are similar on both sides; peak memory is noisy on both, up to 9.3 % on the branch and 7.6 % on main.
  • (b) No systematic shift: fails. 54 of 152 CPU benchmarks are separated, against about 1 expected by chance. Most shifts are small (90 % are under 0.27 %), but several exceed the repeatability bound:
    • client-history navigation loop (React) −1.21 % (instructions −0.99 %)
    • ssr head (Vue) −0.95 %
    • ssr global-mw document (React) +0.76 % (instructions +0.55 %, spreads ≤ 0.02 %)
    • client-head navigation loop (Solid) +0.69 %
    • ssr dehydrate rich types (React) −0.62 %
    • memory-server serialization-payload (Vue): peak −25.5 %, total allocated −5.3 %
    • memory-server error-paths redirect (React): peak −15.3 %, total −4.2 %, alloc calls −2.4 %

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

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with the relevant test commands, or tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Chores
    • Benchmark runs now use a job-local compile cache. Workflow output also reports cache directory names, disk usage, and file counts, providing additional details alongside benchmark results. These updates affect benchmark reporting and do not change application features or behavior.

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>
@schiller-manuel
schiller-manuel requested a review from a team as a code owner November 27, 2026 14:31
@changeset-bot

changeset-bot Bot commented Nov 27, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 612244f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The benchmark workflow now sets a job-local directory for Node’s compile cache and reports each cache subdirectory’s name, disk usage, and file count after the benchmark step.

Changes: Benchmark cache workflow

Layer / File(s) Summary
Cache setup and reporting
.github/workflows/benchmarks.yml
The workflow sets NODE_COMPILE_CACHE to a job-local directory under $RUNNER_TEMP. After benchmarks, it reports each cache subdirectory’s name, disk usage, and file count.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Other

Suggested reviewers: tkdodo, sheraff

Merge Risk: Low · up to 61224

This enables a Node compile cache for CodSpeed benchmark jobs. It has no production impact, but the author's A/A comparison is still pending, so benchmark baselines could shift. Wait for that check to pass before merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: enabling NODE_COMPILE_CACHE for the CodSpeed benchmark jobs. The raw summary, the PR description, and the objectives all describe this change. The title uses the conve…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description follows the repository template. It has the Changes section, the Checklist, and the Release Impact section. It also includes the AI disclosure that the template asks for. The Changes s…
Full details: Title check

Explanation

The title names the main change: enabling NODE_COMPILE_CACHE for the CodSpeed benchmark jobs. The raw summary, the PR description, and the objectives all describe this change. The title uses the conventional ci(benchmarks) prefix and is specific enough for a teammate scanning history.

Full details: Description check

Explanation

The description follows the repository template. It has the Changes section, the Checklist, and the Release Impact section. It also includes the AI disclosure that the template asks for. The Changes section is detailed. It explains the motivation, the cache scope, how the cache reaches the workers, the cache usage data, and the A/A repeatability results. The author marks the PR as not ready to merge. The author also states that the A/A check does not pass. The checklist item 'I fully understand the code' is unchecked, which the author left open. The description is long, and much of it is measurement data. The template asks for terse text. The description still covers every required section and gives the needed information, so the check passes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 10b22c2 and 612244f.

Files selected for processing: 1

  • .github/workflows/benchmarks.yml

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@nx-cloud

nx-cloud Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 612244f

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded <1s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 12s View ↗

💡 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 2026-11-27 14:36:15 UTC

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@pkg-pr-new

pkg-pr-new Bot commented Nov 27, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@9004

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@9004

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@9004

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@9004

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@9004

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@9004

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@9004

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@9004

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@9004

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@9004

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@9004

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@9004

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@9004

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@9004

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@9004

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@9004

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@9004

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@9004

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@9004

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@9004

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@9004

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@9004

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@9004

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@9004

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@9004

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@9004

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@9004

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@9004

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@9004

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@9004

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@9004

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@9004

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@9004

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@9004

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@9004

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@9004

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@9004

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@9004

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@9004

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@9004

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@9004

commit: 612244f

@Sheraff Sheraff left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like it doesn't change test timings, so if it makes them faster then awesome

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants