← Back to Pull requests

CNDB-20422: Extend the SAI parallel graph writer to flushes, index builds, and all compactions #2856

Open
unknown opened this pull request with 443 lines diff across 5 files
View on GitHub
unknown unknown commented on Dec 01, 2026 18:00 UTC
Author

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 covers CompactionGraph, 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 (default false) for memtable flushes. When set, CassandraOnHeapGraph builds its index writer with OnDiskParallelGraphIndexWriter; 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 .enabled setting, whichever builder runs; its comment no longer calls it experimental, and its default stays false.

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_threads was 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:

  • New 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.

  • New 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 of VectorParallelFlushTest also run with the flush-specific settings (2 threads in total, direct buffers).

  • VectorTester.Versioned now 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.
  • Diff: 443 lines (+332 / -111) across 5 files Reviewer: MarkWolters Review duration: 2309m
    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
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.3% (MEDIUM) · Higher = larger blast radius
    45.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 24.2% · Safe to merge
    24.2%