Skip to content

Don't measure in-memory hw for full text indices#6309

Merged
JojiiOfficial merged 3 commits intodevfrom
only_measure_on_disk_full_text_index
Apr 3, 2025
Merged

Don't measure in-memory hw for full text indices#6309
JojiiOfficial merged 3 commits intodevfrom
only_measure_on_disk_full_text_index

Conversation

@JojiiOfficial
Copy link
Contributor

Depends on #6296

@JojiiOfficial JojiiOfficial force-pushed the only_measure_on_disk_bool_index branch from 5e13c4b to 2fe6d18 Compare April 3, 2025 09:08
@JojiiOfficial JojiiOfficial force-pushed the only_measure_on_disk_full_text_index branch from a237b6d to 281fe19 Compare April 3, 2025 11:24
Base automatically changed from only_measure_on_disk_bool_index to dev April 3, 2025 17:04
@JojiiOfficial JojiiOfficial force-pushed the only_measure_on_disk_full_text_index branch from 281fe19 to d179174 Compare April 3, 2025 17:05
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 3, 2025

📝 Walkthrough

Walkthrough

This pull request updates the management of hardware counter measurement across several modules by introducing a new abstraction, ConditionedCounter. Two public methods, never and always, have been added to create instances with conditions preset to disable or enable hardware measurements explicitly. The changes replace direct usage of HardwareCounterCell in various components with ConditionedCounter where applicable. Several method signatures have been updated to either remove or ignore the hardware counter parameter, streamlining the call interfaces in both immutable and mutable index implementations, as well as in posting list and chunk reader modules. These modifications clarify the intended behavior for hardware measurement tracking without altering the core logic of the existing functions.

Possibly related PRs

Suggested reviewers

  • agourlay
  • timvisee
  • coszio
  • generall

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 821aa0a and d179174.

📒 Files selected for processing (8)
  • lib/common/common/src/counter/conditioned_counter.rs (1 hunks)
  • lib/segment/src/index/field_index/field_index_base.rs (1 hunks)
  • lib/segment/src/index/field_index/full_text_index/compressed_posting/compressed_chunks_reader.rs (3 hunks)
  • lib/segment/src/index/field_index/full_text_index/compressed_posting/compressed_posting_list.rs (2 hunks)
  • lib/segment/src/index/field_index/full_text_index/immutable_inverted_index.rs (5 hunks)
  • lib/segment/src/index/field_index/full_text_index/inverted_index.rs (1 hunks)
  • lib/segment/src/index/field_index/full_text_index/mmap_inverted_index/mmap_postings.rs (4 hunks)
  • lib/segment/src/index/field_index/full_text_index/mutable_inverted_index.rs (4 hunks)
🧰 Additional context used
🧬 Code Definitions (6)
lib/segment/src/index/field_index/field_index_base.rs (3)
lib/segment/src/index/field_index/full_text_index/text_index.rs (1)
  • query (255-262)
lib/api/src/grpc/qdrant.rs (2)
  • query (7434-7452)
  • query (7761-7764)
src/tonic/api/points_api.rs (1)
  • query (588-609)
lib/segment/src/index/field_index/full_text_index/compressed_posting/compressed_posting_list.rs (1)
lib/common/common/src/counter/conditioned_counter.rs (1)
  • never (26-28)
lib/segment/src/index/field_index/full_text_index/inverted_index.rs (4)
lib/segment/src/index/field_index/full_text_index/immutable_inverted_index.rs (1)
  • check_match (97-122)
lib/segment/src/index/field_index/full_text_index/mutable_inverted_index.rs (1)
  • check_match (194-205)
lib/segment/src/index/field_index/full_text_index/mmap_inverted_index/mod.rs (1)
  • check_match (223-247)
lib/segment/src/index/field_index/full_text_index/text_index.rs (1)
  • check_match (159-176)
lib/common/common/src/counter/conditioned_counter.rs (3)
lib/common/common/src/counter/hardware_accumulator.rs (1)
  • new (111-117)
lib/common/common/src/counter/hardware_counter.rs (1)
  • new (42-55)
lib/segment/src/index/field_index/full_text_index/compressed_posting/compressed_chunks_reader.rs (1)
  • new (18-32)
lib/segment/src/index/field_index/full_text_index/mmap_inverted_index/mmap_postings.rs (3)
lib/segment/src/index/field_index/full_text_index/compressed_posting/compressed_chunks_reader.rs (1)
  • new (18-32)
lib/common/common/src/counter/conditioned_counter.rs (1)
  • new (17-23)
lib/common/common/src/counter/hardware_counter.rs (1)
  • new (42-55)
lib/segment/src/index/field_index/full_text_index/immutable_inverted_index.rs (3)
lib/segment/src/index/field_index/full_text_index/inverted_index.rs (2)
  • get_posting_len (97-98)
  • get_token_id (197-197)
lib/segment/src/index/field_index/full_text_index/mutable_inverted_index.rs (2)
  • get_posting_len (176-182)
  • get_token_id (220-222)
lib/common/common/src/counter/hardware_counter.rs (1)
  • disposable (60-73)
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: Basic TLS/HTTPS tests
  • GitHub Check: test-snapshot-operations-s3-minio
  • GitHub Check: test-shard-snapshot-api-s3-minio
  • GitHub Check: test-low-resources
  • GitHub Check: test-consistency
  • GitHub Check: test (macos-latest)
  • GitHub Check: test-consensus-compose
  • GitHub Check: test
  • GitHub Check: test (windows-latest)
  • GitHub Check: test-consensus
  • GitHub Check: test (ubuntu-latest)
  • GitHub Check: test
  • GitHub Check: test
🔇 Additional comments (20)
lib/segment/src/index/field_index/field_index_base.rs (1)

184-184: Updated API call to match new method signature

The check_match method call has been updated to no longer pass the hw_counter parameter, aligning with changes to the ParsedQuery implementation that simplified its signature by removing hardware counter tracking.

lib/segment/src/index/field_index/full_text_index/compressed_posting/compressed_chunks_reader.rs (3)

2-2: Updated import to use ConditionedCounter

Added import for the new ConditionedCounter type which will replace direct usage of HardwareCounterCell for more conditional measurement control.


14-14: Changed hw_counter field type for improved measurement control

The hw_counter field type has been changed from a reference to HardwareCounterCell to an instance of ConditionedCounter, allowing for more granular control over when hardware measurements are collected.


23-23: Updated constructor parameter type to match field

The parameter type in the constructor has been updated to match the change made to the struct field, ensuring type consistency.

lib/segment/src/index/field_index/full_text_index/inverted_index.rs (1)

47-47: Simplified method signature by removing hardware counter parameter

The check_match method signature has been simplified to no longer include the hw_counter parameter, since hardware measurements are now handled at a higher level through the ConditionedCounter abstraction. This change streamlines the API while maintaining the same functionality.

lib/segment/src/index/field_index/full_text_index/compressed_posting/compressed_posting_list.rs (2)

2-2: Added import for ConditionedCounter

Added import for the new ConditionedCounter type which enables conditional hardware measurement.


45-45: Disabled hardware measurements for memory operations

The hardware counter is now wrapped with ConditionedCounter::never(), effectively disabling hardware measurements for in-memory operations in full text indices. This aligns with the PR's objective of not measuring in-memory hardware operations for full text indices, which can improve performance by reducing unnecessary tracking overhead.

lib/common/common/src/counter/conditioned_counter.rs (1)

24-33: Well-designed helper methods for common use cases.

The never and always methods provide a more semantic API for creating ConditionedCounter instances with predefined conditions. This improves code readability and makes the intent clearer than using boolean literals directly.

lib/segment/src/index/field_index/full_text_index/mmap_inverted_index/mmap_postings.rs (4)

5-5: Adding the ConditionedCounter import is appropriate.

This import supports the changes to the get_reader method.


69-69: Good addition of the on_disk field.

This field properly tracks whether the postings are stored on disk, which is essential for determining when hardware measurements should be taken.


126-126: Appropriate use of ConditionedCounter.

The integration of ConditionedCounter with the on_disk field ensures that hardware measurements are only taken when postings are accessed from disk, which aligns with the PR objective of not measuring in-memory operations for full text indices.


232-232: Correct initialization of on_disk field.

Setting on_disk to the negation of populate makes sense - if data is populated into memory, it's not on disk, and vice versa.

This implementation should also reflect the previous reviewer's feedback about depending on the populate parameter, which is now being addressed.

lib/segment/src/index/field_index/full_text_index/mutable_inverted_index.rs (4)

149-150: Appropriate removal of hardware counter usage.

Prefixing the parameter with an underscore clearly indicates that it's intentionally unused, which is good practice in Rust.


176-182: Simplified method implementation.

Removing the hardware counter usage from get_posting_len while preserving the parameter (as _) maintains compatibility with the trait definition while streamlining the implementation.


198-202: Appropriate removal of hardware counter usage in check_match.

The parameter is now properly marked as unused with the underscore prefix.


220-222: Consistent pattern of hardware counter removal.

This change to get_token_id follows the same pattern as the other methods, maintaining consistency across the implementation.

lib/segment/src/index/field_index/full_text_index/immutable_inverted_index.rs (4)

73-76: Helpful comments explaining hw_counter usage.

These comments provide valuable context about why the hardware counter is passed through to the reader method, explaining both the measurement behavior and the lifetime constraints.


85-86: Simplified method implementation.

Removing the hardware counter usage simplifies the code while maintaining the required interface.


101-121: Good solution for check_match implementation.

Creating a disposable hardware counter specifically for this method is an elegant solution that allows the method to continue functioning without affecting external hardware measurements. This approach maintains correctness while supporting the PR's objective of not measuring operations that shouldn't be measured.


141-143: Consistent pattern of hardware counter removal.

The change to get_token_id follows the same pattern as other methods, maintaining consistency throughout the implementation.

✨ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@JojiiOfficial JojiiOfficial merged commit bf706c2 into dev Apr 3, 2025
17 checks passed
@JojiiOfficial JojiiOfficial deleted the only_measure_on_disk_full_text_index branch April 3, 2025 17:43
pull bot pushed a commit to kp-forks/qdrant that referenced this pull request Apr 21, 2025
* Don't measure in-memory full text index

* Clippy

* Fix mmap_postings conditioned counting
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