Skip to content

test(plugin): keep the back-to-back timeout test independent of machine load - #2886

Merged
robcohen merged 1 commit into
mainfrom
fix/plugin-timeout-load
Nov 7, 2026
Merged

robcohen merged 1 commit into
mainfrom
fix/plugin-timeout-load

Conversation

@robcohen

@robcohen robcohen commented Nov 7, 2026

Copy link
Copy Markdown
Member

What changed

plugin_conformance::python_plugins_back_to_back_after_a_timeout (test-only change, no behavior change):

  • The budget passed with --plugin-max-time-secs is now 15 seconds instead of 2.
  • The two nap.py plugins sleep 600 seconds instead of 90.
  • The bound on the whole run is now 2 * budget + 60 seconds (90), instead of 60. A const assertion keeps it below one nap's sleep.
  • The doc comment records the measurements behind these numbers.

The assertions are unchanged:

  • exactly two budget errors;
  • the third plugin's "has no payee" error is reported;
  • the run stays under the bound;
  • no temp files are left behind;
  • python_ready() is still the Python-presence gate, which panics under RLEDGER_REQUIRE_PYTHON_WASI.

Why

The budget is wall-clock and applies to every plugin, so error_plugin.py, which is expected to finish, had to start CPython and run within 2 seconds. On a loaded machine it could not.

The test still tests the timeout:

  • The naps sleep 40 times the budget, so they always exceed it.
  • A guest that outlived its deadline would keep the process alive for 600 seconds. That breaks the 90-second bound.

Verification

All of this ran on a 16-core machine.

Reproduced on the old test. stress-ng --cpu 64 gave a load average of 50 to 100. The test failed 5 of 5 runs, all three plugins reporting the 2-second budget error, which is the failure in the issue.

Measured the finishing plugin alone under the same load, at various budgets:

Budget Result
2 s timed out 3 of 3
3 s timed out 2 of 3
4 s timed out 1 of 3
6 s timed out 1 of 3
8 s passed 3 of 3

A budget of 15 seconds leaves about twice the worst case seen.

Ran the new test under the same load. It passed 20 of 20 runs. Each run took 37 to 52 seconds against the 90-second bound, with a load average of 75 to 100 by the end.

Checks:

  • cargo test -p rustledger --all-features with RLEDGER_REQUIRE_PYTHON_WASI=1: all pass, no skip markers.
  • cargo clippy -p rustledger --all-features --all-targets -- -D warnings
  • RUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-deps
  • cargo fmt --check

Cost

Unloaded, the test now takes about 35 seconds instead of about 5, because it waits out two 15-second budgets.

How to test

RLEDGER_REQUIRE_PYTHON_WASI=1 cargo test -p rustledger --all-features --test plugin_conformance python_plugins_back_to_back_after_a_timeout
# under load, e.g. alongside: nix shell nixpkgs#stress-ng -c stress-ng --cpu 64 --timeout 900s

Closes #2879

🤖 Generated with Claude Code

…ne load

`python_plugins_back_to_back_after_a_timeout` ran three Python plugins
under one 2-second wall-clock budget and expected only the two sleeping
ones to exceed it. Under load the third (`error_plugin.py`) hit the
budget too: with 64 CPU hogs on 16 cores it failed 5 runs out of 5, and
a 6-second budget still timed it out once in three.

The budget is now 15 seconds, about twice the worst seen, so the plugin
expected to finish does. The naps sleep 600 seconds instead of 90, so
they still exceed it, and the bound on the whole run (2 budgets plus a
minute) stays well short of one nap's sleep, so a guest left running
past its deadline still fails the test. The Python-presence assertion
is unchanged.

Under the same load it passed 20 runs out of 20.

Closes #2879

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robcohen
robcohen requested a review from a team as a code owner November 7, 2026 04:31
@codecov

codecov Bot commented Nov 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

✅ Compatibility Test Results

Metric Result
Check Compatibility 100%
BQL Compatibility 100% (raw 93%, 179 masked)
Full AST Match 100%
Total Files 826
What's tested
  • Check: Exit codes and error counts match bean-check
  • BQL: Query results match bean-query
    The headline is the EFFECTIVE rate, after pairs where beanquery
    itself is wrong are masked. raw is the same run with nothing
    masked. A widening gap means the registry grew, not that rledger
    changed.
  • Files: ~800 test files downloaded from 10+ beancount repositories

Full results available in workflow artifacts

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

Shape rustledger beancount Speedup RSS (rledger / beancount)
simple 50.6ms ± 0.7ms 717.4ms ± 10.4ms 14.2x 42.7 MB / 51.0 MB
investment 78.4ms ± 1.6ms 2732.1ms ± 28.4ms 34.9x 58.8 MB / 59.0 MB
fifo 75.5ms ± 1.0ms 15245.7ms ± 185.2ms 202.1x 54.7 MB / 58.8 MB

vs base, measured in this run

Shape base this PR Change RSS base → PR
simple 51.3ms ± 1.7ms 50.6ms ± 0.7ms -1.4% ✅ within noise 42.9 MB → 42.7 MB (-0.5%)
investment 77.7ms ± 0.7ms 78.4ms ± 1.6ms +0.9% ✅ within noise 59.0 MB → 58.8 MB (-0.3%)
fifo 78.1ms ± 8.8ms 75.5ms ± 1.0ms -3.3% ✅ within noise 54.9 MB → 54.7 MB (-0.2%)

A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: simple 0.8ms, investment 0.8ms, fifo 4.0ms), and is at least 5%.
10,000 transactions per shape · 20 runs, 3 warmup · hyperfine

What do these numbers mean?
  • simple — Two-posting transfers, one currency. The historical workload — keep as the floor, not as the benchmark.
  • investment — Cost specs, per-unit prices and lot reductions. Exercises booking and inventory, which simple leaves at 0.3%.
  • fifo — Bare {} reductions against a FIFO account — how FIFO sells are normally written. The other four shapes reach the ordered-selection path twice in 2k transactions between them, so it was effectively unprofiled until it turned out to be quadratic (plan_ordered scans every lot per reduction: FIFO ledgers are quadratic (8.8s at 20k transactions) #2083).
  • vs base: the PR and the base-branch commit it is built on, built and measured in the same job
  • RSS: peak resident set size, a single sample — reported without a verdict because there is no spread to test it against
  • A shape with no beancount column is one bean-check reports errors on; it is timed for rledger only

@robcohen
robcohen merged commit 4d786b4 into main Nov 7, 2026
47 of 48 checks passed
@robcohen
robcohen deleted the fix/plugin-timeout-load branch November 7, 2026 13:29
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.

test(plugin): python_plugins_back_to_back_after_a_timeout fails under load

1 participant