Skip to content

test: make the slowest tests fast without losing what they assert - #525

Merged
lg2m merged 22 commits into
test/delete-low-valuefrom
perf/fast-tests
Nov 1, 2026
Merged

lg2m merged 22 commits into
test/delete-low-valuefrom
perf/fast-tests

Conversation

@lg2m

@lg2m lg2m commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #524.

Change

The slowest tests now run fast, and each one still checks what it checked before. This covers findings D1–D19, except D10 and D20, which earlier PRs already did. Production behavior is unchanged: the only new knobs are test-only (#[cfg(test)]) or an internal parameter whose production default is unchanged.

It also fixes the follow-up from #523: the qq-core::soak goal_enabled_soak_measures_real_notices_across_compaction flake.

Flake cause. The brief recorded the failing field as work_requests_with_goal, but the failing assertion is soak.rs:44, durable_calls == 72, which read 0. When the fixture sets an active goal, the scheduler queues a goal-origin run at once. On a loaded core that run is claimed before the fixture's own prompt. It does all 72 work turns, while the report counts ToolCallFinished for the prompt run, which did none. Per-run RunStarted logging showed the goal-origin run starting first in every failure. Fix: the goal-mode fixture now measures the goal run that the scheduler queues (Fixture::goal_run), with a per-run turn cap that fits the 72-turn script. The goal-mode turn_overhead bench uses the same fixture and still passes its asserts (QQ_BENCH_GOAL=1 QQ_BENCH_ITERATIONS=1 cargo bench -p qq-core --bench turn_overhead). docs/runbooks/perf-recording.md now says the goal mode measures the goal run.

What changed, by item:

  • D1: The two multi-day soaks are now one test, multi_day_driver_survives_real_process_kills_waits_and_outages. It runs 22 steps with two real process kills, three waits, two interleaved prompts, two outages, and achievement through the real check. It then replaces the goal and runs the deadline to exhaustion, which the old unchecked variant used to prove. The reopen and no-recharge assertions are unchanged. It stays in the soak group (the multi_day_ filter still matches).
  • D15: The busy_workspace fixture's pacing is now a parameter. The perf run keeps 560 × 1 KiB chunks with 10 ms pauses. The test streams 505 × 8 KiB chunks with no pause and still commits over 512 events, the same gate. The captured-output timeout test waits 100 ms instead of 1 s.
  • D6: The four escaped-tree cases (cancel and timeout, × pipe and setsid) now run at the same time instead of one after another. The real timeout_seconds: 3 still runs.
  • D3: The in-run compaction scripts called a real sh 640 times to make 6 KB output. A test tool now returns the same stored 2,051-byte bounded shell result. Each test sees exactly as many compactions as before, which I checked by logging the counts on both trees. maximum_goal_is_verbatim… runs 30 turns instead of 72 and still compacts five times per row (the test asserts at least three).
  • D5: The summarizer deadline tests use a 2 s duration limit instead of 5 s. On one loaded core the run takes about 520 ms to reach the hung summarizer (22 ms unloaded). The 300–500 ms the brief suggested failed under stress. 2 s passed 40/40.
  • D2: Each run reads three 90 KiB notes instead of one, so the window-less session reaches the stale-read shedding point after about 40 runs instead of 140. The assertions are unchanged.
  • D4: The capped file is paged from line 40,000, which still takes seven pages to reach the terminal marker. The first page is covered by ab3_scan_cap_continuation_does_not_claim_an_exact_remainder.
  • D7: The yield and timeout tests wait for the command's first output (or its pid report), then pause and advance the clock past the 1 s limit. a_shell_timeout_names_its_limit_and_how_to_raise_it and shell_timeout_kills_the_whole_process_group ran the same 1 s timeout and are now one test, shell_timeout_kills_the_whole_process_group_and_names_its_limit, with both sets of assertions.
  • D9: Store::open keeps its 1.5 s ownership wait. The two busy-store tests open through an internal open_waiting with a 50 ms wait and still assert that the refusal waited at least that long. I did not add the other D9 limits (see Known impact).
  • D8: A test-only tool_calls_per_slice on Runtime reaches the run loop through the agent profile. Production builds still use MAX_TOOL_CALLS_PER_SLICE. The slice-report tests run with a 32-call slice. one_durable_run_continues_across_the_internal_tool_budget (and the text-only slice-report audit test) keep the full 256-call continuation. The empty-checkpoint billing test now checks the exact cost instead of > 61_700.
  • D17: The cd-prefixed read test runs the command once and checks that its execution receipt counts as work and that is_progress is true. ab1_verified_exec_reads_report_on_request_sixty_five keeps the 64-call end-to-end run.
  • D11: The final-slot test is parametrized by RUNS and uses 3; it also passes at 10. It is renamed from goal_tenth_run_… to goal_final_run_… because the old name would now be false, and .config/nextest.toml is updated to match.
  • D16: The close-drain test runs once instead of 16 times. The draining flag is checked under the lifecycle lock, so the drain is deterministic, and 30 stress iterations passed. The permission-selection matrix now uses one store, with a fresh session per row.
  • D13: The qq-server tests build their HTTP client once per test thread instead of per request.
  • D14: with_endpoint is test-only, and it now reuses one rustls client per thread. The effort matrix reuses one compiler per thread.
  • D18: The output-cap compaction is triggered through a 128 Ki-token window instead of 4 MiB of history. 128 Ki is the smallest window where the summarizer's window/8 rule leaves 16,384 uncapped.
  • D19: The 15-row goal-check authority matrix opens two runtimes (allowed and denied) instead of 15, with a workspace and session per row.
  • D12: The child-budget arithmetic is now unit tables on BudgetMeter: child_budget after charge_child, and exceeded after an audit's spend, one row per limit family. A mutation that dropped the output-token check failed the new table. End to end, each delegation test keeps one known-spend row and one unknown-spend row, and the nested-receipt test corrupts and restores one store instead of building three.

Verification

Timings are local, from cargo nextest run --workspace --profile ci --all-features on 32 cores, junit.xml time per test.

Full workspace, total test-seconds: 235.9 s → 170.5 s (172.0 and 178.8 on two re-runs under load 5–6 from a preceding check). Wall time 12.7 s → 5.7 s.

Item Test Before (s) After (s)
D1 multi_day_* (two tests → one) 12.07 2.83
D15 busy_workspace_fixture_seeds_a_long_history 6.38 1.13
D15 captured_output_timeout_kills_and_reaps_the_process_group 1.01 0.11
D6 cancel_and_timeout_kill_descendants_that_left_the_group 6.23 3.08
D3 maximum_goal_is_verbatim_immediately_after_three_in_run_summaries 6.19 0.54
D3 an_in_run_summary_cut_at_the_output_limit_is_continued_and_joined_verbatim 3.88 0.58
D3 an_in_run_marker_survives_restart_and_folds_into_a_later_between_run_compaction 1.89 0.31
D3 an_in_run_summarizer_keeps_the_session_context_before_its_prompt 1.89 0.24
D3 one_run_spanning_several_windows_compacts_its_own_turns_and_completes 1.86 0.27
D3 an_empty_faulted_attempt_inside_the_replaced_span_keeps_replay_equal_to_live 1.17 0.19
D3 a_dense_tokenizer_compacts_in_run_instead_of_failing_at_the_guard 1.01 0.21
D3 cancelling_during_in_run_compaction_settles_both_runs_once 0.81 0.14
D3 a_rejected_in_run_summary_fails_the_run_closed_without_resending_the_overflow 0.79 0.14
D3 an_in_run_compaction_that_cannot_start_fails_the_prompt_run_as_a_server_failure 0.79 0.13
D3 a_provider_window_rejection_compacts_the_run_and_continues 0.50 0.11
D5 stopping_a_pending_summarizer_preserves_measured_turns_and_unknown_totals 5.23 2.21
D5 original_deadline_stops_a_summarizer_backoff_without_retrying 5.07 2.06
D2 a_session_without_a_window_still_sheds_stale_reads_before_the_storage_backstop 5.08 2.15
D4 ab3_scan_cap_offsets_remain_readable_until_a_terminal_marker 4.56 0.32
D7 a_run_follows_a_yielded_command_and_stops_the_rest_when_it_ends 2.05 0.15
D7 yielded_commands_stop_on_cancel_and_on_teardown 2.05 0.15
D7 a_yielded_escaped_tree_dies_when_the_run_ends 2.04 0.08
D7 saturated_live_output_never_masks_the_shell_timeout 1.41 0.05
D7 a_long_command_yields_and_completes_through_command_status 1.03 0.08
D7 shell_timeout_kills_the_whole_process_group_and_names_its_limit (two tests → one) 2.04 0.07
D9 a_store_has_one_owner_and_a_busy_store_is_refused_without_mutation 1.55 0.10
D9 a_busy_store_is_refused_before_the_database_is_created 1.51 0.06
D17 ab1_cd_prefixed_reads_without_context_verification_count_as_work 1.78 0.07
D11 goal_final_run_reserves_a_durable_tool_free_handoff_after_early_completion 1.43 0.79
D16 closing_goal_host_drains_accepted_work_without_admitting_successors 0.87 0.07
D16 session_resume_permission_selection_is_shared_by_prompt_and_goal 0.62 0.17
D13 command_routes_match_the_protocol_table 0.77 0.06
D14 every_effort_reaches_responses_standard_codex_and_chat_transport 0.77 0.14
D14 three rejects_*headers tests 0.97 0.07
D18 compaction_sends_and_persists_the_effective_output_cap 0.78 0.24
D19 auto_goal_checks_derive_contained_authority_without_human_consent 0.61 0.19
D12 budgeted_read_children_refuse_exhausted_or_unknown_remainders 0.75 0.29
D12 audit_overspend_and_unknown_spend_exhaust_the_parent 0.37 0.14
D12 nested_spend_receipt_rejects_incomplete_or_overflowing_descendants 0.28 0.13
D8 five slice-report tests 2.92 0.95
sum of rows 94.0 21.8

Stress (taskset recipe: three busy loops pinned to core 0, --retries 0):

  • goal_enabled_soak_measures_real_notices_across_compaction, before: 1/40, 3/60, 8/30 and 12/60 failed, all on durable_calls 0 ≠ 72. After the fix: 60/60 passed.
  • Changed process tests: cancel_and_timeout_kill_descendants_that_left_the_group 40/40 passed. The six D7 tests together: 40/40 passed. captured_output_timeout… at 100 ms: 200/200 passed. The D5 pair at 2 s: 40/40 passed; at 500 ms, 10 of 40 failed on "the second summary request must really hang", which is why I kept 2 s. closing_goal_host_drains…, unloaded: 30/30 passed.

Commands:

  • cargo xtask check --full: passed on the head commit (fmt, lint, clippy, workspace tests with soak, minimal provider profile).
  • cargo clippy -p qq-core --all-targets --no-default-features -D warnings: passed.
  • Test lists: the renamed goal_final_run_… is updated in .config/nextest.toml. The merged and deleted tests (multi_day_checked_goal_achieves_after_forty_runs_and_real_process_kills, a_shell_timeout_names_its_limit_and_how_to_raise_it, shell_timeout_kills_the_whole_process_group) were not named in .config/nextest.toml, .config/platform-tests/*.txt, .config/quarantine.toml, .github or docs (checked with grep). The real-process regex still matches the merged timeout test. goal_driver_soak is now #[cfg(unix)] as a module, because its only test needs a real sh check. It was never in a Windows platform list.

Deleted or merged tests:

  • multi_day_checked_goal_achieves_after_forty_runs_and_real_process_kills: merged into multi_day_driver_survives_real_process_kills_waits_and_outages, which now covers the checked-goal achievement and then the deadline exhaustion of a replacement goal.
  • a_shell_timeout_names_its_limit_and_how_to_raise_it and shell_timeout_kills_the_whole_process_group: merged into shell_timeout_kills_the_whole_process_group_and_names_its_limit. Both ran the same 1 s timeout, and the merged test has both sets of assertions.
  • Rows removed from end-to-end matrices: the input_tokens, output_tokens, cost and tokens_unknown rows in budgeted_read_children_…, and the InputTokens, OutputTokens, Cost and TokensUnknown rows in audit_overspend_…. They are now unit rows in runtime::budget::tests::{a_settled_child_spends_each_bound_or_makes_it_unknown, an_overspending_or_unmeasured_child_exceeds_its_parent}.

Known impact

  • D9 is partly done. The FEED_CAPACITY, EVENT_JOURNAL_ROWS, MAX_SESSION_SPILL_BYTES, MAX_SESSION_FILES and history-scan-budget tests run 0.4–1.2 s each locally. Making them injectable means threading a store-wide option through append_event and the tool-call writers, which every write calls. That is more production surface than about 3 s of local test time justifies, so I left them.
  • Not in scope but still slow: goal_check_process_timeout_and_binary_output_stay_bounded (2 s, a real 2 s check deadline, A6) and deadlines::duration_waits_for_blocking_attachment_guidance_and_skill_cleanup (2.4 s). I listed them as follow-ups.
  • D6 still takes 3 s: the real 3 s timeout runs once, alongside the cancel cases.
  • D5 uses 2 s, not 300–500 ms. Shorter limits fail on a loaded core (numbers above).
  • Production behavior is unchanged. Runtime gains a tool_calls_per_slice field that equals MAX_TOOL_CALLS_PER_SLICE outside tests. Store::open keeps its 1.5 s wait.

lg2m added 22 commits November 1, 2026 07:10
With an active goal the scheduler queues a goal-origin run as soon as the
goal is set. Under load it was claimed before the fixture's prompt, so the
report counted the prompt's tool events (zero) while the goal run did the
work. The fixture now follows the queued goal run, with a per-run turn cap
that fits the scripted workload.
One checked goal now covers the real kills, waits, outages, interleaved
prompts, achievement through the check, and then a replacement goal that
runs out its deadline, which the unchecked soak used to prove.
The perf run keeps its 560 paced 1 KiB chunks. The test streams 8 KiB
chunks with no pause, which still commits over 512 events, the gate it
checks. The captured-output timeout test waits 100 ms instead of 1 s.
The in-run compaction scripts spawned about 640 shells only to produce
6 KB results. A test tool now returns the same stored bytes (the bounded
2,051-byte shell result), so every test compacts exactly as many times as
before. The verbatim-goal test runs 30 turns instead of 72, which still
compacts five times per row.
A 5 s limit made each case wait 5 s. On one loaded core the run needs
about 520 ms to reach the hung summarizer (22 ms unloaded), so 500 ms
failed under stress while 2 s passed 40 of 40.
Each run reads three 90 KiB notes instead of one, so the window-less
session crosses the point where stale reads must be shed after about 40
runs instead of 140. The assertions are unchanged.
The first page is already covered by
ab3_scan_cap_continuation_does_not_claim_an_exact_remainder; starting at
line 40,000 still pages seven times into the terminal marker instead of
140 quadratic rescans.
The yield and timeout tests waited a real second per command. They now
wait for the command's first output (or its pid report), then pause and
advance the clock, as running_build_survives_clock_advance does. The
timeout message test and the process-group timeout test ran the same
1 s timeout; they are one test now.
Store::open keeps the 1.5 s ownership wait; the two busy-store tests
open through an internal variant with a 50 ms wait and still assert the
refusal waited at least that long.
The test ran 64 shell turns to show a cd-prefixed read never triggers a
stall report. That follows from the call counting as progress, so it now
runs the command once and checks the receipt is work and is_progress is
true. The stall counter's reset is unit-tested in runtime/progress.rs,
and ab1_verified_exec_reads_report_on_request_sixty_five keeps the
end-to-end 64-call run.
The final-slot rules depend on the last and next-to-last runs, not on
there being ten. The test passes at both RUNS = 10 and RUNS = 3.
…e permission matrix

The close drain is guarded by the draining flag under the lifecycle
lock, so one pass covers it; 30 stress iterations pass. The permission
selection matrix creates a fresh stored session per row in one store
instead of opening 16 stores.
Each request built a reqwest client with platform TLS roots. The client
is built once per test thread now, so command_routes_match_the_protocol_table
runs in 27 ms instead of 0.77 s here (2.9 s on CI).
with_endpoint is test-only and built a rustls client with platform roots
per call; the header-rejection tests only reject headers. The effort
matrix compiled 21 providers with a new compiler each; it reuses one per
thread now.
…window

The test filled nearly 4 MiB of history to reach the storage backstop.
A 128 Ki-token window compacts at about 0.5 MiB and still leaves the
16,384-token cap uncapped by the summarizer's window/8 rule.
…atrix

The 15-row matrix opened a store per row. The policy authority is the
only per-runtime input, so one runtime with each authority serves every
row, each in its own workspace and session.
child_budget and exceeded now carry every limit family as unit rows.
The end-to-end delegation tests keep one known-spend and one unknown-spend
row each, and the nested receipt test corrupts and restores one store
instead of building three.
A test-only tool_calls_per_slice on Runtime (carried through the agent
profile into the compiled plan) replaces MAX_TOOL_CALLS_PER_SLICE in the
checkpoint test; production builds keep the constant. The full 256-call
continuation stays end to end, and the empty-checkpoint billing test now
checks the exact cost instead of a lower bound.
@lg2m lg2m added the ci:full label Nov 1, 2026
@lg2m

lg2m commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T17:28:23.353562Z e520425 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: e5204251a8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lg2m
lg2m added this pull request to stack #526 November 1, 2026 20:03
@lg2m
lg2m merged commit cf07b60 into main Nov 1, 2026
34 of 40 checks passed
@lg2m
lg2m deleted the perf/fast-tests branch November 1, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant