Streaming N:1 compaction #659
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #659"
general
weight: 0.35
tlwillke
This PR addresses #580 that adds
OnDiskGraphIndexCompactor, a streaming N:1 compaction algorithm for merging multiple on-disk HNSW graph indexes into a single compacted index.``
`source[0].index ─┐
source[1].index ─┤──► OnDiskGraphIndexCompactor ──► compacted.index
source[N].index ─┘
java
List<OnDiskGraphIndex> sources = List.of(index0, index1, index2);
// Mark all nodes live (no deletions)
List<FixedBitSet> liveNodes = sources.stream()
.map(s -> { var bs = new FixedBitSet(s.size()); bs.set(0, s.size()); return bs; })
.collect(toList());
// Sequential ordinal remapping: source[s] node i → global offset[s] + i
int offset = 0;
List<OrdinalMapper> remappers = new ArrayList<>();
for (var src : sources) {
remappers.add(new OrdinalMapper.OffsetMapper(offset, src.size()));
offset += src.size();
}
var compactor = new OnDiskGraphIndexCompactor(
sources, liveNodes, remappers,
VectorSimilarityFunction.COSINE,
/ executor= / null // null = use by default shared threadpool in compactor
);
compactor.compact(Path.of("compacted.index"));
Benchmarking example
### Key Changes
- OnDiskGraphIndexCompactor
— core compaction algorithm with parallel ForkJoinPool execution and backpressure windowing- PQRetrainer
— balanced proportional sampling + sequential sorted reads for efficient codebook retraining- Minor API visibility changes to GraphSearcher
,GraphIndexBuilder, andPQVectorsrequired by the compactorCompactorBenchmark-
— JMH benchmark withPARTITION_AND_COMPACT,PARTITION,COMPACT, andBUILDmodes
- Unit tests covering basic compaction, deletions, ordinal remapping, and FusedPQ scenarios
### Recall
Comparison against build-from-scratch (results averaged over three runs).
- Build from scratch: build with PQ, search using FusedPQ with FP reranking.
- Compaction: build source partitions with PQ, compact using FusedPQ with FP rescoring, search using FusedPQ with FP reranking. Source partitions are based on a Fibonacci distribution with 4 partitions.
| Dataset | Dim | Build from Scratch | Compaction | Delta |
|-----------------------|-----:|-------------------:|-----------:|-------:|
| cap-6M | 768 | 0.626 | 0.619 | -0.008 |
| cap-1M | 768 | 0.656 | 0.656 | 0.000 |
| gecko-100k | 768 | 0.690 | 0.701 | +0.011 |
| e5-small-v2-100k | 384 | 0.572 | 0.586 | +0.014 |
| ada002-1M | 1536 | 0.687 | 0.703 | +0.016 |
| e5-base-v2-100k | 768 | 0.676 | 0.692 | +0.016 |
| cohere-english-v3-10M | 1024 | 0.544 | 0.561 | +0.017 |
| e5-large-v2-100k | 1024 | 0.686 | 0.703 | +0.017 |
| ada002-100k | 1536 | 0.751 | 0.769 | +0.018 |
| cohere-english-v3-1M | 1024 | 0.593 | 0.612 | +0.019 |
Recall is generally comparable to build-from-scratch and often better, though some datasets show small drops. All datasets compact successfully under -Xmx5g`; compaction has also been validated on a 2560-dim 10M-vector dataset under the same constraint.