Skip to content

beamrt: reuse TCP iolist flatten scratch and close #468 P3 items - #471

Merged
CommaBot merged 1 commit into
mainfrom
feat/wave3d38-beamrt
Dec 6, 2026
Merged

CommaBot merged 1 commit into
mainfrom
feat/wave3d38-beamrt

Conversation

@CommaBot

@CommaBot CommaBot commented Dec 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Strictly scoped to crates/beamrt/src/** (Wave 3D-38, based on main @ 78aaffef):

  1. TCP large-iolist send scratch reuse (crates/beamrt/src/net/prim_inet.rs)

    • In Driver::command_with_proc(), when a batched TCP send exceeds Iodata::borrow's inline VECTOR_COUNT/PACKED_BYTES (such as netbench raft_log's flink_sender_loop batching up to 64 AE lines per :gen_tcp.send), the fallback previously allocated and freed a fresh Vec<u8> on every send (3.60% Self-CPU in glibc malloc/free under 0-LOST perf).
    • Added a bounded RAII thread-local SendScratch (TCP_SEND_VEC, capped at 64 KiB on drop so oversized payloads are dropped rather than pinned in TLS; alternating oversized/small sends simply fall back to normal allocation, matching the uncached baseline), plus unit test tcp_send_scratch_reuses_and_caps_oversized_buffers.
  2. Close all 4 Fable perf(beamrt): Wave 3D-36 selective-receive thunk fast path & #462 P2/P3 closure #468 P3 follow-up items

    • P3-1 (crates/beamrt/src/mailbox.rs): Clarified MsgQueue::examined doc comment (incremented by Rust MsgQueue::peek, omitted by naked-asm beamrt_recv_peek_thunk).
    • P3-2 (crates/beamrt/src/asm_ctx.rs): Added 3 targeted unit tests pinning (a) recv_peek_thunk fused 64-bit store observed by Rust MsgQueue::advance(), (b) recv_next_thunk priority lane (peeked == 2 → cur_prio), and (c) pending_exit deferral in both branches (non-empty queue stays on fast path; empty queue enters slow path → die_now → Y_EXIT).
    • P3-3 (crates/beamrt/src/scheduler.rs): Moved entries_before snapshot after rt.oversub.spin_backoff_until_ns.swap(...) in oversub_backoff_compacts_short_local_backlog_and_recovers_after_expiry.
    • P3-4 (crates/beamrt/src/asm_ctx.rs): Fixed stale doc comment (r15 / x28 holds Process, not the first argument register).

Profiling & R2 Review Notes (pvg-office-1, Ryzen 7 PRO 8845HS, workers=4)

  • 0-LOST perf & perf stat on netbench/raft_log (beamc vs OTP 29.1.2 beam):
    • SendScratch cut raft_log user CPU by -20.6% (3.29s → 2.61s, 19% lower than OTP 29.1.2 BEAM's 3.23s).
    • R2 cleanup per Fable review:
      • Reverted the R1 scheduler.rs enqueue() !local wakeup change in full to preserve the scheduler.rs:229-232 invariant (urgent and off-scheduler enqueues are never deferred) and avoid tail-latency risk on mixed CPU/NIF workloads.
      • Documented SEND_SCRATCH_MAX_CAP (64 KiB) drop-on-oversized behavior explicitly on prim_inet.rs.
      • Remaining normal-load raft_log gap vs BEAM (58.6% of context switches in beamrt-io-{0..3}) is deferred to Wave 3D-39 for a clean first-principles scheduler-integrated I/O polling design.
  • Idle-3s CPU (raft_log_opt, BEAMRT_SCHEDULERS=4): 0.00% (< 1% PASS).

Verification

  • ./scripts/check-aeneas-subset.sh — PASS
  • ./scripts/check-beamrt-ssot.sh — PASS
  • cargo clippy -p beamrt --all-targets -- -D warnings — PASS (0 warnings, re-verified on R2)
  • cargo test -p beamrt --lib — PASS (including all 4 new unit tests, re-verified on R2)
  • cargo test -p beamrt --test runtime_tests -- --test-threads=1 — PASS (64/64)
  • cargo test -p beamrt --test ssot_matrix_tests — PASS (6/6)

@CommaBot
CommaBot force-pushed the feat/wave3d38-beamrt branch from 13930b8 to bef0c97 Compare December 6, 2026 01:22
@CommaBot CommaBot changed the title beamrt: reuse TCP iolist flatten scratch, tighten external enqueue wakeups, and close #468 P3 items beamrt: reuse TCP iolist flatten scratch and close #468 P3 items Dec 6, 2026
@CommaBot
CommaBot merged commit 7e4e3e0 into main Dec 6, 2026
3 checks passed
@CommaBot
CommaBot deleted the feat/wave3d38-beamrt branch December 6, 2026 01:31
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.

2 participants