Skip to content

Add volatile multi dense vector storage#6564

Merged
timvisee merged 2 commits intodevfrom
vector-storage-multi-dense-volatile-test
May 21, 2025
Merged

Add volatile multi dense vector storage#6564
timvisee merged 2 commits intodevfrom
vector-storage-multi-dense-volatile-test

Conversation

@timvisee
Copy link
Member

@timvisee timvisee commented May 20, 2025

Depends on #6561

Same as #6561, but for multi dense vectors.

Tasks

All Submissions:

  • Contributions should target the dev branch. Did you create your branch from dev?
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you formatted your code locally using cargo +nightly fmt --all command prior to submission?
  3. Have you checked your code using cargo clippy --all --all-features command?

@timvisee timvisee requested review from Copilot and generall May 20, 2025 15:46

This comment was marked as resolved.

@timvisee timvisee force-pushed the vector-storage-multi-dense-volatile-test branch from fd1d80c to 57f02bc Compare May 20, 2025 16:19
@timvisee timvisee added this to the Remove RocksDB milestone May 21, 2025
@timvisee timvisee force-pushed the vector-storage-multi-dense-volatile-test branch from 57f02bc to 7bc5ead Compare May 21, 2025 09:41
@timvisee timvisee mentioned this pull request May 21, 2025
9 tasks
Base automatically changed from vector-storage-dense-volatile-test to dev May 21, 2025 12:07
@timvisee timvisee force-pushed the vector-storage-multi-dense-volatile-test branch from 7bc5ead to 3897979 Compare May 21, 2025 12:08
@timvisee timvisee marked this pull request as ready for review May 21, 2025 12:08
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 21, 2025

📝 Walkthrough

Walkthrough

This change introduces a new in-memory, multi-dense vector storage backend called VolatileMultiDenseVectorStorage, designed for test-only scenarios. Three new test-only variants—MultiDenseVolatile, MultiDenseVolatileByte, and MultiDenseVolatileHalf—are added to the VectorStorageEnum and integrated into all relevant match arms and methods. Support for these variants is also added to GPU vector storage initialization, quantized vector creation, and raw scorer creation, all under test configuration. The test suite is updated to include new tests for the volatile storage variant, and an existing enum variant is renamed for clarity.

Suggested reviewers

  • generall
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
lib/segment/src/vector_storage/multi_dense/volatile_multi_dense_vector_storage.rs (1)

219-227: Size estimation can be off by orders of magnitude

size_of_available_vectors_in_bytes() approximates storage size by multiplying the
total number of inner vectors with vector_dim and then scaling by the ratio of
available/total outer vectors.
Because the average number of inner vectors per outer vector may vary greatly,
this heuristic can seriously under- or over-estimate memory use.

Consider computing the exact size instead (cheap for in-mem storage):

self.vectors.len() * self.vector_dim() * std::mem::size_of::<T>()

or store/maintain a running bytes_used counter during insertions/deletions.

lib/segment/src/vector_storage/tests/test_appendable_multi_dense_vector_storage.rs (1)

290-297: Include volatile storage in the parametrised rstests for broader coverage

Currently the new volatile backend is exercised only by dedicated unit tests,
while the generic #[rstest] suites still iterate over RocksDbFloat and
AppendableMmapFloat only. Adding the volatile variant here would let the same
edge-case matrix (delete/update/large-vector) run against all back-ends and
prevent silent divergence.

-        MultiDenseStorageType::RocksDbFloat,
-        MultiDenseStorageType::AppendableMmapFloat
+        MultiDenseStorageType::RocksDbFloat,
+        MultiDenseStorageType::AppendableMmapFloat,
+        // Volatile variant (treated as in-mem, use a dummy path)
+        // MultiDenseStorageType::VolatileFloat,   // requires enum & factory wiring

(You may need to promote the volatile option into MultiDenseStorageType and
route it through create_vector_storage.)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c2eba2 and 3897979.

📒 Files selected for processing (7)
  • lib/segment/src/index/hnsw_index/gpu/gpu_vector_storage/mod.rs (1 hunks)
  • lib/segment/src/vector_storage/multi_dense/mod.rs (1 hunks)
  • lib/segment/src/vector_storage/multi_dense/volatile_multi_dense_vector_storage.rs (1 hunks)
  • lib/segment/src/vector_storage/quantized/quantized_vectors.rs (1 hunks)
  • lib/segment/src/vector_storage/raw_scorer.rs (1 hunks)
  • lib/segment/src/vector_storage/tests/test_appendable_multi_dense_vector_storage.rs (8 hunks)
  • lib/segment/src/vector_storage/vector_storage_base.rs (22 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
lib/segment/src/vector_storage/multi_dense/volatile_multi_dense_vector_storage.rs (3)
lib/segment/src/vector_storage/vector_storage_base.rs (30)
  • distance (42-42)
  • distance (585-623)
  • datatype (44-44)
  • datatype (625-663)
  • is_on_disk (46-46)
  • is_on_disk (667-705)
  • total_vector_count (51-51)
  • total_vector_count (707-745)
  • get_vector (66-66)
  • get_vector (747-785)
  • get_vector_sequential (69-69)
  • get_vector_sequential (787-825)
  • get_vector_opt (72-72)
  • get_vector_opt (827-865)
  • insert_vector (74-79)
  • insert_vector (867-934)
  • update_from (87-91)
  • update_from (936-994)
  • flusher (93-93)
  • flusher (996-1034)
  • files (95-95)
  • files (1036-1074)
  • delete_vector (104-104)
  • delete_vector (1076-1114)
  • is_deleted_vector (107-107)
  • is_deleted_vector (1116-1154)
  • deleted_vector_count (123-123)
  • deleted_vector_count (1156-1194)
  • deleted_vector_bitslice (129-129)
  • deleted_vector_bitslice (1196-1234)
lib/segment/src/data_types/query_context.rs (1)
  • hardware_counter (187-189)
lib/segment/src/common/operation_error.rs (1)
  • check_process_stopped (242-247)
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: test-consistency
  • GitHub Check: test-snapshot-operations-s3-minio
  • GitHub Check: test-shard-snapshot-api-s3-minio
  • GitHub Check: test-low-resources
  • GitHub Check: Basic TLS/HTTPS tests
  • GitHub Check: test-consensus-compose
  • GitHub Check: rust-tests (ubuntu-latest)
  • GitHub Check: rust-tests (windows-latest)
  • GitHub Check: integration-tests
  • GitHub Check: rust-tests (macos-latest)
  • GitHub Check: integration-tests-consensus
  • GitHub Check: lint
  • GitHub Check: storage-compat-test
🔇 Additional comments (5)
lib/segment/src/vector_storage/multi_dense/mod.rs (1)

3-4: Good addition of test-only volatile storage implementation.

The module declaration for volatile_multi_dense_vector_storage is properly flagged with #[cfg(test)] to ensure it's only included in test builds. This aligns with the PR's objective to add volatile multi-dense vector storage.

lib/segment/src/vector_storage/raw_scorer.rs (1)

108-113: Consistent implementation of raw scorer support for volatile multi-dense vectors.

The added match arms for the new test-only variants correctly delegate to the appropriate multi-scorer implementation methods, maintaining consistency with the existing pattern for other multi-dense vector types. All variants are properly conditioned with #[cfg(test)] to ensure they only appear in test builds.

lib/segment/src/vector_storage/quantized/quantized_vectors.rs (1)

301-312: Properly integrated volatile multi-dense storage with quantization.

The added match arms for the test-only variants correctly delegate to the create_multi_impl method, maintaining consistency with other multi-dense vector implementations. All variants are appropriately guarded with #[cfg(test)] for test-only compilation.

lib/segment/src/index/hnsw_index/gpu/gpu_vector_storage/mod.rs (1)

411-425: Correct GPU vector storage integration for volatile multi-dense vectors.

The implementation properly maps each new test-only variant to the corresponding constructor method:

  • MultiDenseVolatile uses new_multi_f32 with force_half_precision flag
  • MultiDenseVolatileByte uses new_multi
  • MultiDenseVolatileHalf uses new_multi_f16

This follows the established pattern for other storage types and ensures GPU compatibility with the new volatile storage implementations. All variants are properly guarded with #[cfg(test)].

lib/segment/src/vector_storage/vector_storage_base.rs (1)

20-22: Visibility reminder: test-only variants silently disappear in release builds

VolatileMultiDenseVectorStorage and its enum variants are gated behind
#[cfg(test)]. Any code that accidentally slips outside a #[cfg(test)] block
(e.g. in benchmarks or integration tools) will fail to compile.
Please double-check all call-sites (particularly helpers in other modules) and add
#[cfg(test)] guards where necessary.

@timvisee timvisee merged commit 1cf4b62 into dev May 21, 2025
17 checks passed
@timvisee timvisee deleted the vector-storage-multi-dense-volatile-test branch May 21, 2025 12:35
generall pushed a commit that referenced this pull request May 22, 2025
* Add volatile multi dense vector storage

* Add and use volatile multi dense vector storage test
n0x29a pushed a commit that referenced this pull request May 23, 2025
* Add volatile multi dense vector storage

* Add and use volatile multi dense vector storage test
@coderabbitai coderabbitai bot mentioned this pull request Jul 1, 2025
@coderabbitai coderabbitai bot mentioned this pull request Aug 13, 2025
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