Skip to content

Optimizations for Soroban LTX commit path. - #5418

Merged
dmkozh merged 1 commit into
stellar:masterfrom
dmkozh:commit_to_ltx2
Oct 21, 2026
Merged

dmkozh merged 1 commit into
stellar:masterfrom
dmkozh:commit_to_ltx2

Conversation

@dmkozh

@dmkozh dmkozh commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Description

Optimizations for Soroban LTX commit path.

This includes several micro-optimizations that have a significant impact on the Soroban LTX commit stage performance (~-40ms on large TPL benchmarks; surprisingly much more impact than parallelization change this is based on):

  • Replace several hot path copies with moves
  • Avoid unnecessary LTX loads that were only needed to distinguish between INIT and LIVE entries; propagate a flag that distinguishes these instead
  • Get rid of an unnecessary inner LTX in commitChangesToLedgerTxn

Checklist

  • Reviewed the contributing document
  • Rebased on top of master (no merge commits)
  • Ran clang-format v8.0.0 (via make format or the Visual Studio extension)
  • Compiles
  • Ran all tests
  • If change impacts performance, include supporting evidence per the performance document

@dmkozh
dmkozh force-pushed the commit_to_ltx2 branch 5 times, most recently from 77746b7 to 2d94b36 Compare October 20, 2026 16:07
@dmkozh
dmkozh marked this pull request as ready for review October 20, 2026 16:07
Copilot AI balanced review requested due to automatic review settings October 20, 2026 16:07
@dmkozh
dmkozh requested a review from graydon October 20, 2026 16:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Consensus-sensitive entry classification and transaction-boundary changes warrant human review and regression-test confirmation.

No open issues 🎉

What changed in this PR

Optimizes Stellar Core’s Soroban ledger commit path by reducing copies, redundant lookups, and nested transaction overhead.

Changes:

  • Moves entry payloads through transaction, thread, and global state.
  • Tracks whether entries are new to avoid existence lookups.
  • Commits directly to the destination ledger transaction.
File Description
src/​transactions/​ParallelApplyUtils.h Updates consuming commit interfaces and documentation.
src/​transactions/​ParallelApplyUtils.cpp Implements moves, entry classification, and direct commits.
src/​transactions/​ParallelApplyTypes.h Adds entry-origin tracking and mutable result access.
src/​ledger/​test/​InMemoryLedgerTxn.h Declares move-aware test ledger overrides.
src/​ledger/​test/​InMemoryLedgerTxn.cpp Preserves key tracking during moved writes.
src/​ledger/​LedgerTxnImpl.h Declares move-aware internal operations.
src/​ledger/​LedgerTxn.h Exposes move-aware write overloads.
src/​ledger/​LedgerTxn.cpp Moves entries and avoids redundant map allocations.
src/​ledger/​LedgerManagerImpl.cpp Transfers successful results into thread state.
src/​ledger/​LedgerEntryScope.h Declares scoped payload extraction.
src/​ledger/​LedgerEntryScope.cpp Implements scope-checked payload moves.
src/​ledger/​InternalLedgerEntry.h Declares a move-aware entry constructor.
src/​ledger/​InternalLedgerEntry.cpp Implements entry payload movement.

Review effort: Balanced

graydon
graydon previously approved these changes Oct 21, 2026

@graydon graydon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty delicate stuff! I spent a while reviewing it and discussing with LLMs and believe it's all correct, but a little accident-prone. So I added a few more commits that make it a little less dangerous (refactoring a bit, adding more tracking machinery for moves, tightening the active tracking).

This includes several micro-optimizations that have a significant impact on the Soroban LTX commit stage performance (~-40ms on large TPL benchmarks; surprisingly much more impact than parallelization change this is based on):

- Replace several hot path copies with moves
- Avoid unnecessary LTX loads that were only needed to distinguish between INIT and LIVE entries; propagate a flag that distinguishes these instead
- Get rid of an unnecessary inner LTX in commitChangesToLedgerTxn

@graydon graydon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@dmkozh
dmkozh added this pull request to the merge queue Oct 21, 2026
Merged via the queue into stellar:master with commit b5701f4 Oct 21, 2026
68 of 82 checks passed
@dmkozh
dmkozh deleted the commit_to_ltx2 branch October 21, 2026 19:32
SirTyson added a commit to SirTyson/stellar-core that referenced this pull request Nov 9, 2026
Brings overlay-v2-shared up to date with master. The previous master
merge (b90d48e, stellar#5428) was recorded with master's tip 100cc38 missing
from its parents, so this merge used 100cc38 as its base (temporary
graft of b90d48e, removed afterwards).

Notable master changes brought in:
- Protocol 30: CURRENT_LEDGER_PROTOCOL_VERSION follows
  MAX_SUPPORTED_PROTOCOL_VERSION; CAP-0084 and CAP-0087 ungated, p29 and
  p30 Soroban hosts (stellar#5472, stellar#5478, stellar#5484, stellar#5483).
- Millisecond-resolution close times at protocol 30 (stellar#5423):
  ConsensusTime/ApplyTime types, STELLAR_VALUE_SIGNED_MS and
  STELLAR_VALUE_EMPTY_TX_SET_MS.
- Tx set validity hardening (stellar#5481), lower max message size in protocol
  29 (stellar#733), sub-second ledger edge-case fixes.
- Simplified ledger view hierarchy (stellar#5461); the overlay-only-mode
  sequence number skip now lives in TransactionFrame::checkValid.
- Banned accounts deprecated (CAP-0077 is active).
- Apply-path performance work (stellar#5402, stellar#5411, stellar#5414, stellar#5415, stellar#5418, stellar#5421,
  stellar#5436, stellar#5286), apply-load tx set construction mode (stellar#5448), --check-lcm
  (stellar#5435), v29.0.0 release merge.

Conflict resolution:
- Files overlay-v2-shared deleted and master modified (the C++ overlay,
  TransactionQueue, TransactionQueueTests, UpgradesTests, private/Horizon/RPC
  workflows): kept deleted. Master's changes to them are C++ overlay
  peer/flow-control logic, tx queue admission and tests for those.
- Herder: kept the Rust-overlay submission path (recvTransaction returns
  TxSubmitStatus) and dropped the deprecated `force` parameter as master did.
  triggerNextLedger keeps the prepared/built tx set path from the Rust
  mempool, now with ConsensusTime close times and master's apply-time
  close-time offset. The early tx set preparation path (prepareTxSet,
  buildTxSet, setupTriggerNextLedger) takes ConsensusTime. Kept master's
  mNominatedTxSetOverride test hook (applied before the tx set is cached in
  the Rust overlay) and the herder.txset.build timer (now timing
  buildTxSet). Dropped the banned-accounts setup and tx queue maintenance.
- AppConnector: dropped both ov2's maybeUpdateImmutableLedgerView and
  master's C++-overlay getOverlayThreadSnapshot.
- LoadGenerator: master's CachedTestAccountPtr with ov2's TxSubmitStatus.
- Tests: kept ov2's removal of tests that need the C++ overlay, standalone
  mode or the tx queue (standalone, manualclose, flooding, tx queue limits,
  far-future slot cleanup, herderExternalizesValuesWithProtocol, MAX_SAC_TPS,
  custom token, soroswap and noisy binary search apply-load tests). Added
  master's ms close time HerderTests and the non-canonical empty tx set test
  on ov2's Rust-overlay topologies. The tx set size test checks against
  overlay-v2's own tx set allowance. The sub-second
  getUpperBoundCloseTimeOffset test checks the offset directly, since there
  is no C++ tx queue admission. Tests that used CheckValidLedgerViewWrapper
  now use getLCLView().
- Cargo.lock: master's lockfile plus the overlay crate's packages,
  regenerated by cargo; semver-compatible duplicates take the newer
  version.
- Build: Makefile.am keeps the Rust overlay rules and adds tracy
  import-chrome; ci-build.sh keeps ASAN off and takes master's -g1.
- Needed to compile: PendingEnvelopes.cpp includes LedgerManager.h
  (master got it through the C++ OverlayManager.h); ov2's early-nomination
  and checkpoint-slot tests use ConsensusTime/ApplyTimeOffset; OverlayIPC
  tests take ledger views from the LedgerManager.
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