Repository navigation
perf(node): move the accepted LaneState into the lane instead of cloning it (#1792 item 3) - #1872
Merged
Merged
Conversation
…ing it Group E item 3 (independent half) of the serve-path hot-path audit (#1792): each accepted voucher/preimage cloned the verified candidate `LaneState` into the lane guard and then passed the same value to `channel_state_store.record`, which clones it again — two full clones per proof, both under the per-lane lock. Move the candidate into `guard.state` and have `record` borrow it from there, so the proof clones once (the store's internal clone) rather than twice. `LaneState` is `Clone`, not `Copy`, so this genuinely elides one duplication; `verified.{new_bytes,amount}` are `Copy`, so the partial move leaves them readable. The preimage path hoists its O(1) receipt-amount read above the move for the same reason. The remaining clone lives inside the store's `record` and is coupled to the buffer-resharding item (#1792 item 1); it is left for that change. Behavior is unchanged — a pure move-vs-clone refactor. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_013MSiZrVoUQzy4J5Ci8RGEu
There was a problem hiding this comment.
Pull request overview
This PR reduces per-proof overhead in the node’s paid delivery accept path by eliminating an extra LaneState clone taken under the per-lane lock. It does so by moving the verified candidate state into the lane (guard.state) and then recording the store state by borrowing from the lane, while preserving existing acceptance logic and store behavior.
Changes:
- Move
verified.next_stateintoguard.statein the voucher accept path and pass&guard.statetochannel_state_store.record(). - In the preimage accept path, compute the receipt
amountbefore movingnext_stateinto the lane, then record via&guard.state.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Coverage reportTotal: 82.09% (was 82.10%, ● 0.00%) — 68205/83083 lines
History
|
yigitdot
added a commit
that referenced
this pull request
Aug 30, 2026
One conflict, in `dispatch.rs`'s `use super::{…}` list. Main's per-lane
perf work (#1870/#1872/#1873) dropped `Mutex` from it when the accepted
`LaneState` moved into the lane instead of being cloned; this branch had
added `FloorRefusalSite` for the split refusal logging. Took the union:
main's list, minus `Mutex` (no remaining use in the file), plus
`FloorRefusalSite`.
Everything else auto-merged, including both serve loops where the perf
commits and this branch's floor calls are adjacent. Verified the floor
surface survived intact: `release_if_repaid` and the pool-only mid-stream
re-check in `delivery.rs` / `serve_leg.rs`, both admission gates and the
refusal logging in `dispatch.rs`, and the accumulator itself.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.
What
Addresses the independently-achievable half of item 3 of #1792 (Group E of the serve-path hot-path audit): "Two
LaneStateclones per accepted proof, both under locks."Each accepted voucher/preimage did:
— two full
LaneStateduplications per proof, both inside the per-lane critical section.Change
Move the verified candidate into
guard.stateand haverecordborrow it from the lane:LaneStateis#[derive(Clone)]— notCopy— so this genuinely elides one duplication rather than being a no-op.verified.{new_bytes,amount}areCopy, so the partial move leaves them readable for the credit/receipt bookkeeping below. The preimage path hoists its O(1) receipt-amount read (next_state.owed()) above the move for the same reason.Applied to both the voucher path (
commit_one_proof) and the preimage path (commit_one_preimage).Scope
The remaining clone is the one inside the store's
record()(let mut next = state.clone()), which exists to reconcileregistered_untilagainst the buffered copy. That one is coupled to the process-globalLaneBufferand is the item 1 (buffer-resharding) change's to remove — left untouched here so this PR stays a small, self-contained, behavior-preserving refactor.Correctness
Pure move-vs-clone: the stored
LaneStateand every downstream read are byte-identical to before; only the redundant intermediate copy is gone. No change to payment logic, lock scope order, or the durable record.Testing
cargo build -p decdn-node— cleancargo clippy -p decdn-node --all-targets— clean (no anti-panic policy violations)cargo test -p decdn-node --lib— 771 passedcargo test -p decdn-node --test client_loopback -- voucher preimage reveal chain capabilit— 16 passed (full accept-path coverage: voucher advance, hash-chain reveals, capability gating)cargo fmt --checkandcargo doc --workspace --no-deps --document-private-items(-D warnings) — cleanCloses #1792 item 3 (partial — the store-internal clone is deferred to item 1).
🤖 Generated with Claude Code
https://claude.ai/code/session_013MSiZrVoUQzy4J5Ci8RGEu
Generated by Claude Code