Skip to content

state_exec: threaded execution's S2b, the router and process control across groups - #1524

Merged
transfix merged 61 commits into
masterfrom
perf/threaded-s2b
Nov 25, 2026
Merged

transfix merged 61 commits into
masterfrom
perf/threaded-s2b

Conversation

@transfix

@transfix transfix commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Threaded execution's S2b (state-exec-perf/threaded-impl/S2.md, section 2's S2b table): the router and process control across exec groups. Draft: the skeptic pass and the A/B are still to come.

What it does

  • Channel homes and the router (exec_router.h, new; td 4.6). Each resolved channel key has one home group: the group that registered the longest prefix covering it, else group 0. Ariadne's document groups register their prefix, and pycvc's pooled Execs register their chroot. The router is on only while a group other than group 0 has a prefix (RT-1: with one group it is never consulted). A group that registered no prefix (a Stage 1 host's own group) keeps its own keys local, router or not.
  • One ordered ingress (S2b.1): messages, commands and router entries share one queue applied in post order; settled calls come after it. S0.7's throw rule is kept. The protocol (send, subscribe, unsubscribe, deliver by pid and recv_seq, requeue, taken, adopt), broadcast tracking, the ingress cap (state_exec.groups.ingress_cap, 65536; # keys never capped), and a group's teardown, which forwards what it holds to the keys' new homes before it unregisters.
  • The pid directory and published info (S2b.2, S2b.3; S2-Q9). The published process row carries scope alone, with no chroot or owner root (Joe, 2026-11-23), plus name. Rows are rebuilt only when the process table changes.
  • Process control across groups (S2b.5; S2-Q7, S2-Q8). kill, pause and resume reach a pid of the caller's owner in another group (#t for "requested"). An owned process sees and controls only its owner's processes locally too: ps, inspect, kill, pause and resume. exec_pool::post_message, post_control, kill_owner (acknowledged, fork-join and continuous) and info.
  • Ariadne (S2b.6; S2-Q16). S1-Q6's channel rules are lifted, so a document with a / channel can be isolated. Group 0 is pumped for a pending router entry, and a host post to group 0 on a document's channel is routed.
  • pycvc (S2b.7): pooled Exec owner tags pycvc:<prefix>.<i>, one prefix per live pool, ExecPool.info(pid) and ExecPool.prefix, and run_all drains group 0.
  • Tests (S2b.8): state_exec_router_test (MS-1..MS-10, MS-12 against a router-off group, PL-6..PL-8, KO-3, RT-1, DT-3, DT-4, and the implementers' cases) and state_exec_stress_test (ST-1, ST-2). The router protocol's model is tools/locks_model/router.py (CTest state_exec_router_model_test, and a deep lane in locks-deep.yml).
  • Bench, CI, docs (S2b.9): mt.cross_group_msg and its wake-latency gate, SAN_REQUIRED_S2B, a nightly ST-1/ST-2 lane, and the docs: td 4.5, 4.6, 4.11, 4.12, 4.17, 5, 8.4 and 9.2, plus STATE_EXEC_LOCKS 7.2/7.5, ARIADNE, APP_API, the developer guide, BENCH, TESTING and pycvc's README.

Always-on changes (td 5)

  • One ordered ingress: order across messages and commands is now post order, and commands apply before settled calls. AsyncPostControl.HasPendingControlCountsCommandsOnly is the one test whose outcome changes; it is updated.
  • Owner filtering of local control for owned processes. processes.ari now lists only its own Runtime's processes in group 0, which is Q5's intent.
  • post_message returns bool and counts against the ingress cap.

Review and verification so far

  • The frozen text (S2b.0) was amended twice. First from the router model's eleven findings (S2b.0a), then from the R2 reviews: R2a found 5 majors, R2b 3 majors (S2b.R2). Every finding's fix is in, each with a test that fails without it. The model finds only the documented gaps.
  • Windows MSVC Release at 2a07796, default and CVC_EXEC_SLICE_STEPS=256 identical:
    • router 66, stress 2, exec_pool 88, groups 33, async 143, intrinsics 181, async_calls 83, priority 40, scheduler 200;
    • exceptions 26, data_steps 54, hazards 12, integration 105, stackless 89, app 123;
    • ariadne_host 54, ariadne_runtime 361, coordinator 76, locks 221.
  • CTest: bench smoke, tool test and gates (the one:cross steps pin included), both models, pycvc 11, and the slice256 and threads_auto entries.
  • Stress: ST-1 for 3 minutes (303 seeds) and ST-2 over 30 fuzz seeds, with nothing lost, duplicated, misrouted or stranded.
  • Still to come: the skeptic pass, CI, and the quiet-window A/B (section 6's gates).

…s groups)

S2b.0 of threaded execution's S2b (S2.md section 2): the declarations the router's and process
control's implementers code against, with stubs that keep today's behaviour.

- exec_router.h (new): group_ref, a handle the router and directory name a group by, whose close
  waits for posts in progress, so no post reaches a destroyed scheduler (built); the router entries
  (send, subscribe, unsubscribe, deliver, requeue, taken); exec_directory, the pid directory
  (stub); exec_router, channel homes by longest registered prefix (registration and home_of built;
  the host entry points stubs). Its header comment carries the rules S2b.0 freezes: the homes, when
  the router is on, the ordered ingress and the throw rule, the protocol and broadcast tracking,
  the ingress cap, teardown and rehoming, host posts, the owner rule, the directory's write points,
  published info and the lock order.
- scheduler_base.h: process_info::owner; published_process, the S2-Q9 row (with name and scope,
  which local ps rows carry: scope alone, no chroot or owner root, as Joe chose); control_cmd's
  kill_owner kind; control_as, the owner rule's local half; the messaging virtuals' routing note.
- async_scheduler: set_router, route_self, leave_router, post_route, deliver_to, the ingress cap and
  its counters, has_pending_ingress, published info (published, published_info, published_rows),
  control_as; post_message returns bool. process::recv_seq; process_table::generation.
- exec_pool: exec_pool(opts, app), post_message, post_control, kill_owner (stub), info.
  exec_group: channel_prefixes registered, route(). app: exec_router().
- Wired: group 0 registers the default home; a group registers its channel prefixes and leaves the
  router in its teardown after detach_end, before the kills; a scheduler closes its handle when it
  goes; app::exec_pool() passes the app; both schedulers handle kill_owner (the sync one refuses
  it). state_exec_router_test, with the handle's and the registration's cases.

Frozen for S2b: every rule in exec_router.h's header, the entry kinds, the published row, the
directory's write points, the owner rule and the cap's accounting.
S2b.7 of threaded execution's S2b (S2.md section 2; S2-Q7; section 0, rows 16 and 23).

- A pooled Exec's group is built with owner "pycvc:<prefix>.<i>" and channel_prefixes
  {"<prefix>.<i>"}, its chroot: its programs, and the children they spawn or fork, carry its tag,
  so one pooled Exec controls none of another's processes, and its channels are homed at its own
  group. run_all submits with the tag. A plain Exec keeps "".
- Exec.lock_query's viewer is the owner its programs run as (the tag for a pooled Exec), so it
  still lists its own Exec's holds (S2.md section 8's Exec.lock_query hit).
- pycvc.i: process_info.owner; async_scheduler.post_message returns bool. ExecPool.info(pid): a
  process's published row (exec_pool::info, S2-Q9) as a dict.
- README: the owner tags, that a pooled Exec cannot kill another's processes, the channel homes,
  ExecPool.info, and post_message's bool and cap.
- test_pycvc_exec_pool.py: OW-1 (test_ow01_pooled_execs_have_owners) and
  test_s2b7_post_message_returns_bool. OW-1's owner rows need the directory and the published
  rows (S2b.2, S2b.3, with R's directory writes).
A pooled program's key outside its chroot ("/k") is homed at group 0, the app's exec scheduler
(exec_router.h's homes), which no pooled pump drains, so a send or subscribe posted there would
wait for ever (a /-key exchange within one pooled Exec, local before the router, included).

- ExecPool builds group 0 when it is made, on its thread after the pooled Execs, rather than by
  the first routed key inside a pump on a worker (exec_router::home_of builds it).
- run_all drains group 0 before each round, on its thread under group 0's pump owner, while it has
  posts and no other thread pumps it (an Ariadne frame drains it then); such a post counts as work
  for the next round. Group 0's processes are not stepped. Never from inside one of group 0's own
  steps (run_all called by a host function of it).
- README: the channel homes' drain.
- test_s2b7_a_global_key_meets_across_pooled_execs: a pooled program receives on a /-key what
  another pooled Exec's program sends, and replies on a key under the sender's chroot. Needs the
  router (S2b.4); without it the receiver is killed at its idle limit.
An exhaustive model of the router protocol S2b.0 froze in exec_router.h's
header comment (S2-Q10, S2-Q15; td 4.6, 4.11, 8.4): one key homed at H,
then at group 0 after H's teardown, receiving groups R1 and R2 and a
sender group S, every interleaving of the groups' atomic steps, breadth
first. Properties: no loss, no duplicate, FIFO per (sender group, key) at
the home, nothing stranded or orphaned at quiescence, no stale record or
tracker, no deadlock, one outcome per schedule.

The frozen text has eleven findings, each with an amendment (--amend) and
a finding-* check that runs every amendment but its own; with all of them
only the two documented gaps remain (a requeue's position, a broadcast
whose home dies with copies outstanding). test_router.py runs the quick
suite and checks the explorer (about 25 s); --suite deep is for
locks-deep.yml (36 checks, about 9 minutes, 1.1 GB). README.md's new
section lists the findings, the gaps, the mutations and the sizes.
S2b.6 of threaded execution's S2b (S2.md section 0 rows 21-23, S2-Q16).

- Prefixes (row 23): an isolated document's group is made with channel_prefixes = {its prefix},
  so its constructor registers the document's channels with the app's router. A move retires the
  old group, which lives on until its kernels end: it now leaves the router at the move
  (retire_from_router: leave_router under its token, after the new group registered the prefix),
  so the new group is the home at once and what the old one held for the router goes there.
- Eligibility (S2-Q16): S1-Q6's channel rules are lifted. A document no longer needs a strict
  channels: block free of global: true channels and static / references, since a / channel is
  homed at group 0 and routed. The prefix, oidc (its '#' channel is never routed), writable holes
  leaving the prefix and the affinity rules stay.
- Group 0 never stranded (row 22): the Runtime's drain pumps group 0 while it has pending ingress
  too, not only while it has live processes.
- Routed host posts (row 21): app.h's compute_async and intrinsics.h's resolve_channel_key say a
  post to exec_scheduler() on another group's channel is passed on by the router; ARIADNE.md 2.5
  gives the rules as S2-Q16 leaves them.
- Tests: EL-1 (the lifted cases are eligible now), AMoveLeavesANestedDocumentsStreamAlone (the
  nested document stays in group 0 by a hole; the ingress count becomes a delivery check), and
  AriadneRouter.S2b6_* and AriadneRouterHost.S2b6_* at threads 0, 1 and 2. The global-channel,
  move and host-post cases need the router's routing (S2b.4) and fail on S2b.0's stubs.
The router protocol's model (tools/locks_model/router.py) found eleven problems in S2b.0's frozen
text; exec_router.h's header comment now carries the amended rules.

- Teardown: close the handle first (a refused poster re-resolves and waits while the home is still
  that group), forward to new homes resolved without closed groups (exec_router::new_home_of), in
  the order the group took things: pending messages, remote-waiter records, broadcast trackers
  (the new adopt entry), then queued messages and router entries; unregister last. Forwarded sends
  and host posts are uncapped, and an uncapped send goes past max_pending_messages.
- A deliver that threw before patching, or that a closed receiver refuses, is stale (a requeue, or
  dropped when requeue_if_stale is false); one that threw also resubscribes its wait.
- The next waiter for a requeue is the earliest local waiter, else the earliest record; an
  all-stale tracked broadcast is applied as a requeue; broadcast ids are unique in the app
  (new_broadcast_id), and a forwarded tracker closes the duplicate a dying home could cause.
- Islands: a group that registered no prefix (has_prefix) keeps the keys no other group's prefix
  covers in its own scheduler, router on or off, so a Stage 1 host's groups keep today's messaging.
- app::exec_scheduler_probe(): group 0 if built, for hosts that drain it only while it exists.
- The model's quick suite in CTest (state_exec_router_model_test).
…(S2b.9)

Threaded execution's S2b.9 bench (S2.md section 6; td 6.3): msg-send and msg-recv between
exec_groups on the app's exec_pool through the app's router, against the same programs in one
group. pattern=pingpong (k pairs trading a ping and a pong), fanout (one sender to k receivers,
each on a key of its own, then their k acks) and broadcast (one send on round i's key, which k
receivers wait on). span=cross puts each process in a group whose name is its channel prefix, every
key homed at its receiver's group (the router on; a broadcast's receivers wait on the sender's key,
so each copy is a remote delivery); span=one runs the same programs in one group with no prefix
(the router off, RT-1's fast path, checked by the router's consulted() count). t and pump are
mt.groups'.

The host starts each broadcast round: once every receiver has had the rounds before it and waits
again (read under its group's token), it posts the round's go to the sender's group, after the
receivers' subscribes in that group's ordered ingress, so the send finds every waiter, with no
polling in the programs (their steps stay deterministic).

Each rep checks every program's result, the count of timed receipts and their send times;
extra.ns_per_msg, extra.wake_p50_ns and extra.wake_p99_ns (a send's post to its receiver's step,
the bench's latency method), the router's and the ingress's counters, the pool's. A cross-group
point first sends a probe to another group's key and fails at once when the message does not reach
its home, so against S2b.0's stubs (no routing yet) those points fail loudly instead of waiting out
--timeout.

state_exec_bench.py: GATE_GUARDS judges the wake gate (gate --metric extra.wake_p50_ns --max 50000)
on one pair's pingpong across groups only, and fails a point that timed no receipt as vacuous; the
tool test covers it and the span=one:cross steps pin.
…to one group's

state_exec_bench_gates runs mt.cross_group_msg's smoke points in one group and across groups, in
both pump modes, and pairs them on span with compare --metric steps_total --threshold 0
--fail-on-change: a routed send or receive takes the steps a local one does (S2b.9). Until the
router routes (S2b.1, S2b.4), the cross-group points fail their routing probe and this step fails.
…sanitizer legs

S2b.9's CI half (S2.md section 5), in all three sanitizer legs (gcc TSan, ASan with UBSan,
clang TSan):

- state_exec_router_test and state_exec_stress_test (ST-1's and ST-2's short forms) in
  SAN_CXX_TESTS and the clang leg's cxx_tests.
- SAN_CXX_RUNS_S2B, appended to each leg's cxx_runs: the stress binary runs whole. run.sh takes a
  new --keep-stress-suites in a SAN_CXX_RUNS line, which drops its *Stress* exclusion for that
  binary (its own filter, or all of it), so the short forms run whatever their suites are called.
- mt.cross_group_msg at t=4 k=4 m=20, both pump modes, in SAN_BENCH and the clang leg's bench: 12
  small points.
- SAN_REQUIRED_S2B, appended in the run step as S1A's, S1B's and S2A's are: the router test's
  interface cases and S2.md section 4's named cases (MS-12, PL-6..PL-8, KO-3, RT-1, DT-3, DT-4),
  pycvc's OW-1, and mt.cross_group_msg's cross-group points, with a TODO for the cases still to be
  named (MS-1..MS-10, the implementers' unit tests, Ariadne's, the stress cases).

ci.yml stays CRLF.
…ks-deep

state-exec-stress.yml (new; schedule and workflow_dispatch): state_exec_stress_test's long forms
on Linux, ST-1 with CVC_EXEC_STRESS_MINUTES=10 and ST-2 over 1000 CVC_EXEC_FUZZ seeds
(CVC_EXEC_STRESS_SEEDS=1000), each in a step of its own, in two lanes, gcc's TSan and Release. Each
lane builds as ci.yml's sanitizer legs do (their cvcpkg deps and tools, their configure flags,
without pycvc) and only the stress binary; TSan reads the legs' suppressions file, which stays
empty, and a run fails on a non-zero exit or a sanitizer report. A ref without the test stops after
the checkout. It posts no llm-gate check, as the repository's other scheduled workflows post none.

locks-deep.yml: a router-model job running the router protocol model's deep suite, as the
state-word model's job does, once tools/locks_model/router.py exists (a TODO for its real command
line and time).
tools/locks_model/router.py is merged: the router-model job takes the model's deep suite as its
notes give it (36 checks, about 9 minutes on the lead's box, at most 3.0 million states and 1.1 GB;
45 minutes), and ci.yml's sanitizer comment says the model runs in CTest and in locks-deep.yml.
S2b.2 of threaded execution's S2b (S2.md section 2; td 4.5, S2-Q8): the app's pid directory,
which its router holds (exec_router::directory()).

- exec_directory: 64 shards (pid mod 64), each a mutex and a map pid -> directory_entry (its
  group's handle and its owner). add (a debug build asserts it replaces no live entry), remove,
  find (copied out: nothing is posted under a shard's lock), size, and groups_of(owner): each
  group once, in group id order (group 0, then creation order), pool.kill_owner's targets.
- The writes at execute, fork, restore and reap are R's calls in async_scheduler.cpp (S2b.4).

Tests (state_exec_router_test, C's block): add, find, remove and groups_of over three groups and
every shard; threads sharing the shards; a pid found between its creation and its group's first
publish, and gone at its reap (skipped until R's writes are in).
S2b.3 of threaded execution's S2b (S2.md section 2; td 4.5, S2-Q9): what each scheduler of an
app's routing publishes at the end of its run loops, for readers on other threads.

- process_table::generation() moves at every update() (insert, every status change but ready <->
  running, every priority change and relevel) and at every erase.
- async_scheduler::publish_info (R calls it at run_loop's end, after the run report): the
  summary's atomics every time (the run report's runnable, best_runnable and next deadline while
  a wake notifier is installed, else the table's; the live processes); the rows rebuilt when the
  generation moved, or a lock hold did; otherwise their steps, run seconds and memory refreshed at
  most every 100 ms. A row reads each field as make_info does (scope = process_scope, locks_held
  the absolute keys of the lock mirror's holds, waits_on as waiting_on).
- Lock holds do not reach the table (lock_home is frozen): when the generation did not move, the
  publish compares the holders' mirrors with their rows, and the count of rows showing holds.
- published(), published_info(pid), published_rows() read them from any thread;
  exec_router::info(pid) is the directory's group's published row (exec_pool::info).

Tests: the generation's moves; a row field for field against make_info, the summary and
pool.info; a hold taken and dropped without a wait published; rows rebuilt on generation moves,
counters refreshed at most every 100 ms (by counts against the loop's own time) and still
refreshed with nothing moving (the publish cases skip until R's call is in).
S2b.5 of threaded execution's S2b (S2.md section 2; td 4.5, S2-Q7, S2-Q8): the owner rule and
pool.kill_owner.

- async_scheduler::control_as: the local half from the process table (a caller with an owner
  reaches only its owner's processes); a pid not here, for a caller with a non-empty owner, that
  the directory has in another group with the same owner is posted there (kill, pause, resume) and
  gives #t; anything else #f. exec_router::post_control posts to the directory's group.
- The intrinsics: kill, pause and resume go through control_as with the stepping process's owner
  (else the context's process's, else ""); ps lists, and inspect shows, only that owner's
  processes when it is not "". Unowned callers and hosts are unchanged.
- exec_pool::kill_owner(owner): a kill_owner command with a done to each group of
  groups_of(owner), then the wait for the dones: group 0 and a fork-join group no thread pumps are
  drained inline under their token (an unattached group under its handle and membership, so no
  pump_all takes it meanwhile), a group attached to (or held by) this thread under with_group, the
  rest waited for, servicing this thread's host queue. A group torn down meanwhile ends its wait
  (its destructor refuses the command, KO-3); a failed attached group's processes are killed
  already. Refused (std::logic_error) inside a pump, host body or callback of the pool.
- app::exec_pump_frame pumps group 0 while anything posted to it waits (has_pending_ingress), not
  only while it has live processes (S2.md section 0, row 22). ~app's order checked: nothing posts
  to group 0 after its handle closes.

Tests: the owner rule locally on both schedulers and across two groups and group 0; kill_owner in
fork-join and continuous mode at threads 0, 1 and 2 (a group attached to another thread waited
for), a group torn down while it waits (fork-join and continuous), and its refusal inside a
pump_all.
…-6..PL-8, KO-3, RT-1, DT-3, DT-4)

S2b.8 (S2.md section 4; td 8.3, 8.4, 8.9), at the end of state_exec_router_test.cpp, written
against S2b.0's frozen interface before the implementation. A case drives its groups in an order it
chooses: each step one pump of one group, by hand (a steps-only exec_group::pump; group 0 under its
pump owner) or a pump_all of that group alone (deterministic, or threaded with each pump moved to
another thread), so posts between groups land in a known order. Oracles are outcomes: results,
statuses, where messages are queued (only at their home), the ingress counters, and where the
frozen protocol posts a subscribe, send or deliver (has_pending_ingress). No wall-clock assertion:
a deadline is waited for, never asserted; ceilings only turn a hang into a failure.

- MS-1..MS-4: a send reaches a waiter at its home once, at the home's next drain; a send with no
  waiter queues at the home only; a remote receive subscribes and gets the send once; a broadcast
  reaches three groups, each with its own envelope (changes in one group never reach another).
- MS-5, MS-6: a timed wait expiring, and a waiter killed or reaped, with a delivery in flight: the
  message is queued at the home (requeued 1) and the next receiver gets it, once.
- MS-7: 8 groups x 1000 messages to one key: none lost or duplicated, FIFO per sender, fork-join
  and continuous at threads 1, 2 and 4.
- MS-8: an app-global key from a document group is homed at group 0, and app::exec_pump_frame
  drains a send homed at group 0 when group 0 has no live process (S2.md section 0, row 22).
- MS-9: a '#' key stays in the group that resolves it; the router is not consulted for it.
- MS-10: the ingress cap: msg-send's {status "error", reason "ingress full"}, every host post
  refused (async_scheduler's, the pool's, a forwarded one), ingress_refused counted.
- MS-12: twelve columns (waiter present or absent, a broadcast, a timed receive expiring with a
  message in flight, a waiter killed with a deliver in flight, the pending cap, a chroot-resolved
  key, a hand-built future, broadcasts whose remote copies all go stale or one is taken) in four
  layouts of sender, receiver and home: each equal to the single group's, hand-pumped and in
  deterministic mode.
- PL-6..PL-8, KO-3: post_control's kill lands within one more step of a target being pumped;
  kill, pause and resume across groups of one owner give #t and take effect; another owner's pid
  (or an unowned caller's reach across groups) gives #f, and in group 0 another document's process
  is neither controlled nor seen; kill_owner is acknowledged by every group (fork-join idle, pumped
  elsewhere, continuous) before the host frees the contexts; a group destroyed while kill_owner
  waits on it ends the wait.
- RT-1: with one group (and a plain group beside it) the router is never consulted, and the
  messaging programs' step counts equal a bare scheduler's.
- DT-3, DT-4: MS-12 in deterministic mode equals threaded mode; deterministic continuous runs of 8
  groups exchanging messages repeat their delivery order.

On S2b.0's stubs MS-9 and RT-1 pass; the rest fail for the missing routing, directory and control.
S2b.8 (S2.md section 4; td 8.8): state_exec_stress_test, suite RandomPrograms (no "Stress" in a
name, so the PR lanes and the sanitizer legs run its short form). One run is an app with a pool
(threads 1, 2 or 4; fork-join or continuous, by seed) and 16 groups (8 in Debug, 6 under a
sanitizer), each the home of a unicast and a broadcast key, plus group 0's global keys: receivers
(untimed and timed) and senders in random groups, victims, and between passes the host's kills
(direct and post_control), kills of receivers while they wait, pauses and resumes, killer programs
across groups, and group churn (a group's next version with new keys; the old keys rehome to group
0). At the end every receiver is killed once it waits and a drainer at each key's home takes what
is queued. Checked: every message received (by its key's receivers, once each, by one receiver of a
unicast key) or drained once, never both, never neither; nothing left queued; no phantom; no hang.

ST-1 runs seeds 1-6 in CTest, and for CVC_EXEC_STRESS_MINUTES minutes when set; ST-2 runs seeds with
CVC_EXEC_FUZZ set (3 in CTest, CVC_EXEC_STRESS_SEEDS when set). CVC_EXEC_STRESS_LOCAL=1 checks the
generator itself with every message kept in its home group and no churn, which needs no router.

Its CMake target is the lead's to add (src/cvc/tests/CMakeLists.txt).
S2b.1 and S2b.4 of threaded execution's S2b (S2.md section 2; exec_router.h's rules). One commit:
the routing branch points and the ingress share async_scheduler.cpp's messaging functions, and a
split would leave a commit that does not build.

S2b.1, one ordered ingress (always on, every async scheduler):
- post_message's messages, post_control's commands and router entries share one queue, applied in
  post order; the lock port's posts before it in a drain, the settled calls after it (S2-Q10).
- The throw rule (S0.7): the entry that threw is not put back and is counted (throw_dropped); a
  command that threw is refused (control_refused) unless its call returned; a deliver that threw
  before patching its frame goes back to its home as a requeue; the rest goes back to the front.
- The destructor: commands refused (done(false), counted), plain messages dropped and counted
  (destroy_dropped), router entries bounced to their homes (a deliver as a requeue; the others to
  home_of(key) once the handle is closed), or dropped and counted where no home takes them.
- The cap: host messages and sends not uncapped count in the queue; past ingress_cap() they are
  refused (ingress_refused). state_exec.groups.ingress_cap through the settings cache, unless
  set_ingress_cap was called; written and read under the ingress mutex.
- recv_seq moves at every receive park; deliver_to(pid, seq, key, msg). A full pending FIFO's drops
  are counted (pending_dropped); the FIFO is a deque, a requeue at its front past the cap.
- C's call sites: the directory's add at execute, fork and restore, its remove at reap (a reap
  after its step included, and the destructor's table), publish_info at every run loop's end.

S2b.4, channel homes:
- The branch points (deliver_to_receivers, receive_message(_until), pop_pending_message,
  pending_message_count) check router_ && router_->active(), then the key's home through a capped
  cache checked against the router's epoch; never for a '#' key. Drain applies through a local
  path (deliver_home), so routing never recurses. RT-1: with one group, or no prefix, nothing
  consults the router.
- The protocol at both ends: send, subscribe, unsubscribe (a timed-out, killed, reaped or locally
  answered remote wait), deliver by pid and seq with one envelope copy per receiving group (lists
  and dicts copied, B9/B12), requeue (the next waiter, else the FIFO's front), taken; broadcast
  tracking at the home (a local waiter took it: stale copies dropped; one remote waiter: untracked;
  k >= 2: tracked, queued once if every copy comes back stale, a stale copy of a taken one
  dropped). Remote waiters in subscription order; a record past its deadline skipped; the router's
  remote-waiter count kept as records come and go.
- A post through a closed handle resolves the home again and posts there (a requeue's broadcast id
  cleared, a taken dropped). Host posts on a key homed elsewhere forward a send to the home (its
  cap); exec_router::post_message posts to the home, group 0's post_message while the router is off.
- leave_router: the keys it homes found first (none while the router is off), unregister, close,
  then its pending messages (uncapped sends, FIFO order, keys sorted), its remote-waiter records
  (subscribes with the same seq) and its queued router entries go to the keys' new homes.
- msg-send gives {status "error", path, reason "ingress full"} when the home refused it.
- CVC_EXEC_FUZZ yields at the router's posts (the scheduler's and the router's own).

Tests: R's unit tests in state_exec_router_test.cpp (RouterR.*): the order across kinds, the throw
rule, the destructor's bounce, the cap and its counter, deliver_to's staleness, a requeue at the
front, broadcast tracking, rehoming at teardown, the cache and the epoch, a closed home resolved
again, no consultation without a prefix, and a remote receiver on a continuous pool.
# Conflicts:
#	src/cvc/state/state_exec/exec_router.cpp
…robe

The lead's follow-up to the group 0 drain, on S2b.0a (app::exec_scheduler_probe).

- ExecPool no longer builds group 0. run_all looks it up through app::exec_scheduler_probe(), which
  never builds it (the first key homed there does), and keeps it once found: it lives as long as
  the app.
- The drain takes group 0's pump owner in a try instead of checking pumped_elsewhere() first: on
  kPumpedElsewhereError (another thread pumps it: an Ariadne frame, kill_owner, another pool's
  batch) this round skips the drain, which that thread's pump does. Any other exception still
  propagates.
- Exec::run_batch takes the app instead of a group 0 pointer. README and the headers say so.
… a held group 0

pycvc's ExecPool.run_all now drains group 0 on its own thread, under group 0's pump owner, and
pool.kill_owner drains it inline, so another thread may hold group 0's token when a frame comes.
app::exec_pump_frame takes group 0's token in a try before it reads group 0's liveness (that read
would race the other thread's drain) and again in its pump; held by another thread at either
point, group 0 is skipped this frame, never a throw, and pumped at the next frame's host_first.

Test: GroupZeroDriver.AFrameSkipsGroupZeroWhileAnotherThreadHoldsIt (a test thread holds group 0's
pump owner across one exec_pump_frame, with no frame group and with one: no throw, group 0 not
pumped; released, the next frame runs its program).
- MS-7b: a sender's FIFO holds across its home's teardown: messages queued at H, applied, and still
  in H's ingress when H goes, then sent to the key's new home (group 0), all reach a receiver in
  the sender's order; a wait recorded at H is forwarded and served at group 0.
- MS-8: the sending document group has a prefix (an app-global key is homed at group 0 for such a
  group), and a group with no prefix is an island: with the router on its own key stays its own,
  while its send on another group's key is routed there.
- MS-12: two columns for a tracked broadcast whose home is torn down with its copies out (its
  tracker forwarded as adopt): one copy taken and one stale is never delivered twice; all stale is
  queued once at the new home. A cell's world now includes group 0, settled with the groups, and
  "queued at the home" reads the key's current home.
- ST-1, ST-2: no duplicate is allowed for a key whose home was torn down either (the gap the first
  version allowed for broadcasts is closed).
…UIRED_S2B

state_exec_stress_test (ST-1, ST-2) is built and discovered, with a 900 s timeout for its short form; SAN_REQUIRED_S2B gains the router test's MS-1..MS-10 cases, the teardown-forward interface case and the stress test's two cases.
The router's ends of the protocol follow exec_router.h's header as amended from the router model
(S2b.0a, tools/locks_model/router.py; S2b0a-amendments.md).

- Teardown (leave_router): close the handle first; forward to exec_router::new_home_of, in the
  order the group took things: the pending messages of the keys it homed (uncapped sends, FIFO
  order), its remote-waiter records (subscribes, same seq), its trackers (adopt), then its queued
  host posts of keys it homed (uncapped sends) and router entries, in queue order (a send
  uncapped; a deliver stale: a requeue to its home, or dropped per requeue_if_stale; the rest as
  they are); a message of a key it did not home dies with it, counted; unregister last. An island
  homes nothing.
- A post a closed home refuses resolves the home again with home_of, yielding while that is still
  the closed group (its teardown forwards, then unregisters), so it arrives after the forward;
  broadcast ids are kept (unique in the app: exec_router::new_broadcast_id), and a taken goes on.
  A closed group 0 (~app) is never unregistered: no home then.
- An uncapped send that finds no waiter joins the FIFO past max_pending_messages.
- A deliver that threw before patching: stale (per requeue_if_stale) plus a subscribe for its wait
  with the same seq; counted in throw_dropped. A deliver a closed receiver refuses is stale at once
  at the home.
- A requeue goes to one waiter: the earliest local waiter (recv_seq now comes from one count per
  scheduler, so the lowest is the earliest park), else the earliest record whose deadline has not
  passed; else the front of the FIFO. An all-stale tracked broadcast is applied as a requeue. adopt
  entries make the new home track a forwarded broadcast.
- Islands: a scheduler whose group registered no prefix (exec_router::has_prefix) keeps the keys
  no other group's prefix covers, in its messaging and its host posts, router on or off.
- A host post to a group whose handle closed goes on as a send (the poster waits for the forward).

Tests (RouterR.*): the teardown's forward order (pending, then queued sends and host posts, past
group 0's FIFO cap), an adopted tracker (no second delivery), a requeue to the earliest waiter
only (local in park order, else the earliest record), a deliver a closed receiver refuses, an
uncapped send past the FIFO's cap, and islands keeping their keys with the router on.
A's retire_from_router (96b58f9) calls leave_router itself, under the old group's token, after
the new group registered the same prefix and after the old group's processes were killed and
reaped; ~exec_group calls it again. leave_router needs no lock port closed and finds nothing the
second time. When another thread held the token, the move only unregistered the old group: its
teardown now still forwards the messages it held for the prefix, to the group whose prefix covers
their keys now (an island's own keys still die with it, counted). With the router off, a teardown
asks the router nothing (RT-1).

Test: RouterR.LeavingTheRouterTwiceAndAfterAMove (a move's leave after the kills and reaps
forwards to the new group; a second leave and the teardown's send nothing; an unregister-only
move's teardown forwards to the new group: failed before this commit).
… not to group 0's ""

leave_router's forward passed `router_->new_home_of(e.key)` and `std::move(e)` as arguments of one
call: their order is unspecified, and MSVC moved the entry first, so the home was resolved for an
empty key (group 0) and the forwarded message landed there under "". It depended on the build's
inlining: RouterR.LeavingTheRouterTwiceAndAfterAMove and AriadneRouter.S2b6_AMovedDocumentKeeps-
ReceivingOnItsChannels (its 90 s ceiling) failed with it. The home is resolved first now.
…ess in post_control's comment

R's requests after S2b.4: exec_router::prefix_home_of answers an island's lookup (a covering prefix, else its own) without building group 0, in the scheduler's cache and in post_message; post_control's comment gives the ordered ingress (S2b.1); HasPendingControlCountsCommandsOnly expects the query applied before the later message; C's directory case no longer requires a kill of a child forked before its parent's first step, which ends at once.
STATE_EXEC_THREADED.md as S2b built it (S2.md S2b.9), checked against exec_router.h's header
comment (S2b.0, S2b.0a, ae66f19) and the code at 7618b8b:
- status line: S2b built in perf/threaded-s2b; S2c, Stages 3, 4 and M not.
- 4.5: the pid directory and its write points; pool.post_control; the owner rule, locally and
  across groups (#t "requested", owner "" with no rights across groups), the owners Ariadne and
  pycvc give; published info (the summary, the row with scope alone and name, when rows are
  rebuilt, the 100 ms refresh, pool.info); pool.kill_owner in both modes, its inline drains,
  waits and refusals; send-signal dropped; set-priority, merged ps and inspect left to S2c.
- 4.6: Stage 1's channel rules gone (S2-Q16); Stage 2 as built: handles, homes and islands, when
  the router is on, the cache, the ordered ingress and the throw rule, the protocol with taken and
  adopt, broadcast tracking, the cap and uncapped sends, teardown's order, host posts, group 0's
  drivers, the fuzz points, what is kept and the documented gaps (the requeue position, islands
  once a prefix's home goes, a document moving into a group).
- 4.11: what is kept across groups now. 4.12: exec_group's handle and prefixes, exec_pool's S2b
  API, app::exec_router() and exec_scheduler_probe(), exec_pump_frame's group 0 gate,
  async_scheduler's S2b members, post_control's order, Ariadne's drain, rule list (S1-Q6 as
  S2-Q16 leaves it) and move, pooled Execs' owners and run_all's drain, the AriApp and run_all
  limit. 4.17: the S2b failure rows and the ingress counters.
- 5: items 11-13 as built; S2b's always-on changes (one ordered ingress, the owner filter,
  post_message's bool and cap), hosts, step counts and the compatibility scan.
- 6.3, 7, 8.3, 8.4, 8.8: S2b's gates, files, tests (by name) and exit; S2c's entry.
- 9.2: S2-Q7..S2-Q10 and S2-Q16 built; the S2b lead's decisions; S2b.0a's amendments.
- STATE_EXEC_LOCKS.md 7.2, 7.5 (S2-Q7): the owner rule is per process; pooled Exec owner tags;
  owner "" has no rights across groups; what S2b built across groups and what waits for S2c
  (set-priority, get-priority); the weights shipped off in S2a.
- ARIADNE.md 2.5: routed host posts (a post to exec_scheduler() on an isolated document's channel
  reaches its group, a '#' channel never moves), group 0 pumped for what is posted to it under
  its token, a group-0 document seeing only its own processes, and two limits: an Ariadne host
  and ExecPool.run_all on one app run on one thread (both drive group 0, S1-Q4), and a document
  moving into a group leaves what was parked in group 0 for its channels. The processes
  component lists only its own Runtime's processes.
- APP_API.md: exec_scheduler_probe(), exec_router(), exec_pump_frame's group 0 for pending posts;
  messaging and control across groups (exec_pool's post_message, post_control, kill_owner, info;
  post_message's bool and cap; the owner rule), with an example; drain_end's group 0.
- STATE_EXEC_DEVELOPER_GUIDE.md: messages and control across groups for host authors (homes,
  channel_prefixes, islands, group 0's drivers, host posts, the cap, control, teardown, gaps); a
  post to exec_scheduler() on another group's channel is routed, one hop more, a '#' key stays
  put; post_control's order (the ordered ingress) and its kill_owner kind; the owner rule for
  ps, inspect, kill, pause and resume; msg-send's result (reason "ingress full", and "error"
  without a cluster shard); msg-recv and msg-pending on a remote home; ingress_cap's setting.
- bindings/pycvc/README.md: post_message's forwarding and result, msg-pending on a remote home,
  and run_all with an AriApp on one app from one thread.
B's text (B-notes.md), checked against B's commits on the integration head (the bench's
mt.cross_group_msg, tools/bench's GATE_GUARDS entry, state_exec_bench_gates.cmake, ci.yml,
run.sh, state-exec-stress.yml, locks-deep.yml):
- STATE_EXEC_BENCH.md: mt.cross_group_msg (keys, smoke, records, a rep's checks, the routing
  probe); its GATE_GUARDS entry; the gates CTest's span=one:cross steps_total pin; threaded
  execution's Stage 2b gates.
- TESTING.md: the router and stress binaries and mt.cross_group_msg in the sanitizer legs;
  SAN_REQUIRED_S2B and its row; run.sh's --keep-stress-suites and SAN_CXX_RUNS_S2B; the nightly
  stress lane (state-exec-stress.yml); locks-deep.yml's router-model lane; CVC_EXEC_FUZZ's router
  points.
… and required lines

The lead's decisions on R2a's and R2b's findings, in the frozen text and the headers:
- The cap counts a host post only for a key without '#': a '#' key's post is a runtime reply, a
  completion (R2b S-M1).
- Teardown: a refused poster waits with no cap (a backoff) while the home is still the closed,
  registered group, never on its own teardown's thread or for a closed group 0 (R2a C-M5, C-m1); a
  group that registered a prefix forwards every key's messages but '#' ones, even once
  unregistered (Ariadne's move) and for a key a longer prefix covers now (C-M4, S-m1, C-m4); a throw
  still unregisters and a second leave_router finds nothing (C-m2).
- group_ref::post_message posts into that group, unrouted; one group_ref lock at a time, never
  re-entered, nothing routed under it (C-M3).
- kill_owner is called on the thread that drives the fork-join groups and group 0, and is refused
  from inside a pump before it posts anything (C-M1, C-m5).
- The owner rule's #f for a group being torn down; a kill that killed before it threw gets
  done(true); deliver_to_receivers' -1 when no home is left; a dying home's keys go to the next
  covering prefix; the generation does not track lock holds (a publish compares them); what
  destroy_dropped counts; leave_router's order in its comments; the gap a key whose home changes
  twice under a broadcast leaves (S-m9). exec_router::prefix_registered for pycvc's pools (S-M2).
- SAN_REQUIRED_S2B lists R's, C's, A's and Y's S2b cases; the nightly lanes filter ST-1 and ST-2.
- processes.ari's comment and ARIADNE_SHELL.md say what a group-0 document sees since S2b.
MS-12 compared every layout with the single group run with the router on, so "every outcome equals
the single-group outcome" was checked against the router's local path. Its oracle is now each
column's programs in one group of an app where no group registers a prefix (the router off and
never consulted, which the cell checks: today's messaging), and every layout, the single group with
the router on included, is compared with that; hand-pumped and in deterministic mode, as before.
…views (C-M2, C-m5)

- C-M2: a failed try of a group's token no longer means another thread will drain it. The holder
  may be a one-shot drain (another kill_owner's, run_all's last round, a frame's look) or a
  pump_all that is not called again, and with group 0 undriven the caller waited for ever. While a
  group's command is not done, the wait tries the group again on a backoff (1 ms doubling to
  50 ms; the wait is still woken at once by each done), and an inline drain drains until the
  ingress is empty (bounded rounds), not only until its own command: a kill_owner that held the
  token applies the commands of one whose try failed meanwhile.
- C-m5: kill_owner from inside a target group's pump (or a step of group 0 on this thread) is
  refused before anything is posted or drained; before, earlier groups were already drained and
  every command posted when it threw.
- C-M1 is exec_pool.h's contract (fd08049): kill_owner on the thread that drives the fork-join
  groups and group 0. A token try that fails is caught as kPumpedElsewhereError only.

Tests (the R2a probes, adopted): PoolKillOwner.TwoAtOnceBothReturn (two kill_owners on group 0 at
once, the second posting while the first applies: both return; it hung before) and
PoolKillOwner.RefusedInsideAGroupsPumpBeforeActing (refused from g's pump hook: h, drained first
before, keeps its process and has nothing posted).
R's items of the R2 fix round (R2-fixes.md), to exec_router.h's text at fd08049:
- C-M3: route_target's closed flag is an atomic, set by close() under the lock and read lock-free
  by closed(); group_ref::post_message posts into its group unrouted (a send entry through
  post_route, uncapped for a '#' key), so no handle's lock is taken twice and nothing is routed
  under one.
- C-M5, C-m1: a refused poster waits with no cap (yields, then 100 us sleeps) while home_of still
  gives the closed, registered home; a post made by a scheduler whose handle is closed (its
  teardown: leave_router, its kills, its destructor) and one refused by a closed group 0 resolve
  with new_home_of at once. A host's post (another thread) waits.
- C-m2: leave_router unregisters however it ends (a scope guard), and counts its records out of
  the router as it takes them; exec_group's constructor registers its prefixes before set_router,
  and a throw there unregisters and closes the handle.
- C-M4, S-m1, C-m4: a scheduler remembers it had a prefix (set_router, after exec_group's
  registration, and the cache), and its teardown forwards every message it holds but '#' ones to
  new_home_of, even once unregistered and for a key a longer prefix covers now; an island forwards
  none.
- S-M1: a host post of a '#' key is never capped.
- C-m3: deliver_to patches the frame before it clears the wait; a deliver that threw after its
  patch still answers taken for a tracked copy.
- C-m7: ingress_cap_ is an atomic, written under the ingress mutex.
- S-m8: register_prefix ignores "" from a group other than group 0 (a debug build asserts).

Tests (RouterR, each failing on the code before this commit; adopted probes named):
APostThroughAHandleNeverDeadlocksWithItsClose (R2a PostMessageThroughAHandleRacingItsClose),
APostThroughAHandleGoesIntoItsGroup, AnUnregisterAloneStillForwardsAtTheTeardown (R2a
AnUnregisterAloneLosesTheMessagesItHomes), ATornDownHomeForwardsAMessageALaterPrefixCovers (R2b
Sm1; R2a's C-m4 probe is the same case), AnAnswerWaitsForItsClosedHomesForward (after R2a's
AnAnswerThatOutwaitsTheForwardIsNotADuplicate, on two threads), ATeardownNeverWaitsOnItself (after
R2a's ATeardownNeverWaitsForItsOwnUnregister), AReplyOnAHashKeyIsNeverCapped (R2b SM1),
OnlyGroupZeroRegistersTheEmptyPrefix (release builds). C-m2, C-m3 and C-m7 have no test: an
allocation failure, or a race only TSan sees.
…l-key test fixed

The R2 reviews' pycvc items (R2-fixes.md, section Y).

- S-M2: two ExecPools of one app with one prefix registered one channel prefix, whose home is the
  first pool's group, so the second pool's own channels hung there. Each live pool of an app now
  has a prefix of its own (exec_router::prefix_registered on its first chroot, "<prefix>.0"): the
  default "exec_pool" takes the first free of exec_pool, exec_pool_2, exec_pool_3, ..., and any
  other prefix a live pool already uses raises ValueError. A closed pool's prefix is free again.
  ExecPool.prefix (read-only) reports the one chosen. test_s2b7_one_prefix_per_pool (from R2b's
  probe): two default pools take exec_pool and exec_pool_2 and the second's own channel works; an
  explicit prefix in use is refused, and taken once its pool is closed.
- S-M3: test_s2b7_a_global_key_meets_across_pooled_execs sent an int, did arithmetic on msg-recv's
  envelope and replied to a key nobody waited on; it now uses R2b's programs (the payloads, and
  "/s2b7pool.1.channels.reply", what (msg-recv "reply") in that Exec waits on) and expects
  ["41", "41+1"]. README's example key is "/<prefix>.1.channels.inbox".
- README: one prefix per pool, ExecPool.prefix; the shared-tags sentence goes.
R's seven RouterR cases (OnlyGroupZeroRegistersTheEmptyPrefix runs in release builds only, so it is not a required line), C's two PoolKillOwner cases and pycvc's test_s2b7_one_prefix_per_pool.
#1524's package-linux / libcvc-debug failed ExecPool.PL05_ALightGroupIsNotStarved three times: a
message's latency was 2 heavy pumps (1 or 2 of 100), against at most the one in progress. The pool's
virtual time is pump time, and at the default 2 ms budget a step slowed past it (steps of 2-3 ms
were logged in both groups on that runner) ends a light pump before its program takes the message,
which then waits out a heavy pump more. A probe with a 20 us budget shows the same latencies here.

The case now pumps 20 ms with unbounded steps, so every build's heavy pump takes the whole budget and
a light pump outlasts a slow step: 40 of 40 as 4 copies sharing 2 cores, 10 of 10 alone. A steps-only
budget was tried and dropped: a light pump could then run long, and a descheduled one put the light
group tens of heavy pumps behind (latencies of 12 to 107 under the 2-core squeeze).
transfix added a commit that referenced this pull request Nov 24, 2026
#1524's package-linux / libcvc-debug failed ExecPool.PL05_ALightGroupIsNotStarved three times: a
message's latency was 2 heavy pumps (1 or 2 of 100), against at most the one in progress. The pool's
virtual time is pump time, and at the default 2 ms budget a step slowed past it (steps of 2-3 ms
were logged in both groups on that runner) ends a light pump before its program takes the message,
which then waits out a heavy pump more. A probe with a 20 us budget shows the same latencies here.

The case now pumps 20 ms with unbounded steps, so every build's heavy pump takes the whole budget and
a light pump outlasts a slow step: 40 of 40 as 4 copies sharing 2 cores, 10 of 10 alone. A steps-only
budget was tried and dropped: a light pump could then run long, and a descheduled one put the light
group tens of heavy pumps behind (latencies of 12 to 107 under the 2-core squeeze).

(cherry picked from commit 67fda68, #1524: the same flake failed
#1500's recipe / ubuntu-22.04 / Debug three times at a651d0c)
@transfix
transfix marked this pull request as ready for review November 25, 2026 01:51
@transfix
transfix merged commit 014eef2 into master Nov 25, 2026
30 checks passed
@transfix
transfix deleted the perf/threaded-s2b branch November 25, 2026 07:48
@transfix

Copy link
Copy Markdown
Owner Author

S2b A/B (S2.md section 6's S2b rows), run 2026-11-25, 02:59-03:27 local time, Windows MSVC Release, --pin auto, AB.lock held. Base 6489379 (master as merged into this branch); candidate 67fda68 (this PR's head). Base and candidate interleaved, two rounds of 5 reps each.

Gate Result
steps_total unchanged (regression family; mt.groups fork-join; mt.cross_group_msg one group against cross) PASS on every deterministic point (300/300, 30/30, the one:cross pin). See note 1 for the tool's one flag.
mt.cross_group_msg wake latency p50 under 50 us (one pair across two groups) PASS: 6.2 / 6.4 / 6.65 us at t=1/2/4
msg.* with one group within 3% (same pin) INCONCLUSIVE on noise (note 2): geomean cand/base -0.91%, 11 of 20 points slower
sched.single.* (recorded) inconclusive: geomean -0.92%
mt.groups fork-join (recorded: the published info's cost on an app's groups) inconclusive overall. The quiet round 1 is -1.0% (11 of 30 slower; t=8 +3.1%). Round 2's candidate run was disturbed (+59%).

Recorded: a cross-group pingpong costs about 14.5-15.4 us a round trip, against 11.8-12.0 us in one group. Broadcast and fan-out tables are in the run's records.

  1. The tool's reg.steps compare exits 1 on one point: async.futures driver=poll1ms k=10 kernel=sleep1ms where=background, 314 to 312. That count is time-charged: its kernels run on background threads and sleep 1 ms. Base itself gave 312 three times and 314 seven times in this run, and the candidate's ten reps were all 312. Ten such async.futures points vary run to run on both sides; seven stay inside base's own range, and three drift slightly both ways. Every deterministic point is unchanged.
  2. Another session compiled throughout the regression family (up to 18 cores of cl). Every kept regression run is marked DISTURBED, and the per-round geomeans swing by ±16%, so the 3% gate cannot decide. A rerun of msg.* and sched.single.* in a quiet window is ready (ab_window_s2b_rerun.ps1).

@transfix

Copy link
Copy Markdown
Owner Author

S2b A/B rerun of msg.* and sched.single.*, 2026-11-25 04:48-04:51 local time, in a quiet window: the waiter needed three quiet checks a minute apart, and every kept run was quiet. Same frozen pair: base 6489379, candidate 67fda68. Two rounds of 5 reps each, base and candidate interleaved.

Result
steps_total unchanged PASS
msg.* within 3% (gate) INCONCLUSIVE by the tool (each point's own noise is above 3%; base spreads run from 3% to 32%). Geomean cand/base +3.7%, 17 of 20 points slower; round 1 +3.0%, round 2 +4.2%.
sched.single.* (recorded) geomean -1.5% (10 of 34 slower)

The msg.* cost sits in msg.fanout (async +10 to +15%, sync +6 to +7% at k=100 and 300), sync msg.producer_consumer (+8%) and sync msg.broadcast k=10 (+6%). Pingpong and ingress are within about 3%.

The sync scheduler's messaging code is unchanged by S2b, so part of this is probably code layout. The async scheduler's path with no router does add work, though: a second process-table lookup per receive (subscribe_if_remote after park_receiver), and out-of-line calls to homed_elsewhere and exec_router::active on every message operation. A follow-up can make that path inline and lookup-free, then measure again.

transfix added a commit that referenced this pull request Nov 25, 2026
…ck over them (#1500)

* cvcGL: viewport views drawn into textures, so windows stack over them (shell SH2)

An Ariadne `viewport` widget's view used to be drawn into the window's
frame under all of the UI, with a hole cut in its window's background,
so any window over the view's rect covered it, even one behind the
view's window, and the view's first frame was opaque.

Each view now draws into a texture of its own (Viewport::setTextureSize,
texture()), the widget's size in framebuffer pixels, at the window's own
multisampling and resolved as the window's pixels are; the widget draws
that texture as an image in its window. The window stacks, clips and
scrolls the view like any of its content. The view draws in the window's
render after the widget walk placed it, so its first frame shows it: the
mirror re-syncs and the throttle (refresh_hz) decides as the render
reaches it, and a view made this frame is readied (what it leaves out,
its shadows, its framing) by its widget. Picks, pointer probes and the
wheel map a point on screen to the view's texture
(Viewport::windowToRenderer / rendererToWindow). A scenes: entry's
anchor bakes its shadow maps by drawing one pixel into a texture of its
own. ImGuiBackend::cut_window_background and its background painting go.

Tests: cvcgl_ariadne_view_stacking (a window over a view, a view's
window over another window, the first frame, a clipped and a scrolled
view against the same picture in full, a pick through the scroll), the
view_stacking golden, and the pick and slice-view tests through the new
coordinate mapping. cvcgl_ari_frame_bench measures a document's frame
cost offscreen. The arigl-web CI job now also runs on changes to how a
view draws.

* cvcGL: a mirror's re-sync leaves it alone when nothing it draws changed; docs for SH2

syncMirrorProps took every prop out of a mirror and put it back every
frame, and the next draw of those props was slower for it. With views
now re-synced just before they draw, each view paid that: on
viewer_grid.ari a view's draw took 1.6 ms instead of 0.4. The mirror is
now left alone when it already holds exactly the props and lights it
should draw (same ones, same order), which also takes the cost off the
main view where the old order put it.

ARIADNE.md 5.18: how a view draws (a texture its window shows), its
refresh rate (moving it does not redraw it), a scenes: entry's anchor,
what it costs, and the limits (the view under the UI and the opaque
first frame are gone). The UI-DSL roadmap's render-to-texture tier
notes that rendering a view into a texture is built.

* goldens: view_stacking, and orthoslicer / volume_grid / volume_grid_quad with views drawn into textures

Written under Mesa 25.3.6 llvmpipe (cvcpkg's Windows build; it matches the
grid, menus, scene, widgets and windows goldens to the pixel).

view_stacking is new: a window over a view, a view's window over another
window, a clipped view. The other three change around their views: the
view's window now shows its border, resize grip, scroll bars and tab-bar
separator, which the old background painting around the hole covered, and
in volume_grid a slice view's caption that runs past its view is covered by
the view beside it. Inside the slice views a few nearest-sampled texels at
ties land on the other side under llvmpipe, the view being rasterized at
its texture's origin rather than at its place in the window (none on an
NVIDIA GPU).

* cvcgl_ariadne_volume_grid: project world points to the screen through the view's texture

A view's renderer draws into its texture now, so its display coordinates are
the texture's pixels; the test maps them to the window (rendererToWindow)
before it moves the pointer there, as the pick and slice-view tests do.

* cvcGL: every viewport sends its own lights, where VTK can (UpdateLightingUniformsEveryRender)

The renderers of a window share its shader programs, and VTK 9.5 keeps a
program's light uniforms with only the time they were set
(vtkOpenGLRenderer::UpdateLightingUniforms), not whose lights they are. A
view and the main view draw the same props, so one of them could draw
with the other's lights; which one depended on the order of VTK's
modified times, and differed between Linux and Windows.

cvcpkg's VTK 9.5.0+cvc.7 (cy-pca/cvcpkg#636) adds an opt-in
vtkOpenGLRenderer::UpdateLightingUniformsEveryRender. A compile check
(CVC_VTK_HAS_LIGHTING_UNIFORMS_EVERY_RENDER, as for FinishEveryRender)
finds it, and Viewport turns it on for every renderer it makes: the main
view's, the views', mirrors. An older VTK builds and renders as before.

cvcgl_ariadne_view_stacking compares the main view with a window's view
and without it (a see-through shell around a box the view shows from
its own camera): with the property it checks they match; without it, it
reports how many pixels differ (11,667 of 434,700 here, NVIDIA).
ARIADNE.md 5.18 lists the older-VTK behaviour as a limit.

* cvcgl_ariadne_pick: the module view's pointer maps its renderer's point to the window

master's module-view checks (#1493) took the view's renderer display
point as the window's; the view draws into its texture now, so it goes
through rendererToWindow, as the test's other sections do.

* cvcGL: a window's renderers send their own lights once it has two; goldens on VTK 9.5.0+cvc.7

UpdateLightingUniformsEveryRender moves from Viewport's constructor to
ViewportManager, which turns it on for every renderer of a window once
the window has a second one, and leaves it on when a view goes (the
view's lights may still be in a program). A window that only ever had
one renderer keeps VTK's default: nothing else writes its programs'
lights. With the property on, VTK sends a program's lights in the first
cell-type block that uses it each render; cvcgl_lowmem_fastdraw derives
Fast's trace by deleting empty blocks from the AllCellTypes trace, so
it could not see those uploads move to the next block (its uniform-state
and pixel checks held). Its single-renderer window is back on VTK's
default.

cvcgl_ariadne_view_stacking checks the property is on for both
renderers with a view, and off for the main view alone.

Goldens from CI on vtk 9.5.0+cvc.7 (Linux release and release-grpc,
identical to 1 LSB). Against the same commit on cvc.5 (Windows), only
renderers that drew with another's lights change: the main view in
view_stacking, skeleton and molecule_skeleton, and 23 px of the 3-D view
in volume_grid_contours.

* SceneViews: a view is framed on what it draws, a volren by its volumes' box

A view without show: was framed on whatever its renderer held: the
props ViewportManager primed it with before SceneViews set the view's
filter, until the render re-synced it. With a volren that is the main
view's picture quad, which spans the main camera's frustum (+-145 in
volren_views), so the views framed far out; SH4's golden encodes that,
and its zoom: 1.7 was set against it. The view's own picture of a
volren (VolRenViewActor, bounded by the volumes' box) joins the
renderer only once its first raycast lands, after framing.

- ViewportManager::syncMirror(name): a live mirror's re-sync through
  its filter, now. SceneViews::prepare runs it before framing, so the
  renderer holds what the view will draw (also what it leaves out:
  chrome, tags).
- The bounds of a view without show: take in each volren node it draws
  by its volumes' box, known from the first frame.
- volren_views.ari drops zoom: 1.7: framed on the rods and the volume's
  box, its views look as the golden composed them. The golden itself
  is retaken from CI on vtk 9.5.0+cvc.7 (its rods draw with each view's
  own lights).
- cvcgl_ariadne_node_pick (#1491) maps the view's points through
  rendererToWindow, as the other pick tests do.

Under llvmpipe every other golden's frame is pixel-identical before and
after.

* golden: volren_views on SH2 (views framed on what they draw; vtk 9.5.0+cvc.7)

Its views are framed on the rods and the volume's box (42eed3b), with zoom: 1.7
dropped from the document, so they keep SH4's composition; the windows show
their border and grip over their views; the main view's rods draw with the main
view's own lights. From CI run 45326238844 (Linux libcvc-release); Windows's
frame is within 3 of it.

* ari test: FramesAndTimeout's stuck document gets 4 s, not 1

The timeout counts from before the document loads, and its message names
the test only once the test has started. On a slow runner a Debug build
spent the whole second loading, so the message had no test in it: the
debug lane failed this test on master (f32ae43) and on several branches,
while it passed in about 3 s on others.

* tests: PL-5's pumps are 20 ms, far past a slow step

#1524's package-linux / libcvc-debug failed ExecPool.PL05_ALightGroupIsNotStarved three times: a
message's latency was 2 heavy pumps (1 or 2 of 100), against at most the one in progress. The pool's
virtual time is pump time, and at the default 2 ms budget a step slowed past it (steps of 2-3 ms
were logged in both groups on that runner) ends a light pump before its program takes the message,
which then waits out a heavy pump more. A probe with a 20 us budget shows the same latencies here.

The case now pumps 20 ms with unbounded steps, so every build's heavy pump takes the whole budget and
a light pump outlasts a slow step: 40 of 40 as 4 copies sharing 2 cores, 10 of 10 alone. A steps-only
budget was tried and dropped: a light pump could then run long, and a descheduled one put the light
group tens of heavy pumps behind (latencies of 12 to 107 under the 2-core squeeze).

(cherry picked from commit 67fda68, #1524: the same flake failed
#1500's recipe / ubuntu-22.04 / Debug three times at a651d0c)

* goldens: volume_grid's four on SH2 after #1452 (views in textures)

volume_grid, volume_grid_contours, volume_grid_quad and #1452's
volume_grid_segment, from CI run 45482759652 (Linux libcvc-release, vtk
9.5.0+cvc.7). Against SH2's previous images only #1452's panel differs (the
Segmentation tab, names and hex colours); against master's, SH2's changes:
a view's overlay text stops at its view, a view drawn in its window's order
covers the tab bar's rule, and the windows show their border and grip.
volume_grid_segment's Bones view is unchanged (within 1).

* goldens: macOS images for the documents SH2 re-renders

From ci/full run 45572393826 at 59220fb (package-macos / libcvc-release,
vtk 9.5.0+cvc.7; the debug, release-grpc and release-grpc-static lanes'
frames are within 1 of it).

orthoslicer (a refresh: the view's window shows its border and grip, and
the slices' tied texels), view_stacking (new) and volren_views (new: its
views are framed on what they draw) change with SH2 itself. skeleton,
molecule_skeleton, volume_grid, volume_grid_contours, volume_grid_quad and
volume_grid_segment already failed on master's macOS lane; SH2 re-renders
them too, so their macOS images are taken at SH2's rendering. #1526's
images for these seven are taken at master's and differ from SH2's frames
by 2,414 to 16,792 px; its contour_tiler.macos.png is unaffected.
transfix added a commit that referenced this pull request Nov 26, 2026
…test (#1543)

A follow-up to threaded execution's S2b (#1524). With no router set, or the router off, the async scheduler's messaging still paid for routing on every operation. This makes that path one inline test:
- exec_router::active() is inline, its two counters moved from the pimpl into the class;
- async_scheduler::routing_on() is a new inline test, and homed_elsewhere is now an inline wrapper over homed_elsewhere_slow, which runs only when routing is on;
- park_receiver returns the process it parked, so a receive subscribes at a remote home only while routing is on, without a second lookup;
- deliver_to_receivers builds its group handle only while routing is on.

Behaviour is unchanged. A three-way quiet-window A/B (#1543's comment) puts msg.* at -0.69% against the pre-S2b base and S2b at -1.08%. The trim's own effect, +0.40% against S2b, is within the noise. The cvcgl_volume_grid_segment_cooperative failure on the first CI run was a wall-clock check, and it passed on rerun.
transfix added a commit that referenced this pull request Nov 26, 2026
…lace the poster's wait (S2b.R3) (#1561)

A follow-up to threaded execution's S2b (#1524, #1543), fixing the skeptic's findings K-1 to K-6. A group in its teardown never waited for another closed home, so a receiving group torn down with its home sent its answers and unsubscribes ahead of the home's forward: a duplicate broadcast delivery, a leaked tracker, and a dead process's record that kept the router on. Waiting instead would deadlock two homes torn down at once.

- A closed handle takes router entries into a late queue until it is done. The teardown forwards each key's entries to one target, the key's home among the groups open when its first entry goes, forwards the late entries until none are left, then unregisters under the handle's lock and keeps each key's target as a forwarding address. A refused poster follows that address at once. A teardown's own forwards go to open groups only, so nothing comes back to it except a deliver's requeue.
- The seal is a backstop for posters as fast as the forward: when a round's batch doesn't shrink, reaches the ingress cap, or 4 rounds have gone, only another teardown's forward is still taken, and any other poster waits for done, a bounded wait.
- K-2: a teardown's queued and late sends are forwarded only for keys it homed. K-3: once its teardown begins, post_message goes through the group's handle, keeping a host's order; a post that would die with the group dies now, counted. K-4: the constructor's guard spans the whole constructor. K-5: three of the skeptic's probes are adopted.
- The R3 review's fixes: seal on a batch that doesn't shrink or reaches the cap, try_post's refusal reasons, address hops don't count against the 16 re-resolutions, closed-handle posts take only the late-queue mutex and done is atomic.
- The router model has the late queue in place of the wait (quick 32 checks, deep 49, 0 unexpected), and the skeptic's teardown-no-wait mutation finds the three findings. The router-model job's timeout is raised to 90 minutes. 16 RouterR3 tests are added to SAN_REQUIRED_S2B.
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