Repository navigation
Conversation
A build writes the whole index through the page cache and syncs once at the end, so a large index's dirty pages pile up and go to disk in bursts that hold up other writers' fsyncs on the same disk. WithBytesPerSync(n) starts writeback every n bytes written (sync_file_range without waiting, on Linux; a no-op elsewhere). The index built is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DjQed1VX9uGU9PWpAjBiz7
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.
A build writes the whole index through the page cache and syncs once at the end. For a large index the dirty pages pile up and reach the disk in bursts, and while a burst drains, other writers' fsyncs on the same disk wait behind it.
WithBytesPerSync(n)starts writeback of the file everynbytes written. On Linux that issync_file_rangewithSYNC_FILE_RANGE_WRITE, which returns without waiting; elsewhere the option does nothing. The finalSyncstill makes the file durable, and the index is byte-identical with or without the option: the new test builds on 1 and 4 workers with writeback every 1 KB. The default stays 0, which leaves writeback to the kernel.In stellar-rpc, ingestion fsyncs a RocksDB WAL for every ledger while the tx-hash index builds on the same NVMe. With a 4.3 billion key (18.6 GB) index building back to back and writeback every 1 MB, the ingestion commit's p99 went from 44.6 ms to 26.3 ms, the same as with no build running, and a ledger's p99 from 103.8 ms to 94.6 ms. The build itself took 153 s, against 151 s without the option.
The unsorted builder's temporary partition files are not covered. They are unlinked while open and never synced, so forced writeback only helps them when they are large enough to reach the disk anyway.
🤖 Generated with Claude Code