← Back to Pull requests

CNDB-18842: Fix: FusedPQ compaction should write codebook-only PQ file; add regression test #2563

Closed
unknown closed this pull request without merging on Sep 04, 2026 15:01 UTC
View on GitHub
unknown unknown commented on Aug 12, 2026 16:02 UTC
Author

…

What is the issue


...
When FusedPQ is enabled (version FA always; version FB with -Dcassandra.sai.vector.enable_fused=true), the compaction path writes the full PQVectors — codebook + all N×m per-vector codes — to the PQ component file unconditionally. The same per-vector codes are already embedded in TERMS_DATA by the graph writer. This duplicates N×m bytes on disk for every compacted SSTable, where N is the number of vectors and m is the compressed vector size.

The flush path (CassandraOnHeapGraph) was implemented correctly from the start: with FusedPQ it writes only the codebook to the PQ file.

###Impact
For a segment with N vectors and m bytes per PQ code, the wasted disk space per compacted SSTable is exactly N×m bytes — the same order of magnitude as the in-memory savings FusedPQ was designed to deliver. At 500M vectors with D=256 (m=100), this is ~47 GiB of duplicate data per compacted SSTable.

There is no correctness or memory impact at runtime: CassandraDiskAnn reads only the codebook from the PQ file when FUSED_PQ is present in the graph's feature set, so the duplicated codes are written but never read.

###Root cause
CompactionGraph.flush() calls compressedVectors.write(pqOutput, ...) unconditionally, writing full PQVectors regardless of whether FusedPQ is active. The equivalent branch in CassandraOnHeapGraph.writePQ() correctly switches to compressor.write() (codebook only) when writeFusedPQ=true.

What does this PR fix and why was it fixed


...
Apply the same writeFusedPQ branch in CompactionGraph.flush().

Diff: 196 lines (+147 / -49) across 2 files Reviewer: MarkWolters Review duration: 33058m
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 196 lines diff across 2 files
0.36
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
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.316
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2563"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% 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: 36.1% (MEDIUM) · Higher = larger blast radius
36.1%
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: 60.5% · Lower = rushed or shallow review
60.5%
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: 14.2% · Safe to merge
14.2%