Skip to content

exec_pool: a group the deadline cuts short goes first next call - #1395

Merged
transfix merged 1 commit into
masterfrom
tfx/agitated-clarke-d9fa76
Nov 20, 2026
Merged

transfix merged 1 commit into
masterfrom
tfx/agitated-clarke-d9fa76

Conversation

@transfix

Copy link
Copy Markdown
Owner

Problem

exec_pool::pump_all counted a group as skipped, which sends it first next call, only when the group started after the deadline. If a group queues behind one that takes just under the frame (app::exec_pump_frame: 100 ms deadline), it starts every frame with a few ms left. It is never skipped and never goes first, so every frame it gets only that last sliver. The rule that "with k of them that each fill a frame, each starts at least once in k frames" didn't cover this case.

This is what fails state_exec_bench_smoke's mt.ariadne_docs point on a slow build: t=0 docs=2 frame=heavy ... FAIL: bench.ari.d1 ticked 0 times in 4 frames. CI hit it on package-linux / libcvc-debug while landing #1378. The bug was already on master, not caused by #1378.

Fix

A pump is short-changed when all of these hold:

  • it started with less than half the call left (from pump_all's entry to its deadline)
  • the deadline ended it: a process was still runnable (new pump_result::runnable), the step budget wasn't used up, and the deadline, not the group's own seconds budget, set the time limit

finish_group stamps such a group as skipped, so it goes first next call:

  • at threads 0
  • for host-affinity groups with workers
  • ahead of the LPT order in the threaded list (the threaded path had the same gap)

It is counted in the new pool_stats::short_changed.

A group that started with half the call or more left is never short-changed, so k groups that each fill a frame still take turns. host_first's N1 rule and deterministic mode are unchanged.

Tests

  • New ExecPool.AGroupTheDeadlineCutsShortGoesFirstNextTime runs at threads 0, at threads 2 with host affinity, and at threads 2 on the LPT list. One group's test hook spins until a quarter of the call is left, then the other group's endless loop is cut by the deadline. The test checks that the cut group goes first next call. With the fix turned off, it fails in all three configurations.
    • The only timing assumption is 75 ms of slack before the deadline. If that slack is missed, the group is skipped instead of cut and still goes first, so the order check holds either way.
  • Windows/MSVC Release:
    • exec_pool_test: 38 passed
    • state_exec_scheduler_test: 200 passed
    • state_exec_groups_test: 28 passed
    • ariadne_runtime_test: 341 passed
    • state_exec_locks_test without Stress: 209 passed, including all 14 LocksReview cases. LocksThreads.LT03b_PostRacesDestruction ran out of its 90 s budget: about 200 of 10000 runs. That test is about yield throughput and doesn't touch exec_pool or exec_group. The box was running about 27 compiler processes from other builds at the time. Not checked against master.
    • state_exec_bench --smoke: passes, all mt.ariadne_docs points ok.
  • Slow-build repro (kFrame{50000000, 0.1}, heavy tick 48000 iterations), not committed: t=0 docs=2 frame=heavy passed 3/3 with the fix. Under the same load it also passed with the fix turned off, because the ticks ran past 100 ms and the existing skipped rule covered them. So the new unit test is what proves the fix, not this repro.

Docs: docs/STATE_EXEC_THREADED.md (Stage 1 order, per-frame deadline, struct listings) and the comments in exec_pool.h.

A group counted as skipped only when it started past the deadline. One
queued behind a group that takes just under the frame (exec_pump_frame:
100 ms deadline) started every frame with a few ms left, was never
skipped and never went first, so it got only that sliver every frame:
state_exec_bench's mt.ariadne_docs, docs=2 t=0, on a slow build ("ticked
0 times in 4 frames", seen on package-linux / libcvc-debug).

A pump is now short-changed when it started with less than half the
call left (pump_all's entry to its deadline), and the deadline ended it:
a process still runnable (pump_result::runnable, new), steps to spare,
and the deadline, not the group's own seconds budget, was the limit.
finish_group stamps it as skipped, so it goes first next call at threads
0, for host-affinity groups, and ahead of the LPT order in the threaded
list. It counts in pool_stats::short_changed. A group started with half
the call or more is never short-changed, so k groups that each fill a
frame still take turns; host_first's N1 rule and deterministic mode are
unchanged.

ExecPool.AGroupTheDeadlineCutsShortGoesFirstNextTime reproduces it at
threads 0, threads 2 host, and threads 2 LPT; it fails without the fix.
@transfix
transfix merged commit e40176e into master Nov 20, 2026
29 checks passed
@transfix
transfix deleted the tfx/agitated-clarke-d9fa76 branch November 20, 2026 13:35
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