Repository navigation
Conversation
tamirms
force-pushed
the
tamirms/hot-ledger-compress-overlap
branch
from
October 27, 2026 10:20
d754c3c to
764b994
Compare
tamirms
force-pushed
the
tamirms/hot-ledger-compress-overlap
branch
from
October 27, 2026 11:16
764b994 to
f12f113
Compare
tamirms
force-pushed
the
tamirms/hot-ledger-compress-overlap
branch
from
October 28, 2026 08:05
f12f113 to
5886f4f
Compare
The hot loop now starts a ledger's zstd encode before its transaction walk and joins it as the last step queued into the batch, so the encode overlaps the walk and the other queue steps instead of running between them. The encode uses two libzstd threads, and the store keeps one compressor and one output buffer instead of a pool, so a ledger no longer allocates a fresh worst-case buffer when the pool has been emptied by a garbage collection. The ledger writes are now single-flight: a second StartCompress while one is in flight panics. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tamirms
force-pushed
the
tamirms/hot-ledger-compress-overlap
branch
from
November 4, 2026 10:07
5886f4f to
5fc582f
Compare
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
The hot loop now starts a ledger's zstd encode before the ledger's transaction walk, and joins it as the last step queued into the ledger's batch. The encode runs alongside the walk and the other queue steps instead of between them.
HotService.Ingestcallshotchunk.DB.StartCompressbeforeExtractLedgerTxParts.IngestLedgertakes the pending compression and joins it on every path.PhaseLedgersis now the wait for the encode plus the put.zstd.WithWorkers). The output is one standard frame, but its bytes differ from a single-threaded encode of the same input. The freeze of ledgers from the hot DB, later in this stack, makes the cold pack writer encode the same way, so a copied pack matches a built one.StartCompresswhile one is in flight panics.Tests:
TestStartCompress_OneInFlightrequires that panic, and that joining the first compression frees the store for the next.TestStartCompress_ReusesItsBufferrequires every ledger to compress into the one buffer, across garbage collections.Why
A sac-9000 ledger, with its diagnostic events, is 43 MB of XDR and 3.35 MB compressed. On the events stack, the ledgers phase, which compresses the ledger on the ingest goroutine and queues it, takes 47.2 ms of a 153.4 ms ledger at p50 (1,000 unpaced ledgers, mean of two runs). The encode needs only the ledger's bytes, so it can run while the walk does. Measured before this stack was reordered, on the stack through the SDK walk PR, which is now its top PR, the same phase takes 1.3 ms at p50 (1,000 unpaced ledgers, mean of four runs).
🤖 Generated with Claude Code