Skip to content

Conversation

@michaeljmarshall
Copy link
Member

What is the issue

Fixes: https://github.com/riptano/cndb/issues/16308

What does this PR fix and why was it fixed

When we build with the compaction graph, we have to decide the kind of postings structure. Currently, we ignore the GLOBAL_HOLES_ALLOWED percentage after graph construction, which can lead to building very large ONE_TO_MANY postings lists (which leads to increased memory consumption and graph sizes). We need to instead look at the graph stats after construction and decide if they warrant choosing the ZERO_OR_ONE_TO_MANY structure, which will put everything on disk.

Because this change could push some graphs that previously built using ONE_TO_MANY to ZERO_OR_ONE_TO_MANY, we can expect that we might see reduced hybrid search performance due to the need to go to disk more. This is a necessary change though to prevent excessive memory utilization here. Because this is a trade off without an absolute right choice, this PR makes GLOBAL_HOLES_ALLOWED configurable as a -D system property named: cassandra.sai.vector.ordinal_hole_density_limit.

@github-actions
Copy link

Checklist before you submit for review

  • This PR adheres to the Definition of Done
  • Make sure there is a PR in the CNDB project updating the Converged Cassandra version
  • Use NoSpamLogger for log lines that may appear frequently in the logs
  • Verify test results on Butler
  • Test coverage for new/modified code is > 80%
  • Proper code formatting
  • Proper title for each commit staring with the project-issue number, like CNDB-1234
  • Each commit has a meaningful description
  • Each commit is not very long and contains related changes
  • Renames, moves and reformatting are in distinct commits
  • All new files should contain the DataStax copyright header instead of the Apache License one

@michaeljmarshall michaeljmarshall requested review from a team and Copilot and removed request for pkolaczk January 21, 2026 23:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds logic to consider the GLOBAL_HOLES_ALLOWED percentage when building compaction graphs to prevent excessive memory consumption from large ONE_TO_MANY postings lists. The change evaluates graph statistics after construction to determine whether to use the ZERO_OR_ONE_TO_MANY structure (which stores data on disk) instead of ONE_TO_MANY (which uses in-memory postings). The GLOBAL_HOLES_ALLOWED threshold is made configurable via a system property.

Changes:

  • Introduced a new configurable system property cassandra.sai.vector.ordinal_hole_density_limit with a default value of 0.01
  • Added logic in CompactionGraph to check for excessive ordinal mapping holes and switch to ZERO_OR_ONE_TO_MANY structure when necessary
  • Refactored hole density checking into a dedicated method tooManyOrdinalMappingHoles() for reuse across the codebase

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/java/org/apache/cassandra/config/CassandraRelevantProperties.java Added new system property SAI_VECTOR_ORDINAL_HOLE_DENSITY_LIMIT for configuring the hole density threshold
src/java/org/apache/cassandra/index/sai/disk/v5/V5VectorPostingsWriter.java Refactored hole density check into tooManyOrdinalMappingHoles() method and updated GLOBAL_HOLES_ALLOWED to use the new configurable property
src/java/org/apache/cassandra/index/sai/disk/vector/CompactionGraph.java Added hole density check during graph flush to determine appropriate postings structure
test/unit/org/apache/cassandra/index/sai/cql/VectorCompactionTest.java Enhanced test to validate postings structure after compaction and properly restore GLOBAL_HOLES_ALLOWED value

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cassci-bot
Copy link

❌ Build ds-cassandra-pr-gate/PR-2203 rejected by Butler


4 regressions found
See build details here


Found 4 new test failures

Test Explanation Runs Upstream
o.a.c.index.sai.cql.VectorCompaction100dTest.testZeroOrOneToManyCompaction[dc false] REGRESSION 🔴 0 / 20
o.a.c.index.sai.cql.VectorCompaction2dTest.testPQRefine[ec false] (compression) REGRESSION 🔵🔴 0 / 20
o.a.c.index.sai.cql.VectorKeyRestrictedOnPartitionTest.partitionRestrictedWidePartitionBqCompressedTest[eb false] (compression) REGRESSION 🔴🔵 0 / 20
o.a.c.index.sai.cql.VectorSiftSmallTest.testMultiSegmentBuild[ca false] REGRESSION 🔴 0 / 20

Found 2 known test failures

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants