introduce fast mode for optimized sibling presence checks

Centralize the layer count validation into PartitionCache and track it via a new fast_mode flag. Extend query tuples to include a pre-resolved destination layer index, enabling a fast-path batch lookup that bypasses per-layer probing when enabled. Refactor neighbor iteration and hit resolution to eliminate duplication and conditionally dispatch to the optimized path based on the cache state.
This commit is contained in:
Eric Coissac
2026-08-16 21:12:05 +02:00
parent 0ce934b111
commit 693c18bfa7
4 changed files with 297 additions and 102 deletions
+6 -14
View File
@@ -132,20 +132,12 @@ fn build_layer_sibling_annex(
let n = mphf.n();
// Whether this layer's family-member fields can carry a real layer
// number (fast path, exploited by a future scan-time reader) or must
// stay presence-only (today's behaviour) — a single fact about the
// whole index, decided once here, never stored: `n_layers` is
// guaranteed identical across every partition (a merge adds one layer
// to all of them at once), and `FamilyMask`'s 3-bit field only has room
// for layers `0..=6`.
let fast_mode = meta.n_layers <= 7;
if !fast_mode {
tracing::warn!(
"layer {l} ({layer_dir:?}): index has {} layers (>7) — sibling-annex fast layer \
lookup disabled for this build; consider compacting this index",
meta.n_layers
);
}
// number (exploited by `family_scan::scan_layer_families`'s fast path)
// or must stay presence-only — a single fact about the whole index,
// decided once by `cache` (built from the same `PartitionMeta` this
// function would otherwise re-derive) so the writer and every reader
// agree; see `PartitionCache::fast_mode`'s docs.
let fast_mode = cache.fast_mode();
// ── The annex file itself is the reconciliation state, indexed by
// this layer's k-mer iteration order (the physical layout of