Skip to content

ci(benchmark): gate the same-run comparison on file syscall counts - #2

Closed
jclaveau wants to merge 1 commit into
mainfrom
ci/syscall-count-gate
Closed

jclaveau wants to merge 1 commit into
mainfrom
ci/syscall-count-gate

Conversation

@jclaveau

Copy link
Copy Markdown
Owner

Adds a syscall-count row to the integrated benchmark's same-run comparison, so a change that multiplies filesystem work fails the check even when wall time does not move.

Why wall time missed pnpm#17500

pnpm 12.8.0 (a90ec21, "materialize imported files at the current umask") added a metadata read of the store file before every hardlink. On a hot store that roughly doubled the statx calls of an install. pnpm#17502 removed part of it. Each extra call hits a warm page cache and costs about a microsecond, so tens of thousands of them move a 1 s install by less than the comparison's 5% noise allowance. The information run below shows this today: main still makes 58% more statx calls than a candidate fix on the hot-store fresh restore, and the timing table reads "Within tolerance" (−2.1% pacquet, −5.3% pnpr).

What changes

  • Harness: integrated-benchmark --count-syscalls runs every benchmarked install twice more after the timed runs. These runs are untimed, start from the same cleanup a timed run starts from, and execute under strace --follow-forks --summary-only. Each run writes <target>/SYSCALL_COUNTS.<round>.txt.
  • run-integrated-benchmark.mjs: when HEAD and main are both benchmarked, passes --count-syscalls to the first run and stores the parsed counts in BENCHMARK_REPORT.json as syscalls. A missing or malformed strace table fails the run and names the file. The parser requires every row to parse and the rows to add up to the total row.
  • compare-integrated-benchmarks.mjs: adds a "Same-run syscall check" table after the "Same-run regression check" table. It gates about 30 file syscalls (stat family, open, link, copy, ioctl, getdents, mkdir, rename, unlink, chmod, symlink, readlink, access):
    • Regression when HEAD's fewest calls exceed main's most by more than max(2% of main, 50 calls). This fails the check.
    • Unstable when a revision's two identical runs differ by more than that tolerance. The row stays visible and is not gated, because the counts cannot tell a change from noise.
    • Each scenario and engine lists its largest change plus every row that is not within tolerance.
  • Workflow:
    • Installs strace.
    • Removes syscalls from the JSON embedded in the summary.
    • Gives each benchmark step 10 more minutes for the traced runs.
    • Adds head_ref/main_ref inputs to workflow_dispatch, so two arbitrary revisions can be compared with the current harness. The harness always comes from the dispatched ref.
    • Takes its runner from vars.INTEGRATED_BENCHMARK_RUNNER, falling back to blacksmith-8vcpu-ubuntu-2404, so a fork without Blacksmith runners can run it. Nothing changes upstream.

Thresholds

The negative run below compared 24 scenario/engine pairs and found no syscall within tolerance's reach of failing:

  • The largest spread between identical runs was statx in fresh-install cold/cold for pacquet (1,640 calls on about 160k, 1.0%). Every other spread is under 0.3% or under 50 calls.
  • 2% sits above that run-to-run noise. Most counts are fully deterministic: hot-store scenarios move by 0 to 65 calls.
  • The 50-call floor keeps rarely-called syscalls (single-digit access, a few hundred rename) from failing on scheduling-dependent retries.
  • Both regressions this PR targets are far above the line: +5.5k statx (+7%) for reverting perf(deps-restorer): stat a store file once for the hardlink mode check pnpm/pnpm#17502 alone, +28k (+58%) for main vs the candidate fix.

Proof runs (fork, ubuntu-latest)

Positive: the gate fails on a reintroduced per-link stat

Run: https://github.com/jclaveau/pnpm/actions/runs/41084341826. HEAD is this branch plus a revert of pnpm#17502 (throwaway branch ci/syscall-gate-proof-revert-17502). main is this branch. The check fails with 12 syscall regressions, all statx, while the timing table reports every scenario within tolerance:

Scenario Engine Syscall main calls (max) HEAD calls (min) Change Tolerance Identical-run spread Result
isolated-fresh-restore-cold-cache-cold-store pacquet statx 123480 128941 +4.4% 2470 84 Regression
isolated-fresh-restore-cold-cache-cold-store pnpr statx 123931 129396 +4.4% 2479 267 Regression
isolated-fresh-restore-hot-cache-hot-store pacquet statx 76625 82203 +7.3% 1533 5 Regression
isolated-fresh-restore-hot-cache-hot-store pnpr statx 76638 82211 +7.3% 1533 9 Regression
isolated-fresh-install-cold-cache-cold-store pacquet statx 160390 164717 +2.7% 3208 1640 Regression
isolated-fresh-install-cold-cache-cold-store pnpr statx 124129 129536 +4.4% 2483 4 Regression
isolated-fresh-install-hot-cache-hot-store pacquet statx 80484 85928 +6.8% 1610 44 Regression
isolated-fresh-install-hot-cache-hot-store pnpr statx 77531 82953 +7.0% 1551 3 Regression
isolated-fresh-install-cold-cache-hot-store pacquet statx 81498 86865 +6.6% 1630 38 Regression
isolated-fresh-install-cold-cache-hot-store pnpr statx 77529 82950 +7.0% 1551 1 Regression
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet statx 123393 128940 +4.5% 2468 18 Regression
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr statx 123485 129030 +4.5% 2470 13 Regression

Timing rows for the same scenarios in the same run:

Scenario Engine main median HEAD median Change Tolerance Result
isolated-fresh-restore-hot-cache-hot-store pacquet 982.13 ms 924.03 ms -5.9% 49.11 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pnpr 1075.54 ms 1032.48 ms -4.0% 53.78 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pacquet 1164.42 ms 1196.38 ms 2.7% 58.22 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pnpr 883.00 ms 887.34 ms 0.5% 44.15 ms Within tolerance

I first tried the literal pair, a90ec21 against its parent 7679530. It cannot run with today's harness: the September pnpr binary rejects --packument-ttl, and its revision mock never starts. That is why the proof reverts the remaining part of the regression instead.

Negative: the gate passes on a neutral change

Run: https://github.com/jclaveau/pnpm/actions/runs/41084352182 (success). HEAD is this branch, main is main. All 15 scenarios ran, and the syscall check reported no regression and no unstable row.

Information: current main vs a candidate fix

Run: https://github.com/jclaveau/pnpm/actions/runs/41084361972. HEAD is 896dc10 (main after pnpm#17502), main is 2221b90 (jclaveau/pnpm fix/hardlink-mode-check-per-source, a fix that reads the mode once per source file). It shows what pnpm#17502 left of pnpm#17500:

Scenario Engine Syscall main calls (max) HEAD calls (min) Change Tolerance Identical-run spread Result
isolated-fresh-restore-hot-cache-hot-store pacquet statx 48331 76615 +58.5% 967 8 Regression
isolated-fresh-restore-hot-cache-hot-store pnpr statx 48345 76630 +58.5% 967 11 Regression
isolated-fresh-install-cold-cache-cold-store pacquet mkdir 10809 10686 -1.1% 217 247 Unstable (identical runs differ by 247, not gated)
isolated-fresh-install-cold-cache-cold-store pacquet statx 140879 160621 +14.0% 2818 1536 Regression
isolated-fresh-install-hot-cache-hot-store pacquet statx 52209 80385 +54.0% 1045 65 Regression
isolated-fresh-install-hot-cache-hot-store pnpr statx 48979 77524 +58.3% 980 3 Regression
isolated-fresh-install-cold-cache-hot-store pacquet statx 53338 81517 +52.8% 1067 18 Regression
isolated-fresh-install-cold-cache-hot-store pnpr statx 48985 77529 +58.3% 980 3 Regression

In the same run the timing table shows -2.1% (pacquet) and -5.3% (pnpr) for the hot-store fresh restore, both "Within tolerance".

Tests

node --test .github/scripts/compare-integrated-benchmarks.test.mjs .github/scripts/run-integrated-benchmark.test.mjs passes 25 tests. They cover strace parsing, the 2% and 50-call boundaries, unstable runs, refusal of missing, partial or invalid counts, and the table rendering. Disabling each guard in turn fails at least one test.

Refs pnpm#17500, pnpm#17502.

Assisted-by: Claude:claude-opus-5-5

pnpm 12.8.0 doubled the statx calls of a hot-store install
(pnpm#17500) while the timing check stayed within tolerance: on a
warm page cache a stat costs about a microsecond, so 67k extra calls
move a 1 s install by less than the 5% noise allowance.

When HEAD and main are compared, the harness now runs every install
twice more, untimed, under `strace --follow-forks --summary-only`, and
the run script stores the per-syscall counts in the report. The
comparison adds a "Same-run syscall check" table: a file syscall
regresses when HEAD's fewest calls exceed main's most by more than 2%
of main or 50 calls, whichever is larger. A syscall whose two
identical runs differ by more than that is reported unstable and not
gated.

The workflow also takes `head_ref`/`main_ref` dispatch inputs, so a
past regression can be benchmarked with the current harness, and an
`INTEGRATED_BENCHMARK_RUNNER` repository variable, so forks without
Blacksmith runners can run it.

Assisted-by: Claude:claude-opus-5-5
@jclaveau

jclaveau commented Nov 1, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #3, which carries this commit together with the round-2 review fixes.

Assisted-by: Claude:claude-opus-5-5

@jclaveau jclaveau closed this Nov 1, 2026
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.

1 participant