CNDB-20422: Extend the SAI parallel graph writer to flushes, index builds, and all compactions #2856
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 443 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 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.365
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #2856"
general
weight: 0.35
MarkWolters
What is the issue
riptano/cndb#20422. SAI writes a vector index's graph with JVector's sequential writer at memtable flush and at index build (
CassandraOnHeapGraph.createIndexWriter), so the write runs on one core. Compaction can already use JVector's parallel writer (cassandra.sai.vector.encode_and_write_graph_in_parallel.enabled), which produces the same on-disk format. Compaction's parallel writer only coversCompactionGraph, so compactions that build the graph on heap (before PQ exists, or with LTM off) still write sequentially.What does this PR fix and why was it fixed
Adds
cassandra.sai.vector.encode_and_write_graph_in_parallel.flush.enabled(defaultfalse) for memtable flushes. When set,CassandraOnHeapGraphbuilds its index writer withOnDiskParallelGraphIndexWriter; the rest of the writer setup is unchanged. The setting is separate from the compaction one so that each can be turned off on its own. Graphs built from sstables (index builds, compactions, streaming) now follow compaction's.enabledsetting, whichever builder runs; its comment no longer calls it experimental, and its default staysfalse.At flush, the writer's thread count comes from
.flush.num_threads, a node-wide total (default half the available processors) split evenly across the flushes that can run at once, and its buffer type from.flush.use_direct_buffers, else compaction's.use_direct_buffers, so flushes and compaction can be tuned separately without changing existing configurations.Measured on an AWS r6id.4xlarge (16 vCPUs) with live ingestion and the compaction writer on in both runs:
| Dataset | Total flush graph-write time, sequential → parallel | Longest flush graph write |
|---|---|---|
| cohere-wiki 10M (1,024 dims) | 784 s → 176 s | 51.6 s → 10.8 s |
| ibm-datapile 10M (384 dims) | 605 s → 96 s | 74.0 s → 11.1 s |
| wiki-mpnet 10M (768 dims) | 725 s → 144 s | 57.9 s → 11.3 s |
| CAP 6M (1,536 dims) | 493 s → 135 s | 39.7 s → 9.7 s |
These runs predate the node-wide thread total; each flush used 8 threads (compaction's
.num_threadswas set to 8).Each flush finishes sooner (about 50 s instead of 80 s per flush on cohere-wiki 10M), so a flushing memtable's memory is released sooner, leaving more headroom before writes block when ingest outpaces flushing. In these runs ingest was limited by graph insertion, so load time did not change.
An index build's first (on-heap) segment was written 4-6x faster. Recall was unchanged, with no write timeouts either way.
Tests:
VectorParallelFlushTest: for each SAI version, NVQ, FusedPQ and hierarchy setting, writes a segment at flush and at index build with both writers, and checks every row's vector at its ordinal, the expected features and recall. The "with holes" cases add rows without a vector, rows sharing a vector, overwrites and deletes, which leave new ordinals with no vector that the writer must write as placeholders.ParallelFlushWriterSettingsTest: a memtable's graph follows the flush setting and a graph built from sstables follows compaction's; the flush thread total is split across concurrent flushes (at least 1 each); the buffer setting falls back to compaction's when unset. The "with holes" flush cases ofVectorParallelFlushTestalso run with the flush-specific settings (2 threads in total, direct buffers).VectorTester.Versionednow also enables the flush writer for the FusedPQ cases, as it already does for compaction's writer, so the existing versioned vector tests cover it too.