Skip to content

state_exec_groups_test: give the oracle's pumps no wall-clock budget - #1418

Merged
transfix merged 1 commit into
masterfrom
fix/groups-tests-steps-only
Nov 22, 2026
Merged

transfix merged 1 commit into
masterfrom
fix/groups-tests-steps-only

Conversation

@transfix

Copy link
Copy Markdown
Owner

Test-only. Groups.GR01_EveryGroupEqualsItsSoloRun and Groups.DT02_ThreadsZeroEqualsBareSchedulers failed about once each at CVC_EXEC_SLICE_STEPS=256 on a heavily loaded box. The tests gave their pumps a wall-clock budget by accident, and Stage S did what it is designed to do with one. This PR removes the accidental budget, so the pumps run on steps alone, as the solo runs they are compared with do.

The flake predates the threaded S2a work (draft #1404). It reproduces on master, and nothing in S2a is involved.

Cause

  • Stage S cuts a run after state_exec.slice_seconds (1 ms by default) whenever the run loop has any time budget (async_scheduler.cpp continue_run; the budget is built in run_loop for any max_time, +inf included).
  • Pool side (GR01, and DT02's group side). pump_pooled and check_against_solo's first frame passed the deadline now + 1h. The pool's pump_entry turns that into a budget of about 3600 s. That budget is finite, so exec_group::pump passes it on, and the runs are timed.
  • DT02's bare side. bare_world::pump passed kNoTimeLimit (+inf) to sync_run_steps as a present optional, so those runs were timed too. exec_group::pump maps a non-finite budget to nullopt, and the helper's comment says it pumps "as exec_group::pump pumps".
  • GR01's solo side. The solo runs call exec_group::pump(steps_only(97)) directly. They are untimed and never cut.

Under load, a thread descheduled mid-run passes 1 ms on its next clock check and ends the run early, which reorders a group's processes:

Change (src/cvc/tests/state_exec_groups_test.cpp)

  • A new kNoDeadline = clock_type::time_point::max() replaces now + 1h in pump_pooled, in check_against_solo's first frame and in GR12's first frame. seconds_left reads max() as infinite, so exec_group::pump gives the scheduler no budget. This covers GR01, GR02, GR03, GR12 and DT02's group side. The pool's waits already handle a max() deadline: they wait in slices of at most 1 s.
  • bare_world::pump maps a non-finite seconds to nullopt, as exec_group::pump does.

Nothing outside the test file changes. The file's other now + 1h deadlines (GR04, GR09, OC01, GL01, GL02, PA01, GR10, GR11) are left alone, because those tests do not compare a group's process order with an oracle.

Evidence (Windows, MSVC Release, built from this branch's base d473c10)

To stand in for load without loading the box, a temporary test-only probe set state_exec.slice_seconds in each pool_app's tree to a few microseconds. With a slice that short, runs are cut at points that depend on timing, as descheduling does. The probe is not in this PR. All runs used CVC_EXEC_SLICE_STEPS=256.

Run Without the fix With the fix
DT02, group side only, slice 2e-5 FAIL: all 8 groups (#6 waiting; #11/#12 swapped) pass, 5 of 5
DT02, group side only, slice 5e-6 FAIL: groups 0 and 4 (#11/#12 swapped) pass, 5 of 5
DT02, both sides, slice 2e-5 FAIL: every bare world never ended; groups 2, 4, 7 differ pass, 5 of 5
DT02, both sides, slice 5e-6 (not run) pass, 5 of 5
GR01, sanitizer scale (2 and 8 groups, threads 1 and 4), slice 5e-6 FAIL: 6 groups differ pass, 5 of 5
GR01, sanitizer scale, slice 2e-5 FAIL: every frame loop hit 200000 frames, 12 groups never ended pass, 5 of 5
GR01 (full scale: 2/8/32 groups, threads 1-16) + GR02 + GR03 + GR12 + DT02, slice 5e-6 and 2e-5 (not run) pass, 2 of 2 each

With the probe removed, the whole state_exec_groups_test (28 tests) passes 6 of 6 times at the default slice steps and 6 of 6 at CVC_EXEC_SLICE_STEPS=256. clang-format 19 is clean.

Not verified here: the original flake needs real load to show, so this PR can't show it going away under load. The probe shows the mechanism and shows that the fix removes it.

GR01 and DT02 compare a group's record (each process's status, steps and
outcome) with a steps-only run of the same programs. Under load they
failed about once each at CVC_EXEC_SLICE_STEPS=256, because the pumps had
a time budget nobody meant them to have:

- pump_pooled and check_against_solo's first frame passed the deadline
  now + 1 h. The pool turns that into a budget of about 3600 s, and with
  any time budget Stage S cuts a run at state_exec.slice_seconds (1 ms).
- bare_world::pump passed kNoTimeLimit (+inf) to sync_run_steps as a
  present optional, which also counts as a budget. exec_group::pump maps
  a non-finite budget to none.

A thread descheduled mid-run then ends its run early. That reorders a
group's processes: a broadcast receiver misses its message and waits
forever, or the fork and spawn children swap pids. The solo runs go
through exec_group::pump with no budget and are never cut, so the
records differ.

The pool's pumps now pass time_point::max() (kNoDeadline), which
seconds_left reads as infinite, and bare_world::pump maps a non-finite
budget to nullopt as exec_group::pump does. GR12's first frame gets the
same deadline. GR02 and GR03 share the helpers. Stage S is unchanged.
@transfix
transfix merged commit aa158cc into master Nov 22, 2026
29 checks passed
@transfix
transfix deleted the fix/groups-tests-steps-only branch November 22, 2026 08:17
transfix added a commit that referenced this pull request Nov 22, 2026
…clock-rate

JX2 deleted .github/scripts/pin-wasm-pre-jx1.sh, so this branch's numpy pin goes with it.
transfix added a commit that referenced this pull request Nov 22, 2026
Brings in master through aa158cc, among it #1395 (the pool's short-changed rule)
and #1418 (state_exec_groups_test gives the oracle's pumps no wall-clock budget).

Conflicts:

- exec_group.h, pump_result: both sides added fields. Kept master's `runnable`
  and S2a's next_deadline / deadline_precise / best_runnable / awaiting_frame,
  with one doc comment covering both.
- exec_group.cpp, exec_group::pump: `runnable` is read from the scheduler
  (has_runnable(), O(1)), not from S2a's run report. The report is recomputed
  only while a wake notifier is installed, and a fork-join group has none, so
  left.runnable would be stale there, and #1395's short-changed rule reads
  pump_result::runnable in fork-join pump_entry. The other four fields still
  come from the report.
- exec_pool.h, pool_stats: master's short_changed goes after effective_threads,
  before S2a's continuous-mode counters.
- docs/STATE_EXEC_THREADED.md: the pump_result and pool_stats sketches list
  both sides' fields.
- ci.yml: both sides kept. The clang leg's cxx_tests lists
  state_exec_coordinator_test and state_exec_stackless_evaluator_test; the
  env keeps SAN_REQUIRED_S2A and SAN_REQUIRED_NET, and SAN_REQUIRED names both.

exec_pool.cpp merged without conflict: #1395's half_span, pumped::short_changed,
the pump_entry rule and finish_group's skipped stamp sit beside S2a's
give_long_step_default.
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.

1 participant