Skip to content

replay: overlap execution and improve checkpoints and epoch recovery - #292

Draft
7layermagik wants to merge 116 commits into
7layer/execution-performancefrom
7layer/streaming-execution-overlap
Draft

7layermagik wants to merge 116 commits into
7layer/execution-performancefrom
7layer/streaming-execution-overlap

Conversation

@7layermagik

@7layermagik 7layermagik commented Sep 24, 2026 •

Copy link
Copy Markdown

Reduce replay work after complete block assembly by combining prepared status publication, deferred checkpoints and execution during shred arrival. Include the epoch-recovery correctness fixes required by this replay stack.

  • Prepare immutable transaction-status deltas and recheck lineage, coverage, offsets and duplicates at commit. Cache immutable checkpoint encodings and defer checkpoint work without premature durable-root advancement.
  • Preserve credits observed for fully cooled stake accounts and atomically checkpoint completed reward-distribution state only after verified completion. Retain the epoch-116 regression fixture and Shaun's authored fixes.
  • Execute validated prefixes during shred arrival, with the complete emitted block remaining the object finalized and voted on. Validate prefix identity and discard on parent, generation, error or fork-switch mismatch.
  • Preserve vote/stake publication ownership and whole-block fallback; include bounded repair wakeups and child blocking-gap repair with delay diagnostics.

Combines the scopes of #286, #289 and #292. Based on execution #281, whose integration base contains Turbine/production #287 and voting #288. Those prerequisite changes are excluded from this diff. Retarget after prerequisites merge. Kept draft for combined replay, cancellation and recovery review.

Validation: this consolidation is source-identical to 4df83876 (and c1f71346); only ancestry changed. Replay/rewards, epoch fixtures and prerequisite suites passed during regrouping. The consolidation adds no deployment or new live performance claim and does not repeat complete end-to-end streaming validation. Historical checkpoint encoding improved from roughly 195 to 85 ms at the default cadence; that measures encoding work, not voting latency.

7layermagik and others added 30 commits September 15, 2026 20:37
Share lazy encoding state through capture and pruning without retaining parent links or copying synchronization primitives. Keep MTS2 bytes and caller-owned output unchanged; allocate exactly sized node and checkpoint buffers.

Check the original wire encoder, concurrent pruning and encoding, output ownership and recovery. Benchmark moving windows including the default 128-root cadence; document retained-memory costs and the all-new-window limit.
Record moving-window results at the real 128-root cadence, retained-memory tradeoffs and unchanged cold-window costs. Keep raw benchmark artifacts outside the source tree; do not infer live voting gains from staging measurements.
…en transfer)

Consensus-neutral performance changes to pkg/sbpf, validated against the
unmodified interpreter with a 100k-program differential corpus (identical
return values, errors/PCs, CU consumed, meter remaining, memory contents,
input-region state) plus the package's unit tests:

- meter instructions with a local due/budget pair synced around syscalls
  and on exit (Agave's due_insn_count scheme) instead of calling
  ComputeMeter.Consume per instruction
- move cold opcodes to executeCold so Run drops below the compiler's
  "big function" threshold and Consume/Read*/Push/Pop/fast paths inline
- zero only the dirty range of the pooled stack/heap in Finish (page
  bitmap on the fast path, byte range on the translate path) instead of
  256 KiB + HeapMax per execution
- per-window fast-path address translation table (Agave aligned mapping
  layout, branch-free v0 frame gaps, one-entry cache for VASA input regions)
- 16-wide register file (no bounds checks on r[dst]/r[src]), in-place
  call-frame Push/Pop, precomputed internal call targets per Program

pooling_test writes through the VM's translation layer now, since the pool
only re-zeroes memory the VM saw written (all production writes go through
translation).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ctTQDHudYoF3FhmgmvY2y
- perf_bench_test.go: synthetic ALU / load-store / call loops and
  interpreter setup+teardown
- loader/token_perf_bench_test.go: real SPL Token Transfer through the
  loader/verifier/interpreter with sealevel-equivalent syscalls, in the
  aligned and VASA input layouts
- perf_differential_test.go: deterministic random program corpus; run on
  two builds with SBPF_DIFF_OUT=<file> and diff the outputs;
  SBPF_CHECK_POOL_ZERO=1 asserts pooled buffers come back zeroed

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ctTQDHudYoF3FhmgmvY2y
…TowerSync)

Measured through ExecutionCtx.ProcessInstruction so instruction-context
push/pop, lamport-sum checks and timing metrics are included; each has a
NoTiming variant (SkipTimingMetrics) to quantify instrumentation cost, plus
a vote-state (de)serialization round trip. NOTE: written without a local
build of pkg/sealevel (sandbox cannot fetch its dependencies); expect to
fix compile errors on first run.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ctTQDHudYoF3FhmgmvY2y
7layermagik and others added 22 commits September 24, 2026 00:17
…en transfer)

Consensus-neutral performance changes to pkg/sbpf, validated against the
unmodified interpreter with a 100k-program differential corpus (identical
return values, errors/PCs, CU consumed, meter remaining, memory contents,
input-region state) plus the package's unit tests:

- meter instructions with a local due/budget pair synced around syscalls
  and on exit (Agave's due_insn_count scheme) instead of calling
  ComputeMeter.Consume per instruction
- move cold opcodes to executeCold so Run drops below the compiler's
  "big function" threshold and Consume/Read*/Push/Pop/fast paths inline
- zero only the dirty range of the pooled stack/heap in Finish (page
  bitmap on the fast path, byte range on the translate path) instead of
  256 KiB + HeapMax per execution
- per-window fast-path address translation table (Agave aligned mapping
  layout, branch-free v0 frame gaps, one-entry cache for VASA input regions)
- 16-wide register file (no bounds checks on r[dst]/r[src]), in-place
  call-frame Push/Pop, precomputed internal call targets per Program

pooling_test writes through the VM's translation layer now, since the pool
only re-zeroes memory the VM saw written (all production writes go through
translation).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ctTQDHudYoF3FhmgmvY2y
- perf_bench_test.go: synthetic ALU / load-store / call loops and
  interpreter setup+teardown
- loader/token_perf_bench_test.go: real SPL Token Transfer through the
  loader/verifier/interpreter with sealevel-equivalent syscalls, in the
  aligned and VASA input layouts
- perf_differential_test.go: deterministic random program corpus; run on
  two builds with SBPF_DIFF_OUT=<file> and diff the outputs;
  SBPF_CHECK_POOL_ZERO=1 asserts pooled buffers come back zeroed

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ctTQDHudYoF3FhmgmvY2y
…TowerSync)

Measured through ExecutionCtx.ProcessInstruction so instruction-context
push/pop, lamport-sum checks and timing metrics are included; each has a
NoTiming variant (SkipTimingMetrics) to quantify instrumentation cost, plus
a vote-state (de)serialization round trip. NOTE: written without a local
build of pkg/sealevel (sandbox cannot fetch its dependencies); expect to
fix compile errors on first run.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ctTQDHudYoF3FhmgmvY2y
…e loops

sol_memcpy_/sol_memmove_ read the source into a fresh heap buffer and wrote
it back; the copy now goes directly between the two translated slices with
Go's memmove-semantics copy (overlap handled, source translated first so
error precedence is unchanged, and a copy-on-write/growth of the
destination region still reads the pre-write bytes because the source slice
keeps the previous backing buffer alive). sol_memcmp_ uses bytes.Equal for
the common equal case and word-skips to the first differing byte otherwise;
sol_memset_ uses clear for zero and a doubling copy for other values. An
SPL Token transfer issues two memcpy and four memcmp calls, so this is a
small, allocation-free win rather than a large one.

Tests: memcmpResult against the previous byte loop on 100k random inputs,
memsetBytes over sizes and values, and VM-level memmove/memcpy overlap,
error-ordering, copy-on-write-region and memcmp/memset checks.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ctTQDHudYoF3FhmgmvY2y
LtHash.MixIn/MixOut are 1024-lane uint16 add/subtract loops that run twice
per modified account in the accounts delta hash (once for the old value,
once for the new). The scalar loop costs ~560 ns per call in the sandbox
and roughly 350 ns on Zen 5, so a block with ~10k modified accounts spends
several milliseconds of worker CPU on lane arithmetic alone.

On amd64 with AVX2 the lanes are now mixed with VPADDW/VPSUBW, 16 lanes per
instruction, four vectors per iteration, unaligned loads and stores
(28 ns per call here, 20x). Dispatch is a package variable set from
cpu.X86.HasAVX2 (golang.org/x/sys is already a direct dependency); other
architectures, CPUs without AVX2 and the purego build tag keep the
portable loops, which remain the reference. Equals now compares the two
arrays directly (runtime memequal) instead of a lane loop.

Tests compare the assembly and the dispatched functions against the
portable loops on random lanes including wrap-around values, check that
MixOut inverts MixIn, that aliased operands behave, and that the generic
fallback is selectable; go vet's asmdecl check passes and the package
builds under -tags purego and GOARCH=arm64.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ctTQDHudYoF3FhmgmvY2y
Preserve the exact c1f7134 source tree. The new prerequisite stack contains the earlier code plus upstream epoch fixes and execution review corrections already present here; this merge changes review ancestry only.
@7layermagik
7layermagik force-pushed the 7layer/execution-performance branch from 52a1aad to a317eb6 Compare September 24, 2026 05:37
@7layermagik 7layermagik changed the title replay: overlap incremental execution with shred arrival replay: overlap execution and improve checkpoints and epoch recovery Sep 24, 2026
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.

3 participants