Skip to content

CodSpeed: arrow in template changes by about 13% between runs of the same commit #5141

Open

Description

@cgaaf

Summary

The web-server benchmark non-ascii-template: 1000 rows (renderToString + UTF-8 encode) > arrow in template reports one of two instruction counts for the same commit, about 13% apart. CodSpeed reports the difference as a regression or an improvement depending on which level the base run and the PR run each landed on.

A second benchmark, projection derive: write one NESTED field (reference) in the signals lane, does the same thing by about 31%, independently of the first.

How often it appears

Of the 75 pull requests between #5008 and #5132 that have a CodSpeed comment:

Benchmark PRs flagged Reported values
arrow in template 20 (16 slower, 4 faster) 10.9 ms ↔ 12.5 ms, sometimes 11.8 ms
projection derive: write one NESTED field 24 (both directions) 945 µs ↔ 1,245 µs

Examples: #5124, #5125 and #5127 report arrow in template at 10.9 ms → 12.5 ms; #5020 and #5021 report it at 12.5 ms → 10.9 ms.

Reproduction with no code change

I ran the benchmark lanes on a fork at commit 99db9bc with the same runner (codspeed v4.19.1, simulation mode, upload skipped), on ubuntu-24.04 GitHub-hosted runners, and read the instruction counts from the callgrind output.

arrow in template, full web-server lane, unmodified configuration:

Level Instructions Runs
Fast 21.9M – 22.3M about 60 of 76
Slow 24.2M – 25.1M about 16 of 76

Observations:

  • The same runner produced both levels on consecutive runs of the lane.
  • Runners with an AMD EPYC 9V74 produced the slow level more often than runners with a Xeon 6975P-C. Both levels occurred on both.
  • Running non-ascii-template.bench.tsx on its own gave 22.06M on all 16 runners, twice each. The slow level appeared only when the whole lane ran.
  • No garbage collection ran inside the measured call in either state.
  • Capping the young generation (--max-semi-space-size=1) did not change the result.
  • CodSpeed's simulated cache geometry is fixed by the runner, so host cache sizes do not enter the count.

What changes the result

Each row is the full web-server lane on @codspeed/vitest-plugin 5.4.0 with one V8 flag added, except the last.

Configuration arrow in template Runs
Unmodified 21.9M – 25.1M, two levels 76
--always-sparkplug 21.26M – 21.29M on 33; 21.52M on 1 34
--no-maglev 25.742M – 25.746M 12
--always-sparkplug --no-maglev 25.385M – 25.386M 12
--no-sparkplug 29.70M – 30.95M 16
@codspeed/vitest-plugin 6.1.1, no added flag 25.39M 28

@codspeed/core 5.4.0 passes --no-opt but not --no-maglev. Version 6.1.1 adds --always-sparkplug and, on Node 24 and later, --no-maglev.

The benchmark is measured as one call after seven warm-up calls. With Maglev disabled the count is constant and higher than both unmodified levels. I have not established what decides which level an unmodified run reaches.

Effect on the other lanes

Number of benchmarks whose instruction count differed by more than 5% across 6 fresh runners at the same commit (first run of the lane on each runner):

Lane (benchmarks) Unmodified 5.4.0 --always-sparkplug --no-maglev Both flags Plugin 6.1.1
signals (148) 1 0 1 2 1
web-client-1 (8) 0 0 0 1 1
web-client-2 (25) 0 0 0 0 0
web-server (20) 1 0 0 0 0

Details behind the table:

  • --always-sparkplug, web-server: no benchmark differed by more than 2%.
  • --always-sparkplug, web-client-1: replace-full: 1000 rows differed by 4.6% (582M – 609M). Unmodified, it differed by under 1%.
  • --always-sparkplug, web-client-2: on a second run of the lane on the same runner, tail, keyed by fn: remove last + insert last (1000 rows) read 5.26M against 4.63M – 4.64M on the other 11 runs.
  • Plugin 6.1.1 and both flags, web-client-1: replace-full: 1000 rows differed by 5.3% – 6.3% (892M – 949M).
  • --no-maglev and plugin 6.1.1: instruction counts on the client lanes are roughly 1.6× to 1.9× the unmodified counts.

The projection benchmark

projection derive: write one NESTED field (reference) reads 1.48M or 1.94M instructions unmodified. The whole difference is in one code address.

Configuration Values Notes
Unmodified 1.48M / 1.94M First run of the lane 1.94M and second run 1.48M on 5 of 6 runners
--always-sparkplug, full lane 1.517M – 1.520M 12 of 12 runs
--always-sparkplug, earlier round two levels, reversed Not consistent with the row above
--no-maglev 2.18M / 1.72M First run 2.18M on 5 of 6 runners, second run 1.72M on all 6
Both flags 1.77M / 2.22M Same level on both runs of a given runner
Plugin 6.1.1 1.76M – 1.78M, some at 2.67M Same level on both runs of a given runner

I have no explanation for this benchmark.

One configuration tested through the repository's own config

Adding the flag to packages/web/vite.config.server-bench.mjs only, with everything else unmodified:

test: {
  execArgv: ["--always-sparkplug"],
  // ...
}

On 6 runners, arrow in template read 21.274M – 21.280M and no web-server benchmark differed by more than 2%. The other --always-sparkplug runs above injected the flag by patching @codspeed/core.

This shifts the lane's baselines once. Median instruction counts, unmodified → with the flag:

Benchmark Change
search-results: 50 items 2.52M → 4.29M (+71%)
color-picker: 14 colors 0.81M → 0.47M (−42%)
hn story page: no link handler 48.9M → 45.8M (−6.4%)
spread-static-tail: dynhead 11.3M → 10.7M (−5.9%)
polymorphic-chain: compiled 11.7M → 11.2M (−4.8%)
arrow in template 22.2M → 21.3M (−4.2%)
spread-static-tail: tail 9.04M → 8.70M (−3.8%)
other 13 benchmarks within ±1.5%

Not tested

  • Uploading results to CodSpeed under any of these configurations. All runs used --skip-upload, so I have not seen how the dashboard treats them.
  • Wall-clock mode.
  • Any Node version other than the one in .nvmrc.

Data

Workflow runs on the fork, each with per-runner hardware details and callgrind totals as artifacts (artifacts expire 7 days after the run):


Found while looking into the CodSpeed report on #5124. Written with Claude Fable 5.2 (in Claude Code), which also designed the measurements, ran them on GitHub Actions and tabulated the results.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions