Skip to content

Optimize snapshot unpack by using multiple accounts directories - #245

Open
palmerlao wants to merge 4 commits into
devfrom
palmer/shard-bigfile-unpack
Open

Optimize snapshot unpack by using multiple accounts directories#245
palmerlao wants to merge 4 commits into
devfrom
palmer/shard-bigfile-unpack

Conversation

@palmerlao

Copy link
Copy Markdown
Collaborator

This change speeds up snapshot unpacking by

  1. Adding the ability to configure mithril to unpack the snapshot over multiple different directories
    • primarily useful when the machine has multiple NVMEs of different sizes and write speeds each mounted to a different directory. RAID0 can be unpredictable or inefficient in this situation
    • also changing the unpack process to use one big file per directory to hold all the appendvecs rather than storing each appendvec in its own file
    • the big file can optionally be written using O_DIRECT
  2. Improving the index log-to-SST process with pipelining and reducing the number of copies made during the sort

On my test machine I find that dev takes 15m23s to unpack a snapshot while 70f801f can unpack the same snapshot in 6m53s.

palmerlao added 4 commits July 4, 2026 04:39
Unpack coalesces the snapshot's append-vecs into one big file per disk
shard, written by an async per-shard writer fed from a pooled tar reader.
The full and incremental snapshots share a shard's "data" file (offsets
carry across the two sequential phases); a fileId encodes shard = id % N
and segment = id / N, with segment 0 the coalesced file and segment >= 2
runtime per-file append-vecs.

Records go to the least-backlogged shard by in-flight (queued) bytes,
steering toward the fastest-draining disk so throughput approaches the
disks' weighted sum; when no disk has a backlog it falls back to an even
byte split.
Sort each shard buffer in place. The stages overlap so the disk
keeps working while the CPU sorts, instead of each shard reading,
sorting, and writing serially.
Tunes how many shard buffers are sorted at once during the flush.
Ingests the flushed SSTs and asserts one entry per key at its
highest slot.
@palmerlao palmerlao changed the title Optimize snapshot unpack Optimize snapshot unpack by using multiple accounts directories Jul 6, 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.

1 participant