Set up performance measurement for pks check - #53
Open
perryqh wants to merge 1 commit into
Open
Conversation
Groundwork for a series of performance changes. No behavior changes. - `[profile.release]` was left at cargo defaults (lto = false, codegen-units = 16), so `cargo build --release` -- what dev/run_benchmarks.sh measures -- was less optimized than the shipped `dist` build. Now thin LTO + one codegen unit. Measured on a 51k-file app: 5.289s -> 5.127s, and run variance drops from +/-0.084s to +/-0.010s. Fat LTO was measured too and is worse on both axes (5.433s, 42s build vs 27s), so thin stays. - Add `dev/measure.sh`: hyperfine mean plus a per-phase table derived from the `--debug` tracing already in the tool. - Add trace points around the previously untraced tail after the checkers finish, so dropping the reference vector, diffing package_todo.yml, writing output, and final teardown are each attributable instead of appearing as one unexplained gap before process exit. - dev/run_benchmarks.sh: honor PKS_ROOT/PKS_BIN instead of hardcoding a sibling ../pks checkout, and drop the single-file benchmark (that command is buggy and slated for removal, so we shouldn't track a number for it). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
perryqh
force-pushed
the
perf/measure-setup
branch
from
August 19, 2026 22:26
a2d3077 to
4008a93
Compare
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.
Groundwork for a series of performance changes to
pks check. No behavior changes — this branch only makes the tool measurable, and fixes the release profile.Note
Stacked on #52. The base is
bump-rust-toolchain-1.97.1, so the diff above shows only the measurement work. GitHub will retarget this tomainautomatically once #52 merges.Why
There was no way to answer "did that make it faster, and which phase moved?" without a lot of manual setup.
dev/run_benchmarks.shcompares against packwerk but only reports a total, and assumed a specific directory layout.What's here
1.
[profile.release]was never configured. It sat at cargo defaults —lto = false,codegen-units = 16— socargo build --release, which is exactly whatdev/run_benchmarks.shmeasures, was less optimized than the shippeddistbuild. Now thin LTO and one codegen unit.Measured on a 51,513-file application:
lto = "thin"lto = "fat"Fat LTO is slower to run and 55% slower to build, so thin it is — which also matches the existing
distprofile. The numbers are recorded as a comment inCargo.tomlso this doesn't get re-litigated.The variance drop matters as much as the mean: ±0.084 s → ±0.010 s. Several changes I want to measure next are worth 3–8%, which is not distinguishable from noise at the old variance.
2.
dev/measure.sh— hyperfine mean plus a per-phase table derived from the--debugtracing already in the tool. No new instrumentation was needed for the phase breakdown; the tracing subscriber already timestamps every span.3. Four trace points around the tail after the checkers finish. Dropping the reference vector, diffing
package_todo.yml, writing output, and final teardown were previously one unexplained gap before process exit. They're now attributable — which immediately paid off: a gap I had estimated at 0.435 s turned out to be 0.120 s, and the "optimization" I was about to write for it would have been worth ~12 ms.4.
dev/run_benchmarks.sh— honorsPKS_ROOT/PKS_BINinstead of hardcoding a sibling../pkscheckout, createstmp/if missing, and errors clearly if the binary isn't built. Also drops the single-file benchmark block, since that command is buggy and slated for removal and we shouldn't defend a number for it.Sample output
Verification
cargo test— 257 passingcargo clippy --all-targets --all-features— cleancargo fmt --all -- --check— cleandev/measure.shsmoke-tested againsttests/fixtures/simple_app, which caught a real bug: hyperfine aborts on a non-zero exit, andpks checkexits 1 whenever it finds violations. Now passes--ignore-failure. Without that the script would have failed on essentially every real application.🤖 Generated with Claude Code