Repository navigation
perf(beamrt): Wave 3D-36 selective-receive thunk fast path & #462 P2/P3 closure - #468
Merged
Merged
Conversation
…P3 closure
- Selective-receive hot path (asm_ctx.rs, mailbox.rs):
- Promote Peeked to #[repr(u32)] adjacent to 8-byte-aligned peeked_next
with compile-time layout assertions; pack peeked_next + Peeked::Ordinary
into a single 64-bit store in beamrt_recv_peek_thunk and a matching
64-bit load in beamrt_recv_next_thunk (eliminates store-forwarding stall).
- Defer pending_exit check in beamrt_recv_peek_thunk to the empty-queue
path (matching recv_peek_impl semantics) and drop per-peek examined RMW
on the naked-asm fast path.
- Hoist 2-word local HDR_REF exact equality to Fast Path 0 in
beamrt_bif_cmp_thunk (x86_64 and aarch64) so selective-receive {^Ref, _}
scans stay straight-line in the entry cache line with zero taken jumps.
- Close all Fable #462 2 P2 + 4 P3 items:
- P2-1 (scheduler.rs, dirty.rs): extract pure should_skip_idle_spin helper
+ deterministic spin_loop_entries assertion in
runtime_oversub_backoff_skips_dirty_handoff_spin, and deterministic
synthetic-clock unit test dirty_preempt_invokes_on_preempt_and_sets_cooldown.
- P2-2: controlled taskset -c 0,1 5-round ABBA bisect of (A)/(B)/(C)
confirms (A) both-sides park beats (B) by 40.3% and (C) by 49.1% under
deterministic external oversubscription.
- P3-1 (io_poller.rs): CachePadded<AtomicUsize> for PENDING_WORK.
- P3-2 (net/prim_inet.rs): Linux-only fstat (st_dev, st_ino) assertion
with getsockname verification on non-Linux.
- P3-3 / P3-4 (io_poller.rs, net/prim_inet.rs, scheduler.rs): accurate
clamp(1, 4) comment, 'thread-local buffer' wording, drop redundant
normal_budget_ns alias.
CommaBot
pushed a commit
that referenced
this pull request
Dec 6, 2026
CommaBot
added a commit
that referenced
this pull request
Dec 6, 2026
Co-authored-by: Heyang Zhou <6104981+losfair@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wave 3D-36 targets CP#9's #2 real
beamrthotspot (beamrt_recv_peek_thunk9.59% +beamrt_recv_next_thunk3.58% = 13.17%, paired withbeamrt_bif_cmp_thunk9.31% in selective-receive{^Ref, _}scans) and closes all 2 P2 + 4 P3 items from Fable's #462 review. Strict file boundary:crates/beamrt/src/**only (6 files, +276/-120).1. Selective-receive & local
HDR_REFhot-path optimizations (asm_ctx.rs,mailbox.rs)peeked_next+peekedstore/load: PromotedPeekedto#[repr(u32)]right after 8-byte-alignedpeeked_next(enforced by compile-timeconst _assertionsPEEKED == NEXT + 4,NEXT.is_multiple_of(8),ORDINARY == 1,target_endian == "little").beamrt_recv_peek_thunkpacksnode_next | (ORDINARY << 32)into a single 64-bit store (bts r10, 32/orr x10, x10, #0x100000000), andbeamrt_recv_next_thunkreads both via a matching 64-bit load (clean L1 store-to-load forwarding).pending_exitcheck & drop per-peekexaminedRMW: Movedpending_exitcheck inbeamrt_recv_peek_thunkto the empty-queue30:label (matchingrecv_peek_implinexports.rs:1435-14581:1) and removed the 64-bitexaminedread-modify-write on the naked-asm fast path.HDR_REFexact equality to Fast Path 0 inbeamrt_bif_cmp_thunk(bothx86_64andaarch64): Straight-line 10-instruction path in the entry 64B i-cache line with zero taken jumps for{^Ref, _}selective-receive scans, with the non-matching-second-operand tail (7:) kept cold.2. Fable #462 2 P2 + 4 P3 closure
scheduler.rs,dirty.rs): Extracted pureshould_skip_idle_spin(...)helper with full truth-table assertions +#[cfg(test)] spin_loop_entries: AtomicUsizesoruntime_oversub_backoff_skips_dirty_handoff_spindeterministically fails if thert.oversub.is_active(now)guard is reverted; added deterministic synthetic-clock unit testdirty_preempt_invokes_on_preempt_and_sets_cooldowncoveringon_preempt+ cooldown.(A)both-sides park vs(B)scheduler-only park vs(C)dirty-only park undertaskset -c 0,1(BEAMRT_SCHEDULERS=2) acrosssolo,combined, andsolo_oversub(pinned external CPU burners). Kept(A): under deterministic external oversubscription (solo_oversub),(A)(268.28 ms) beats(B)(376.32 ms,+40.27%slower) and(C)(400.10 ms,+49.13%slower).io_poller.rs): WrappedPENDING_WORKincrate::pad::CachePadded<AtomicUsize>to eliminate false sharing withPOLLERS.net/prim_inet.rs): Gatedfstat(st_dev, st_ino)assertion with#[cfg(target_os = "linux")]and verified viagetsocknameon non-Linux (macOS/BSDfstatreturns0for inet sockets).io_poller.rs,net/prim_inet.rs,scheduler.rs): Updatedio_poller.rscomment with CP#9 2-sched forced-4-shard-6.6% / -9.7%trade-off; replaced"TLS path"with"thread-local buffer"; removed redundantnormal_budget_nsalias.Verification
Controlled-load 5-round ABBA (
pvg-office-1, Ryzen 7 PRO 8845HS,taskset -c 0,1,BEAMRT_SCHEDULERS=2, 10 paired samples each)mbox_scan_bench, depth=20,000, iters=1,000 = 20M scans/run,loadavg 23.14 -> 23.04):BASE (357ca95e): median216.43 ms(10.82 ns/msg, min165.76, max283.54)OPT (Wave 3D-36): median200.42 ms(10.02 ns/msg, min131.17, max252.51) →-7.40%(1.080x)dirty_cpuNIF handoff 3-way bisect (prim_buffer:find_byte_index/2,loadavg 23.04 -> 20.66, lower ms = faster):BASE (357ca95e)(A)both-sides park(B)sched-only park(C)dirty-only parksolo(2 dirty procs on 2 cores)160.24 ms213.28 ms145.33 ms(-31.9%vs A)132.02 ms(-38.1%vs A)combined(2 dirty + 2 normal CPU procs)213.46 ms258.22 ms137.01 ms(-46.9%vs A)194.39 ms(-24.7%vs A)solo_oversub(+2 pinned external CPU burners)261.12 ms268.28 ms376.32 ms(+40.3%vs A)400.10 ms(+49.1%vs A)solo_oversub),(A)avoids spinning away CPU quantum and beats(B)by40.3%and(C)by49.1%;(B)/(C)only win when cores are not externally contended. Therefore(A)is retained.OPT_IDLE_3S_CPU_PCT=0.00%(< 1%gate).All 6 Local Gates (on
pvg-office-1)./scripts/check-aeneas-subset.sh— PASS./scripts/check-beamrt-ssot.sh— PASScargo clippy -p beamrt --all-targets -- -D warnings— PASScargo test -p beamrt --lib— PASS (282 passed; 0 failed)cargo test -p beamrt --test runtime_tests -- --test-threads=1— PASS (64 passed; 0 failed)cargo test -p beamrt --test ssot_matrix_tests— PASS (6 passed; 0 failed)Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.