Repository navigation
perf(dataplane): steady-state fast path at the response point (v5 S2c, default-off) - #317
Merged
Merged
Conversation
…, default-off) Extends the S2b command-point inline fast path to the response-ACK point. For a steady command whose response packet is already flushed to the client, the `events`→loop→`await_effect(ForwardResponseToClient)` round-trip is pure FSM bookkeeping with no I/O, so it can be committed inline under the core lock. Because the command's own forward permit is held across `response_rounds` (`pending >= 1`), the S2b `pending == 0` gate is unreachable here. Instead a new core API `try_inline_commit_excluding(&fwd_permit, event, expected, shutdown)` takes the command's permit as a capability/liveness witness: Rust's borrow proves it is not dropped, `Arc::ptr_eq` proves it belongs to this core, so `pending == 1` means that single registration is exactly this permit and nothing else is outstanding (no redirect/drain/control/in-flight sync). The identity check, open/shutdown read, speculative clone transition, exact-effect match and write-back all run in one lock critical section; no raw `pending` escapes (no TOCTOU). The inline commit registers NO new permit — the already-flushed packet means no post-commit I/O and `fwd_permit` keeps the floor. A same-core identity mismatch, `pending != 1`, a sealed/shutdown core or an effect mismatch all fall back to the unchanged slow path. `LocalInfile` (different ack) always takes the slow path. Prepared/cursor commands keep an in-flight sync permit so `pending` is >= 2 and they fall back automatically. Default-off behind `TIPROXY_FSM_FASTPATH`. Flag-off keeps the exact slow-path permit lifetime (ack permit held to the end of the loop iteration). Verified: fast-path on/off wire traces byte-identical; the response point fires once per single-packet-response command under the flag (0 off); all dataplane suites, fmt and clippy clean. New gate tests cover the inline commit (no new permit, same FSM state as the slow transition, terminal round too) and every fallback (pending != 1, wrong-gate witness, sealed, shutdown, effect mismatch). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
bb7133
force-pushed
the
perf/fastpath-s2c-response
branch
from
October 7, 2026 11:48
f2dac10 to
49e7d57
Compare
bb7133
marked this pull request as ready for review
October 7, 2026 16:07
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.
Stacks conceptually on S2b (command point, merged
2ec605dc). Extends the inline fast path to the response-ACK point, default-off behindTIPROXY_FSM_FASTPATH.Why
Measured on current main: for the online write-heavy / small-single-packet-response model, each command has ~1 non-opt#5-bypassed
await_effect(ForwardResponseToClient)round-trip — the same magnitude as the command-forward round-trip that S2b fast-pathed for −6.9% CPU. The response packet is already flushed to the client (session_engine.rs:3646) before this round-trip, so it is pure FSM bookkeeping with no I/O.Mechanism (design converged with CodexM5)
The command's own forward permit is held across
response_rounds(pending >= 1), so S2b'spending == 0gate is unreachable. New core APItry_inline_commit_excluding(&fwd_permit, event, expected, shutdown):fwd_permitis a capability/liveness witness — Rust's borrow proves it is not dropped;Arc::ptr_eqproves it belongs to this core, sopending == 1means that single registration is exactly this permit (no redirect/drain/control/in-flight sync).pendingescapes → no TOCTOU).fwd_permitkeeps the floor.pending != 1/ sealed / shutdown / effect mismatch → unchanged slow path.LocalInfilealways slow. Prepared/cursor commands keep an in-flight sync (pending >= 2) → auto-fallback.Verification
scripts/fastpath-trace-ab.sh).Hit-rate / CPU A/B on a production-like workload is a separate measurement step (as #146 was for S2b).
🤖 Generated with Claude Code