Repository navigation
Conversation
scripts/perf-gate.sh, bench-sessions.sh and bench-views.sh extracted each baseline with `git archive` and built all of them in one shared target/perf-gate/build. Cargo names a workspace crate's artifacts by its path inside the workspace, not by where the workspace is, and rebuilds one only when a source file is newer than the last build. `git archive` dates every file at its commit, which is older than any build already in the directory, so a later baseline reused an earlier one's workspace crates: the build failed where the APIs had diverged (`missing field code in ServerFrame` after #387), linked another commit's `ws-protocol` or `ontology-client` where they had not, and returned the earlier baseline's whole server where no file had been added or removed between the two commits. The three scripts now build baselines through scripts/perf-gate-baseline.sh: each baseline gets a source and target directory of its own under target/perf-gate/baseline-build/, removed once the binary is cached. The cache moves to target/perf-gate/baseline-servers/, so a binary cached by the shared build is never read again, and the three scripts now share one toolchain key (the gate hashed `rustc -V` without its newline, the benchmarks with it). scripts/perf-gate-baseline-selftest.sh builds two baselines that differ in the root crate and in a path dependency, in both orders, and checks each binary reports its own commit. It runs in `make pre-pr-selftest` and in the full suite's perf-gate tool job.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Performance regressions and the perf gate in inputlayer/inputlayer are part of getting the engine production ready, and benchmarks run only on the benchmark host. The perf gate there currently produces wrong or failed baseline builds, found while bisecting #374:
scripts/perf-gate.shextracts each baseline withgit archive | tar -x(file mtimes = the commit's time) and builds every baseline in one sharedtarget/perf-gate/build. Cargo's metadata hash does not include the path of a path dependency, so every baseline'sinputlayer-ws-protocolmaps to the same artifact, and an older baseline extracted after a newer one was built sees files older than the fingerprint and reuses the newer crate. The build fails when the APIs diverged (missing field code in ServerFrame, from #387 built by another lane's run on the shared host clone), and silently links the wrong crate when they did not. Five bisect steps failed this way. Fix:touchthe extracted tree, or a per-baselineCARGO_TARGET_DIR. Until then only baselines at or after the newest-builtws-protocolbuild.Fix it so every baseline is built from exactly its own sources. Deliver it as a small PR; done means merged with CI green.
What Changed
scripts/perf-gate-baseline.shbuilds a baseline server fromgit archiveof its commit in its ownCARGO_TARGET_DIR(target/perf-gate/baseline-build/<commit>-<toolchain>/), removed when the build ends whether it succeeded or not, so cargo can no longer reuse another commit's workspace crates.scripts/perf-gate.sh,scripts/bench-sessions.shandscripts/bench-views.shnow call it instead of each carrying a copy of the build that sharedtarget/perf-gate/build.target/perf-gate/servers/totarget/perf-gate/baseline-servers/, and the cache path and key in.github/workflows/full-suite.ymlchange with it, so binaries built in the shared directory are not picked up again.scripts/perf-gate-baseline-selftest.shbuilds two commits of a throwaway workspace in both orders and checks that each binary reports its own commit's sources, that a cached baseline is not rebuilt, and that a commit that does not compile fails and leaves no build directory behind. It runs frommake pre-pr-selftestand theperf-gate-toolCI job;scripts/test_pre_pr.py,perf-gate/README.md,TESTING.md,CONTRIBUTINGand theMakefilecomment are updated to match.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The change is confined to benchmark tooling and durably removes the shared target directory from all three callers (gate, sessions, views) through one helper with a behavioural regression test; the only defect found is a disk leak when a baseline build fails.
Testing
No baseline commands had run before this step. I ran the new selftest against the fixed helper (all checks pass) and against the base commit's shared-directory build (3 checks fail, each naming the other commit's sources). On the real repository I built #387 (efa32ce) and then its parent (527bacc) with the fixed helper: two distinct binaries, only the #387 one containing
access_denied, and no build directory left behind. The same order with the base commit's build returned a byte-identical #387 binary for the parent in 3 seconds with exit 0 — the silent wrong-binary mode, not the compile error from the report. I interrupted a build mid-flight with SIGINT and SIGTERM (build directory removed, nothing cached), ranscripts/perf-gate.shas a quick A/A smoke on the parent baseline, and ran a tinyscripts/bench-views.sh --baseline-rev. All scenarios pass; build output was removed from the worktree afterwards. No UI surface, so no visual evidence.access_deniedstrings, efa32ce binary cc89631e… with 10access_deniedstrings)baseline-buildholds the commit's directory during the build and is empty after each signal;baseline-serversis emptytarget/perf-gate/baseline-servers/, both arms measuredEvidence: Real repo, this change: #387 then its parent, both built from their own sources
# pre-change shared build directory (target/perf-gate/servers), newer #387 built first, then its parent 527bacc3: servers/527bacc3…-415a6fa19307/ sha256=cc89631edeaa6a8b access_denied strings=10 servers/efa32cec…-415a6fa19307/ sha256=cc89631edeaa6a8b access_denied strings=10 # this change (target/perf-gate/baseline-servers), same order: baseline-servers/527bacc3…-8dc912acd5bf/ sha256=4382b65d6c577d86 access_denied strings=0 baseline-servers/efa32cec…-8dc912acd5bf/ sha256=cc89631edeaa6a8b access_denied strings=10 # 'access_denied' appears in src/ and ws-protocol/ of efa32cec (#387) in 4 files, of its parent 527bacc3 in 0 filesEvidence: Real repo, fixed helper transcript (newer then older)
Evidence: Real repo, pre-change build transcript (older baseline 'built' in 3 s)
Evidence: Selftest against the pre-change shared-directory build (fails)
PASS: the newer baseline is built from its own sources FAIL: the older baseline was built from other sources: it says 'engine-newer protocol-newer' PASS: the older baseline is built from its own sources FAIL: the newer baseline was built from other sources: it says 'engine-older protocol-older' PASS: a cached baseline is not built again PASS: the older baseline is built from its own sources FAIL: a baseline that does not compile was reported built perf-gate-baseline-selftest: 3 failure(s)Evidence: Selftest against this change (passes)
Evidence: Pre-change baseline build used for the reproductions
Evidence: Interrupted build leaves nothing behind
== SIGINT to the helper's process group, 8s into the build == during the build: baseline-build holds [22740b17…-8dc912acd5bf] helper exit status 124 after 8s after SIGINT: baseline-build holds []; baseline-servers holds [] == SIGTERM to the helper's process group, 8s into the build == during the build: baseline-build holds [22740b17…-8dc912acd5bf] helper exit status 124 after 8s after SIGTERM: baseline-build holds []; baseline-servers holds []Evidence: Interruption driver script
Evidence: Perf gate quick A/A smoke on the helper-built baseline
Evidence: Views benchmark with --baseline-rev
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
scripts/perf-gate-baseline.sh:36- The per-baseline work directory (target/perf-gate/baseline-build/<sha>-<toolchain>, an extracted tree plus a full release target dir) is removed only on the success path at line 47. Underset -e, a baseline that fails to compile, or a run that is killed mid-build, leaves it behind; it is reclaimed only if the same commit and toolchain is requested again (line 37). The old sharedtarget/perf-gate/buildwas bounded at one directory; now a bisect over N commits that do not build leaves N full target directories on the benchmark host. Remedy: settrap 'rm -rf "$WORK"' EXITonce WORK is created, and drop the explicitrm -rfat line 47. The selftest's "no build directory is left behind" check (scripts/perf-gate-baseline-selftest.sh:103) covers only the success path.scripts/perf-gate-baseline.sh:44- Simplification: the copy-to-$BIN.tmp-then-mvat lines 44-46 is a new component that guards against an interrupted copy being taken for a cached binary. No intent requirement needs it: the intent is that each baseline is built from its own sources, which the per-baseline source and target directory already delivers, and the previous code used a plaincp. Recommend reverting to a singlecpinto$BIN, unless the author wants to keep this extra hardening.scripts/perf-gate-baseline.sh:32- Moving the cache tobaseline-servers/correctly stops any binary built in the shared directory from being read again, but nothing removes the existingtarget/perf-gate/build,target/perf-gate/srcandtarget/perf-gate/servers/<sha>-*on the benchmark host's clone. They are now dead disk (servers/candidateis still used by scripts/perf-gate.sh:74) and need a one-off manual cleanup. Commits that predate this change still run their own old script when checked out on the host, so they keep using the shared directory; they cannot poison the new cache.🔧 Fix applied.
1 info still open:
scripts/perf-gate-baseline.sh:32- Moving the cache tobaseline-servers/correctly stops any binary built in the shared directory from being read again, but nothing removes the existingtarget/perf-gate/build,target/perf-gate/srcandtarget/perf-gate/servers/<sha>-*on the benchmark host's clone. They are now dead disk (servers/candidateis still used by scripts/perf-gate.sh:74) and need a one-off manual cleanup. Commits that predate this change still run their own old script when checked out on the host, so they keep using the shared directory; they cannot poison the new cache.✅ **Test** - passed
✅ No issues found.
access_deniedstrings, efa32ce binary cc89631e… with 10access_deniedstrings)baseline-buildholds the commit's directory during the build and is empty after each signal;baseline-serversis emptytarget/perf-gate/baseline-servers/, both arms measuredscripts/perf-gate-baseline-selftest.sh(fixed helper: all 8 checks pass)scripts/perf-gate-baseline-selftest.shin a scratch repo whosescripts/perf-gate-baseline.shis the base commit's shared-target/perf-gate/buildblock (3 checks fail: reproduces the bug)scripts/perf-gate-baseline.sh efa32cecthenscripts/perf-gate-baseline.sh 527bacc3on the real repo (170 s and 189 s full release builds, both exit 0,baseline-build/empty after each)old-shared-dir-baseline-shim.sh efa32cecthen527bacc3on the real repo (second 'build' finishes in 3 s and returns the #387 binary)sha256sumandgrep -c -a access_deniedover the four resultinginputlayer-serverbinariesinterrupt-check.sh scripts/perf-gate-baseline.sh:timeout -s INT 8andtimeout -s TERM 8on a baseline build held open by a sleeping build scriptscripts/perf-gate.sh --aa --baseline-rev 527bacc3 --profile quick --rounds 1 --fixtures cheap_query --no-verdict(exit 0)scripts/bench-views.sh --baseline-rev 527bacc3 --edges 1000 --writes 3 --large-writes 2 --reads 2 --keyed 1 --recursive-keyed 1 --large-recursive-keyed 1 --filler-rules 5(exit 0)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.