Repository navigation
perf(ci): benchmark real workload shapes, with the parse caches off (closes #2096) - #2098
Conversation
Closes #2096. The PR benchmark generated its own ledger inline, and every transaction in it was a plain two-posting expense: no cost specs, no lots, no reductions. Booking and the whole inventory engine ran zero times, so the quadratics fixed in #2083, #2086 and #2091 could not have appeared here however sound the comparison was. `gen-profile-workload.py` already documents its `simple` shape as "the floor, not the benchmark" and notes it leaves booking at 0.3%; the inline generator was that floor, used as the benchmark. It now generates `simple`, `investment` and `fifo` through that script — the same one `profile.yml` uses, so a run is reproducible locally — and reports each shape on its own row against its own base, with the significance test applied per shape so a regression in one cannot be diluted by the others holding steady. Two things found while building it: **Both tools were being measured warm.** bean-check writes a `.picklecache` and rledger writes its own binary cache, and hyperfine's warmup populates both, so every measured run was a cache hit. On `fifo` that is 18.4s cold against 0.3s warm — a 60x difference — and rledger's cache short-circuits the parser, which is most of what `check` does. A parser regression was invisible regardless of workload. Both are now disabled through `BEANCOUNT_DISABLE_LOAD_CACHE`, which is Python beancount's own variable that rledger deliberately honors, so one setting covers both. The headline moves accordingly: `fifo` is 160.9x rather than the 4.1x a warm cache reports. **beancount cannot load every shape.** `investment` fails under bean-check (#2097), so the workflow tests for that per shape rather than assuming it, and times rledger alone where bean-check errors. Timing a run that exits early would otherwise have produced a flattering number for a comparison that never happened. The comment body is now built by the step that computes the numbers and read from disk, instead of being assembled in JavaScript from ~15 interpolated step outputs. That is how the footer came to claim "5 runs, 2 warmup" for a run using 20 and 3: nothing tied the string to the value. An empty result set is now a hard error rather than a well-formed comment that happens to say nothing.
The comment explaining why the body is no longer assembled from interpolated step outputs contained the literal expression delimiters as prose. GitHub parses that syntax anywhere in the file, comments included, and an empty expression is a parse error — so the run failed before it created a single job, with only 'this run likely failed because of a workflow file issue' to go on. Caught because #2094 made this workflow run when it is itself edited. Local YAML parsing accepts the file; actionlint is what names the line.
There was a problem hiding this comment.
Pull request overview
Updates the PR benchmark GitHub Actions workflow to measure rustledger on representative, real-world workload “shapes” (including booking/inventory-heavy cases) with load caches disabled, and to publish a per-shape report assembled from the measured artifacts.
Changes:
- Replace the inline “simple-only” heredoc ledger generator with
scripts/gen-profile-workload.pyand run multiple workload shapes (simple,investment,fifo). - Run hyperfine per shape (PR vs base) and optionally time beancount only when it can successfully process that shape; disable load caches via
BEANCOUNT_DISABLE_LOAD_CACHE. - Generate the PR comment body from on-disk JSON artifacts in a Python step (instead of stitching many
${{ }}outputs in JavaScript) and hard-error on missing results.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
📊 Benchmark Results
vs base, measured in this run
A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: What do these numbers mean?
|
This PR changes a workflow file and nothing else, so both sides were built from identical Rust source — and the first run reported `simple` at +3.1%, clearing both tests and printing a colored verdict for a difference that no code caused. The standard error only describes variance WITHIN a run. Two binaries built from the same source still differ run to run through code layout, page placement and a shared runner's neighbors, and that component is invisible to the SEM: with 20 tight samples a 2ms systematic offset clears 2σ comfortably. The effect floor is what covers it, so it has to sit above the observed noise rather than at its edge — and testing three shapes is three chances to trip it. Observed identical-build differences: +3.1% in CI, and -3.3%, +3.0%, +2.5%, -2.5% locally. 5% covers those. Re-verified in both directions: the pre-#2085 quadratic still reports +1788.9% on `fifo`, and every identical-source pair now reads within noise.
|
Self-validation, since this PR runs the workflow it changes (thanks to #2094's paths fix). Run 1 — rejected outright. No jobs created, only "this run likely failed because of a workflow file issue". The cause: the JS comment explaining why the body is no longer assembled from interpolated step outputs contained the literal expression delimiters as prose. GitHub parses that syntax anywhere in the file, comments included, and an empty expression is a parse error. Run 2 — worked, and reported a false positive. Full report, all three shapes, That is the floor being too low, not the test being wrong. The standard error describes variance within a run; two binaries from the same source still differ between runs through code layout, page placement and a shared runner's neighbors, and the SEM cannot see that component — with 20 tight samples a 2ms systematic offset clears 2σ easily. Raised to 5% in d835a69, with the measurements that justify it in the commit message rather than a round number picked by feel. Run 3 — clean. All three shapes within noise, spreads of ±0.6–1.0ms this time, which is itself the evidence: the +3.1% was between-run variance, not code. Re-verified in both directions after the change — the pre-#2085 quadratic still reports +1788.9% 🔴 on |
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
…wo cold runs Review feedback, both valid. `BENCH_SHAPES` was stated in four step env blocks, so generation, timing, RSS and the report each carried their own copy of the list and could drift apart. That is the same defect this PR already fixes in the footer, which claimed a run count nothing tied it to. Hoisted to job level, along with `BENCH_WARMUP` for the same reason — hyperfine consumes it and the comment reports it back. The bean-check eligibility probe is a full cold run of the workload, and hyperfine then did its own warmup run on top: two cold runs where one would do, which on `fifo` is 18 seconds of pure waste. Beancount's warmup is now 0, with the probe serving as it. Representativeness is unchanged — with the parse caches disabled the probe cannot leave a picklecache, so it warms the page cache and Python's imports and nothing else, which is exactly what the warmup it replaces did.
Closes #2096.
The gap
The benchmark generated its own ledger inline, and every transaction in it was a plain two-posting expense — no cost specs, no lots, no reductions. Booking and the entire inventory engine ran zero times.
scripts/gen-profile-workload.pyalready documents this exact workload as "the floor, not the benchmark" and records that it leaves booking at 0.3% of instructions. The benchmark was measuring the floor.#2094 made the comparison trustworthy. This makes the workload representative.
Proof it works
Same two binaries — current
mainas base, the commit before #2085 (theplan_orderedquadratic) as the PR — through the new report:simpleinvestmentfifosimpleis what the old benchmark measured, and it reads within noise. An 18x regression in lot selection shipped invisibly. The comment now also leads with a banner naming the affected shapes.Two things found while building it
Both tools were measured warm. bean-check writes a
.picklecache, rledger writes its own binary cache, and hyperfine's warmup populates both — so every measured run was a cache hit. Onfifothat is 18.4s cold against 0.3s warm, and rledger's cache short-circuits the parser, which is most of whatcheckdoes. A parser regression was invisible regardless of workload. Disabled viaBEANCOUNT_DISABLE_LOAD_CACHE, which is Python beancount's own variable that rledger deliberately honors, so one setting covers both tools. The headline changes accordingly —fifois 160.9x faster than beancount, not the 4.1x a warm cache reports.beancount cannot load every shape.
investmentfails under bean-check (#2097, filed separately — rustledger's STRICT accepts an ambiguous lot match beancount rejects). The workflow now tests whether bean-check succeeds per shape rather than assuming it, and times rledger alone where it does not. Timing a run that exits early would have produced a flattering number for a comparison that never happened.Also
The comment body is built by the step that computes the numbers and read from disk, instead of being assembled in JavaScript from ~15 interpolated step outputs. That indirection is how the footer came to claim "5 runs, 2 warmup" for a run using 20 and 3 — nothing tied the string to the value it described. Shape descriptions are imported from the generator, so the comment cannot describe a workload differently from the thing that produced it. An empty result set is now a hard error rather than a well-formed comment that happens to say nothing.
Budget
Measured on #2094's runs: 4–8 minutes against a 30-minute timeout, dominated by the two release builds, which extra shapes do not repeat. Cold beancount adds ~80s (
fifois 18.4s per run, hence 3 runs and 1 warmup for beancount against 20 and 3 for the rledger pair — it is the context number, not the regression signal).Validated locally end-to-end: the full pipeline was run against all three shapes with real hyperfine output, the empty-result guard was confirmed to fire, and the regression detection is the table above.