Skip to content

state_exec: the async scheduler's messaging with no router costs one test - #1543

Merged
transfix merged 1 commit into
masterfrom
perf/s2b-unrouted-fastpath
Nov 26, 2026
Merged

transfix merged 1 commit into
masterfrom
perf/s2b-unrouted-fastpath

Conversation

@transfix

Copy link
Copy Markdown
Owner

A follow-up to threaded execution's S2b (#1524). Its A/B left the msg.* 3% gate inconclusive. A quiet rerun (#1524 (comment)) then put msg.* 3.7% slower than before S2b, 17 of 20 points, mostly in msg.fanout, msg.producer_consumer and msg.broadcast.

With no router set, or the router off, the async scheduler still paid for routing on every message operation:

  • each check made an out-of-line call to async_scheduler::homed_elsewhere, and with a router set a second one to exec_router::active;
  • every receive looked up its process twice, once in park_receiver and again in subscribe_if_remote;
  • every delivery built an empty group handle.

This change:

  • makes exec_router::active() inline, by moving its two counters from the pimpl into the class;
  • adds async_scheduler::routing_on(), an inline test of the router; homed_elsewhere becomes an inline wrapper over the out-of-line homed_elsewhere_slow, which runs only with the router on;
  • has park_receiver return the process it parked, so a receive subscribes at a remote home only while routing is on, with no second lookup;
  • has deliver_to_receivers build its handle only while routing is on.

Behaviour is unchanged. On Windows MSVC Release these suites pass at the default and at CVC_EXEC_SLICE_STEPS=256: router 66, stress 2, exec_pool 87, groups 33, async 143, intrinsics 181, integration 105, ariadne_runtime 364, ariadne_host 54.

Measurement: a three-way quiet-window A/B is pending. It compares msg.* and sched.single.* across base 6489379 (before S2b), S2b as merged (67fda68), and this branch. Its numbers will be added here.

…test

S2b's A/B (#1524) left the msg.* 3% gate inconclusive, but a quiet rerun put msg.* 3.7% slower,
mostly msg.fanout, msg.producer_consumer and msg.broadcast. With no router, or the router off, every
message operation still made an out-of-line call (async_scheduler::homed_elsewhere, then
exec_router::active), every receive looked its process up twice (park_receiver, then
subscribe_if_remote), and every delivery made an empty group handle.

- exec_router::active() is inline: its two counters move from the pimpl into the class.
- async_scheduler::routing_on() (inline) tests the router; homed_elsewhere is an inline wrapper over
  the out-of-line homed_elsewhere_slow, which runs only with the router on.
- park_receiver returns the process it parked, and receive_message / receive_message_until
  subscribe at a remote home only while routing is on, with no second lookup.
- deliver_to_receivers makes its handle only while routing is on.

Behaviour is unchanged: router, stress, exec_pool, groups, async, intrinsics, integration and the
Ariadne suites pass at the default and at CVC_EXEC_SLICE_STEPS=256.
@transfix

Copy link
Copy Markdown
Owner Author

Three-way A/B, 2026-11-25 11:02-11:09 local time, in a quiet window: the waiter needed three quiet checks a minute apart, and every kept run was quiet. Three rounds of 5 reps of msg.* and sched.single.*, the side order rotating each round, Windows MSVC Release, --pin auto.

Geomean of median wall all rounds round 1 round 2 round 3
msg.*, S2b / base -1.08% (5 of 20 slower) -2.84% +1.33% -2.36%
msg.*, trim / base -0.69% (7 of 20 slower) -2.29% -0.90% +1.02%
msg.*, trim / S2b +0.40% (10 of 20 slower) +0.56% -2.20% +3.47%
sched.single.*, S2b / base -3.35% -4.66% -2.09% -3.54%
sched.single.*, trim / base -1.33% -4.71% -1.65% +2.71%
sched.single.*, trim / S2b +2.09% (27 of 34 slower) -0.05% +0.44% +6.48%
  • steps_total, base vs trim: PASS.
  • msg.* within 3% of base: INCONCLUSIVE by the tool (each point's own noise is above 3%). But at the geomean, S2b and the trim are both within about 1% of base, and both on the faster side.
  • The earlier quiet rerun's +3.7% for S2b (state_exec: threaded execution's S2b, the router and process control across groups #1524, issuecomment-7160310140) does not reproduce: here S2b measures -1.08%. Whole windows on this box move by about ±4% at the geomean, which is more than the per-round agreement inside one window suggested.
  • The trim has no measurable effect: +0.4% on msg.*, and +2.1% on sched.single.*, nearly all of it in round 3. It removes work by construction (a lookup per receive, two calls per message operation), but within the noise here.

@transfix
transfix merged commit 7e9e5c7 into master Nov 26, 2026
54 of 55 checks passed
@transfix
transfix deleted the perf/s2b-unrouted-fastpath branch November 26, 2026 17:30
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