Repository navigation
perf(vindex/kvstore): enable L6 Bloom filters, partition by KeyHash, and tune Pebble backfill - #204
Merged
mhutchinson merged 1 commit intoDec 1, 2026
Conversation
…and tune Pebble backfill
During large CT log backfills (e.g. Sycamore 2026h1 at 926M entries / 67 GB Pebble),
ingestion throughput degraded once Pebble compacted into L6 due to two compounding
issues in kvstore:
1. Missing IterOptions{UseL6Filters: true}: store.go configures 10-bit table Bloom
filters across all 7 levels (L0..L6), but NewIter(nil) leaves UseL6Filters=false,
causing Pebble to skip Bloom filters on L6 (which holds ~90% of the LSM) and
read 4 KiB L6 data blocks on every absent/ephemeral key.
2. Canonical-string worker partitioning: KVIndexer sorted and partitioned slabs by
canonical key string rather than SHA-256 KeyHash, causing every worker to issue
random SeekPrefixGE jumps across the full [0x00..0xFF] SSTable keyspace and stage
pebble.Batch writes out of key order.
Changes:
- Opt into UseL6Filters: true on DB.Lookup and KVIndexer iterators (retaining nil
IterOptions on GetKeyValueRoots recovery replay where queried keys exist).
- Partition and sort KVIndexer.buildBatchMutations and GetKeyValueRoots by SHA-256
KeyHash across workers so each worker scans a disjoint SSTable range forward and
stages chunk writes in strictly ascending Pebble key order.
- Eliminate per-key heap clones on warm non-staged IndexMappedBatch hits, reuse
worker marshal/write buffers, validate canonical keys directly on string, and
skip slices.Clone when input leaf indices are already strictly increasing.
- Double default per-generation active chunk cache capacity (131,072 -> 262,144),
raise default CommitBatchSize (4,096 -> 16,384), skip redundant in-RAM bundle
cloning when TileCacheDir is empty, and expose KVIndexer/Pebble tuning flags on
vindexd.
Benchmarks (linux/amd64, Intel Xeon @ 2.20GHz):
- BenchmarkLookup_AbsentKey_FlushedSSTables-24:
5,398 ns/op -> 4,671 ns/op (-13.5%), 168 B/op -> 168 B/op, 4 -> 4 allocs/op
- BenchmarkKVIndexer_IndexBatch_1000Keys/workers_1-24:
7,354,744 ns/op -> 6,301,465 ns/op (-14.3%), 1,060,455 B/op -> 603,012 B/op (-43.1%), 7,298 -> 1,195 allocs/op (-83.6%)
- BenchmarkKVIndexer_IndexBatch_1000Keys/workers_8-24:
5,065,942 ns/op -> 4,529,381 ns/op (-10.6%), 1,624,022 B/op -> 675,143 B/op (-58.4%), 7,476 -> 1,203 allocs/op (-83.9%)
- BenchmarkKVIndexer_ColdCache_L6SSTables/workers_1-24:
20,830,985 ns/op -> 17,270,191 ns/op (-17.1%), 2,164,727 B/op -> 2,105,405 B/op (-2.7%), 19,845 -> 16,911 allocs/op (-14.8%)
- BenchmarkKVIndexer_ColdCache_L6SSTables/workers_8-24:
11,531,944 ns/op -> 10,517,247 ns/op (-8.8%), 2,910,006 B/op -> 2,403,483 B/op (-17.4%), 20,511 -> 17,840 allocs/op (-13.0%)
- BenchmarkKVIndexer_GetKeyValueRoots_L6SSTables-24:
2,831,966 ns/op -> 2,596,947 ns/op (-8.3%)
patflynn
approved these changes
Nov 30, 2026
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.
Why
While benchmarking
vindexd(ct.wasm) against Let's Encrypt Sycamore 2026h1 (926M entries, 1.48B key occurrences, 67 GB Pebble DB), ingestion throughput degraded from ~81k leaves/s early on to ~6.4–8.5k leaves/s once Pebble compacted into L6 (with active CPU collapsing from 9.5 to 2.0 cores andSyscall6rising to 28.4%).Two compounding issues in
kvstoredrove the late-stage I/O wall:kvstore/store.gowrites 10-bit table Bloom filters on all 7 Pebble levels (L0..L6), butNewIter(nil)leavesUseL6Filters: false. In Pebble v1.1.5 (table_cache.go:511), the bottommost LSM level is always L6 (~90% of a large DB), so every brand-new domain (~60% of keys per CT slab) bypassed Bloom filters and triggered a 4 KiB L6 SSTable data-block read.KeyHashSSTable thrashing across workers:KVIndexer.buildBatchMutationssorted and partitioned slabs by canonical key string ("com.a...") rather than SHA-256KeyHash, causing all workers to issue randomSeekPrefixGE('c' || KeyHash)jumps across the entire SSTable keyspace and stagepebble.Batchwrites out of key order.What Changed
pebble.IterOptions{UseL6Filters: true}onDB.LookupandKVIndexerwrite-path iterators (verified via PebbleFilter.HitsinTestDB_L6BloomFiltersEnabled), keepingnilIterOptionsonGetKeyValueRootsrecovery replay where queried keys exist.KeyHashradix partitioning & sorted batch writes: Partition and sortKVIndexer.buildBatchMutationsandGetKeyValueRootsby SHA-256KeyHashacross workers (capped at 256 workers for dense 1-bytehash[0]bucketing) so each worker scans a disjoint SSTable range monotonically forward and stages chunk writes in strictly ascending'c' + KeyHash + ^chunkNumorder.IndexMappedBatchpaths (withClearCache()on error), reuse per-worker marshal/write buffers, validate canonical keys directly onstring(wire.ValidateCanonicalKeyString), pre-sizeRelativeIndices, and skipslices.Clonewhen leaf indices are already strictly increasing.131,072 -> 262,144), raise defaultCommitBatchSize(4,096 -> 16,384), skip redundantManagedTileCachein-RAM bundle cloning whenTileCacheDir == ""(matchingauditor.go), and expose--kv_indexer_workers,--kv_chunk_cache_size,--db_memtable_size_mb,--db_l0_compaction_threshold, and--db_max_concurrent_compactionsonvindexd(with overflow guards).Benchmarks (
linux/amd64, Intel Xeon @ 2.20GHz)main)Lookup_AbsentKey_FlushedSSTables5,398 ns/op(168 B,4 allocs)4,671 ns/op(168 B,4 allocs)IndexBatch_1000Keys/workers_17.35 ms/op(1,060 KB,7,298 allocs)6.30 ms/op(603 KB,1,195 allocs)IndexBatch_1000Keys/workers_85.07 ms/op(1,624 KB,7,476 allocs)4.53 ms/op(675 KB,1,203 allocs)ColdCache_L6SSTables/workers_120.83 ms/op(2,165 KB,19,845 allocs)18.52 ms/op(2,134 KB,17,024 allocs)ColdCache_L6SSTables/workers_811.53 ms/op(2,910 KB,20,511 allocs)10.06 ms/op(2,404 KB,17,944 allocs)GetKeyValueRoots_L6SSTables2.83 ms/op(995 KB)2.80 ms/op(1,327 KB, sorted forward scans)Verification
go vet ./...CGO_ENABLED=0 go test ./vindex/...go test -race ./vindex/...