Skip to content

Don't measure in memory geo, map and numeric indices#6311

Merged
JojiiOfficial merged 1 commit intodevfrom
only_measure_on_disk_full_geo_map_numeric
Apr 3, 2025
Merged

Don't measure in memory geo, map and numeric indices#6311
JojiiOfficial merged 1 commit intodevfrom
only_measure_on_disk_full_geo_map_numeric

Conversation

@JojiiOfficial
Copy link
Contributor

Depends on #6309

@JojiiOfficial JojiiOfficial force-pushed the only_measure_on_disk_full_text_index branch from 281fe19 to d179174 Compare April 3, 2025 17:05
Base automatically changed from only_measure_on_disk_full_text_index to dev April 3, 2025 17:43
@JojiiOfficial JojiiOfficial force-pushed the only_measure_on_disk_full_geo_map_numeric branch from 2758672 to f85d509 Compare April 3, 2025 17:44
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 3, 2025

📝 Walkthrough

Walkthrough

The changes remove the HardwareCounterCell parameter from multiple method signatures across various index implementations. Both mutable and immutable variants in Geo, Map, and Numeric indexes have their methods updated to eliminate hardware counter tracking logic. In particular, methods such as check_values_any, points_of_hash, and values_of_hash in the Geo indexes; similar methods in the Map indexes; and methods in the Numeric indexes have been streamlined. Additionally, for mmap-based indexes, a new boolean field is_on_disk has been introduced along with a helper method make_conditioned_counter that adjusts counter behavior based on the disk state. These updates simplify the interfaces and internal logic by reducing parameter overhead and removing counter increment operations.

Possibly related PRs

  • Don't measure in-memory hw for full text indices #6309: The changes in the main PR, which involve the removal of the HardwareCounterCell parameter from several methods in the ImmutableGeoMapIndex struct, are related to the modifications in the retrieved PR that also focus on eliminating hardware counter measurements in various index methods, indicating a shared goal of simplifying method signatures and logic.

Suggested reviewers

  • timvisee
  • generall
  • agourlay
  • coszio

📜 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 3bd4477 and edc0118.

📒 Files selected for processing (13)
  • lib/common/common/src/counter/iterator_hw_measurement.rs (2 hunks)
  • lib/segment/src/index/field_index/geo_index/immutable_geo_index.rs (2 hunks)
  • lib/segment/src/index/field_index/geo_index/mmap_geo_index.rs (8 hunks)
  • lib/segment/src/index/field_index/geo_index/mod.rs (2 hunks)
  • lib/segment/src/index/field_index/geo_index/mutable_geo_index.rs (3 hunks)
  • lib/segment/src/index/field_index/map_index/immutable_map_index.rs (4 hunks)
  • lib/segment/src/index/field_index/map_index/mmap_map_index.rs (9 hunks)
  • lib/segment/src/index/field_index/map_index/mod.rs (3 hunks)
  • lib/segment/src/index/field_index/map_index/mutable_map_index.rs (2 hunks)
  • lib/segment/src/index/field_index/numeric_index/immutable_numeric_index.rs (2 hunks)
  • lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs (6 hunks)
  • lib/segment/src/index/field_index/numeric_index/mod.rs (3 hunks)
  • lib/segment/src/index/field_index/numeric_index/mutable_numeric_index.rs (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (12)
  • lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs
  • lib/segment/src/index/field_index/numeric_index/immutable_numeric_index.rs
  • lib/segment/src/index/field_index/geo_index/mmap_geo_index.rs
  • lib/segment/src/index/field_index/geo_index/mod.rs
  • lib/segment/src/index/field_index/numeric_index/mod.rs
  • lib/segment/src/index/field_index/map_index/mmap_map_index.rs
  • lib/segment/src/index/field_index/map_index/mod.rs
  • lib/segment/src/index/field_index/geo_index/immutable_geo_index.rs
  • lib/segment/src/index/field_index/geo_index/mutable_geo_index.rs
  • lib/segment/src/index/field_index/map_index/immutable_map_index.rs
  • lib/segment/src/index/field_index/map_index/mutable_map_index.rs
  • lib/segment/src/index/field_index/numeric_index/mutable_numeric_index.rs
🧰 Additional context used
🧬 Code Definitions (1)
lib/common/common/src/counter/iterator_hw_measurement.rs (2)
lib/common/common/src/counter/hardware_counter.rs (1)
  • new (42-55)
lib/common/common/src/iterator_ext/on_final_count.rs (1)
  • new (14-20)
⏰ 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-consensus-compose
  • GitHub Check: test (macos-latest)
  • GitHub Check: test-consensus
  • GitHub Check: test (windows-latest)
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: test (ubuntu-latest)
🔇 Additional comments (2)
lib/common/common/src/counter/iterator_hw_measurement.rs (2)

1-1: Good addition of the new import for ConditionedCounter.

This import is properly added at the top of the file, maintaining alphabetical ordering with the other imports from the same module.


30-49:

Details

❓ Verification inconclusive

Well-structured new method for conditional hardware measurements.

The new measure_hw_with_condition_cell method enhances the trait with the ability to use a ConditionedCounter, which appears to be part of a larger refactoring to simplify hardware counter handling. The implementation follows the same pattern as the existing methods in the trait.

One thing to note is that unlike measure_hw_with_cell which takes a reference to HardwareCounterCell, this method takes ownership of the ConditionedCounter. If ConditionedCounter is meant to be cloned or moved, this is fine; otherwise, you might want to consider taking a reference instead.


🏁 Script executed:

#!/bin/bash
# Check if ConditionedCounter implements Clone or Copy
rg --type rust "impl (Clone|Copy) for ConditionedCounter" lib/

Length of output: 64


Action: Verify Ownership Semantics for ConditionedCounter

The new method, measure_hw_with_condition_cell, is well structured and follows the pattern of similar methods. However, note that it takes ownership of the ConditionedCounter rather than borrowing it—unlike measure_hw_with_cell, which accepts a reference. Our initial search for an implementation of Clone or Copy for ConditionedCounter (using rg --type rust "impl (Clone|Copy) for ConditionedCounter" lib/) returned no results. This outcome is inconclusive, and it's unclear whether ConditionedCounter is intentionally designed to be moved or if it should support copying/cloning.

Before finalizing, please verify the following:

  • Does ConditionedCounter intentionally lack Clone/Copy implementations?
    If yes, then passing it by value is likely deliberate.
  • Should ConditionedCounter be cloned or borrowed instead?
    In that case, consider changing the method’s parameter to a reference or implementing the necessary traits on ConditionedCounter.

For further insight, you might run the following additional shell script to locate its definition and check for derived traits:

Please verify the implementation and ensure that the ownership model used in measure_hw_with_condition_cell aligns with the design intentions for ConditionedCounter.


🏁 Script executed:

#!/bin/bash
# Search for the definition of ConditionedCounter and check for derived Clone/Copy
rg --type rust "pub\s+struct\s+ConditionedCounter" -n .
rg --type rust "derive\s*\(.*(Clone|Copy).*?\)[^{]*pub\s+struct\s+ConditionedCounter" -n .

Length of output: 366


Directive: Confirm Ownership Semantics for ConditionedCounter

The new measure_hw_with_condition_cell method is well structured and follows established patterns. It accepts a ConditionedCounter by value rather than by reference. Our search of lib/common/common/src/counter/conditioned_counter.rs indicates that ConditionedCounter is defined without any derived Clone or Copy implementations, which implies that it is intended to be moved. This design is acceptable if consuming the counter in this context is deliberate.

Please verify that this ownership decision is consistent with the intended use of ConditionedCounter across the codebase. If the design requires reusing the counter without transfer of ownership, consider taking a reference or implementing Clone/Copy.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.

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: 0

🧹 Nitpick comments (2)
lib/segment/src/index/field_index/map_index/mutable_map_index.rs (1)

128-144: Simplified method signature by removing hardware counter parameter

The check_values_any method now has a simpler signature with the hardware counter parameter removed. The hardware counter tracking logic (hw_counter_val += N::mmapped_size(item.as_referenced())) remains in the code but is no longer used anywhere, which creates dead code.

Consider removing the unused hardware counter tracking logic since it's no longer serving any purpose:

 pub fn check_values_any(&self, idx: PointOffsetType, check_fn: impl Fn(&N) -> bool) -> bool {
-    let mut hw_counter_val = 0;
-
     let res = self
         .point_to_values
         .get(idx as usize)
         .map(|values| {
             values.iter().any(|v| {
                 let item: &N = v.borrow();
-                hw_counter_val += N::mmapped_size(item.as_referenced());
                 check_fn(item)
             })
         })
         .unwrap_or(false);

     res
 }
lib/segment/src/index/field_index/map_index/immutable_map_index.rs (1)

251-261: Simplified method signature by removing hardware counter parameter

The check_values_any method now has a simpler signature with the hardware counter parameter removed. Similar to the mutable version, the hardware counter tracking logic (hw_count_val += <N as MmapValue>::mmapped_size(v.as_referenced())) remains in the code but is no longer used anywhere.

Consider removing the unused hardware counter tracking logic since it's no longer serving any purpose:

 pub fn check_values_any(&self, idx: PointOffsetType, check_fn: impl Fn(&N) -> bool) -> bool {
-    let mut hw_count_val = 0;
-
     let res = self.point_to_values.check_values_any(idx, |v| {
         let v = v.borrow();
-        hw_count_val += <N as MmapValue>::mmapped_size(v.as_referenced());
         check_fn(v)
     });

     res
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between bf706c2 and f85d509.

📒 Files selected for processing (12)
  • lib/segment/src/index/field_index/geo_index/immutable_geo_index.rs (2 hunks)
  • lib/segment/src/index/field_index/geo_index/mmap_geo_index.rs (8 hunks)
  • lib/segment/src/index/field_index/geo_index/mod.rs (2 hunks)
  • lib/segment/src/index/field_index/geo_index/mutable_geo_index.rs (3 hunks)
  • lib/segment/src/index/field_index/map_index/immutable_map_index.rs (4 hunks)
  • lib/segment/src/index/field_index/map_index/mmap_map_index.rs (9 hunks)
  • lib/segment/src/index/field_index/map_index/mod.rs (3 hunks)
  • lib/segment/src/index/field_index/map_index/mutable_map_index.rs (2 hunks)
  • lib/segment/src/index/field_index/numeric_index/immutable_numeric_index.rs (2 hunks)
  • lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs (6 hunks)
  • lib/segment/src/index/field_index/numeric_index/mod.rs (3 hunks)
  • lib/segment/src/index/field_index/numeric_index/mutable_numeric_index.rs (4 hunks)
🧰 Additional context used
🧬 Code Definitions (9)
lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs (4)
lib/segment/src/types.rs (9)
  • is_on_disk (1180-1182)
  • is_on_disk (1317-1322)
  • is_on_disk (1736-1747)
  • is_on_disk (1789-1794)
  • new (376-389)
  • new (1463-1466)
  • new (2601-2603)
  • new (2825-2827)
  • new (2838-2840)
lib/segment/src/index/field_index/map_index/mmap_map_index.rs (1)
  • make_conditioned_counter (329-334)
lib/segment/src/index/field_index/numeric_index/mod.rs (1)
  • new (436-441)
lib/segment/src/index/field_index/map_index/mutable_map_index.rs (1)
  • new (26-39)
lib/segment/src/index/field_index/geo_index/mod.rs (3)
lib/segment/src/index/field_index/geo_index/mmap_geo_index.rs (1)
  • values_of_hash (305-320)
lib/segment/src/index/field_index/geo_index/immutable_geo_index.rs (1)
  • values_of_hash (110-116)
lib/segment/src/index/field_index/geo_index/mutable_geo_index.rs (1)
  • values_of_hash (242-244)
lib/segment/src/index/field_index/geo_index/mmap_geo_index.rs (6)
lib/segment/src/types.rs (9)
  • is_on_disk (1180-1182)
  • is_on_disk (1317-1322)
  • is_on_disk (1736-1747)
  • is_on_disk (1789-1794)
  • new (376-389)
  • new (1463-1466)
  • new (2601-2603)
  • new (2825-2827)
  • new (2838-2840)
lib/segment/src/index/field_index/map_index/mmap_map_index.rs (1)
  • make_conditioned_counter (329-334)
lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs (1)
  • make_conditioned_counter (353-358)
lib/segment/src/index/field_index/bool_index/mmap_bool_index.rs (1)
  • make_conditioned_counter (88-94)
lib/segment/src/index/field_index/geo_index/immutable_geo_index.rs (1)
  • new (37-51)
lib/segment/src/index/field_index/geo_index/mutable_geo_index.rs (2)
  • new (54-63)
  • new (202-212)
lib/segment/src/index/field_index/map_index/mmap_map_index.rs (4)
lib/segment/src/types.rs (5)
  • is_on_disk (1180-1182)
  • is_on_disk (1317-1322)
  • is_on_disk (1736-1747)
  • is_on_disk (1789-1794)
  • i (3035-3035)
lib/segment/src/index/field_index/geo_index/mmap_geo_index.rs (2)
  • make_conditioned_counter (394-399)
  • new (86-195)
lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs (1)
  • make_conditioned_counter (353-358)
lib/segment/src/index/field_index/bool_index/mmap_bool_index.rs (1)
  • make_conditioned_counter (88-94)
lib/segment/src/index/field_index/geo_index/immutable_geo_index.rs (2)
lib/segment/src/index/field_index/geo_index/mod.rs (2)
  • points_of_hash (112-118)
  • values_of_hash (120-126)
lib/segment/src/index/field_index/geo_index/mutable_geo_index.rs (2)
  • points_of_hash (238-240)
  • values_of_hash (242-244)
lib/segment/src/index/field_index/numeric_index/mutable_numeric_index.rs (10)
lib/segment/src/index/field_index/map_index/immutable_map_index.rs (1)
  • check_values_any (251-261)
lib/segment/src/index/field_index/map_index/mutable_map_index.rs (1)
  • check_values_any (128-144)
lib/segment/src/index/field_index/geo_index/mod.rs (1)
  • check_values_any (185-196)
lib/segment/src/index/field_index/numeric_index/mod.rs (1)
  • check_values_any (245-256)
lib/segment/src/index/field_index/geo_index/immutable_geo_index.rs (1)
  • check_values_any (73-84)
lib/segment/src/index/field_index/geo_index/mmap_geo_index.rs (1)
  • check_values_any (247-268)
lib/segment/src/index/field_index/map_index/mmap_map_index.rs (1)
  • check_values_any (164-187)
lib/segment/src/index/field_index/numeric_index/immutable_numeric_index.rs (3)
  • check_values_any (169-175)
  • values_range (68-80)
  • values_range (202-210)
lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs (2)
  • check_values_any (209-226)
  • values_range (254-269)
lib/segment/src/index/field_index/bool_index/mod.rs (1)
  • check_values_any (66-76)
lib/segment/src/index/field_index/geo_index/mutable_geo_index.rs (1)
lib/segment/src/index/field_index/geo_index/immutable_geo_index.rs (5)
  • check_values_any (73-84)
  • values_count (90-94)
  • points_per_hash (96-100)
  • points_of_hash (102-108)
  • values_of_hash (110-116)
lib/segment/src/index/field_index/map_index/mutable_map_index.rs (8)
lib/segment/src/index/field_index/map_index/immutable_map_index.rs (1)
  • check_values_any (251-261)
lib/segment/src/index/field_index/numeric_index/mutable_numeric_index.rs (2)
  • check_values_any (73-78)
  • check_values_any (284-286)
lib/segment/src/index/field_index/geo_index/mod.rs (1)
  • check_values_any (185-196)
lib/segment/src/index/field_index/map_index/mod.rs (1)
  • check_values_any (122-133)
lib/segment/src/index/field_index/numeric_index/mod.rs (1)
  • check_values_any (245-256)
lib/segment/src/index/field_index/map_index/mmap_map_index.rs (1)
  • check_values_any (164-187)
lib/segment/src/index/field_index/numeric_index/immutable_numeric_index.rs (1)
  • check_values_any (169-175)
lib/segment/src/index/field_index/geo_index/mutable_geo_index.rs (1)
  • check_values_any (214-223)
lib/segment/src/index/field_index/map_index/immutable_map_index.rs (7)
lib/segment/src/index/field_index/map_index/mutable_map_index.rs (1)
  • check_values_any (128-144)
lib/segment/src/index/field_index/geo_index/mod.rs (1)
  • check_values_any (185-196)
lib/segment/src/index/field_index/map_index/mod.rs (1)
  • check_values_any (122-133)
lib/segment/src/index/field_index/geo_index/immutable_geo_index.rs (1)
  • check_values_any (73-84)
lib/segment/src/index/field_index/map_index/mmap_map_index.rs (1)
  • check_values_any (164-187)
lib/segment/src/index/field_index/numeric_index/immutable_numeric_index.rs (1)
  • check_values_any (169-175)
lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs (1)
  • check_values_any (209-226)
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • 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: Basic TLS/HTTPS tests
  • GitHub Check: test (macos-latest)
  • GitHub Check: test-consensus-compose
  • GitHub Check: test (windows-latest)
  • GitHub Check: test-consensus
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: test (ubuntu-latest)
🔇 Additional comments (41)
lib/segment/src/index/field_index/numeric_index/mod.rs (3)

252-254: Hardware counter handling simplified for in-memory indexes

The code now differentiates hardware counter behavior between in-memory indexes (Mutable and Immutable) and disk-based index (Mmap). In-memory indexes no longer receive the hardware counter parameter, simplifying their API and improving maintainability.


376-378: Consistent hardware counter removal pattern

The removal of the hardware counter parameter from in-memory index variants is consistently applied here in the point_ids_by_value method, aligning with the changes in the check_values_any method above.


701-710: Hardware counter handling streamlined for filter method

The hardware counter parameter has been removed from the values_range call for in-memory indexes while being maintained for mmap indexes, consistent with the approach throughout this PR. This creates a cleaner separation between hardware measurement logic for in-memory vs. on-disk indexes.

lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs (4)

36-36: Added on-disk tracking capability

The addition of the is_on_disk boolean field enables the index to track whether it's using disk-based storage, which will influence hardware counter behavior.


180-181: Properly initializing the on-disk state

The is_on_disk field is correctly initialized with the parameter value passed to the load method, ensuring the index can properly track its storage location.


215-216: Conditional hardware counter for performance measurement

The code now uses a conditioned hardware counter based on the disk status of the index, which allows for more accurate performance measurements. This approach ensures the hardware counter only tracks operations that are truly I/O-bound.

Also applies to: 260-261


353-358: Helper method for creating conditioned counters

The new make_conditioned_counter method encapsulates the logic for creating a counter that behaves differently based on the disk status. This improves code organization and ensures consistent counter behavior across methods.

lib/segment/src/index/field_index/map_index/mmap_map_index.rs (4)

38-38: Added on-disk tracking for map index

Similar to the numeric index, the map index now tracks whether it's stored on disk, enabling more accurate hardware counter behavior.


167-171: Improved parameter naming and conditioned counter usage

The parameter has been renamed from hw_acc to hw_counter for consistency across the codebase, and the method now creates a conditioned counter based on the disk status.


319-324: Updated measurement methodology for iterators

The code now uses measure_hw_with_acc instead of measure_hw_with_cell, passing the conditioned counter's accumulator. This ensures consistent measurement behavior across the codebase.


329-334: Consistent helper method for counter conditioning

The implementation of make_conditioned_counter is consistent with other index types, reinforcing the systematic approach to hardware counter management across the codebase.

lib/segment/src/index/field_index/geo_index/mmap_geo_index.rs (3)

76-76: Added on-disk tracking capability for geo index

The geo index now includes an is_on_disk field, consistent with the pattern established in other index implementations.


253-254: Consistent conditioning of hardware counters

The geo index implementation applies the conditioned counter pattern consistently across all methods that perform hardware counter measurement, ensuring uniform behavior.

Also applies to: 289-290, 306-307


394-399: Standardized helper method implementation

The make_conditioned_counter implementation is identical to those in other index types, ensuring consistent behavior across different index implementations.

lib/segment/src/index/field_index/map_index/mod.rs (5)

129-130: HardwareCounterCell parameter removed for in-memory indices

The hw_counter parameter has been removed from the check_values_any method calls for both Mutable and Immutable variants, while it is still being passed to the Mmap variant. This change aligns with the PR objective to stop measuring in-memory operations.


184-185: Consistent hardware counter removal from in-memory indices

The hw_counter parameter has been removed from get_count_for_value method calls for both memory-based variants, consistent with the pattern applied to other methods in this PR.


192-193: Hardware counter parameter removed for in-memory iterator retrieval

The hw_counter parameter has been consistently removed from get_iterator method calls for Mutable and Immutable variants while maintaining it for the Mmap variant, which likely involves disk I/O operations.


219-220: Removed hardware counter for in-memory values map iteration

The hw_counter parameter has been removed from iter_values_map method calls for memory-based variants, completing the consistent pattern of removing hardware counter measurements from in-memory operations throughout the file.


122-132:

Details

✅ Verification successful

Verify API compatibility for hardware counter removals

While the changes are consistent within this file, it's important to ensure that the underlying implementations in MutableMapIndex and ImmutableMapIndex classes have been similarly updated to match these interface changes.


🏁 Script executed:

#!/bin/bash
# Check if the method signatures in the underlying implementations have been updated

echo "Checking MutableMapIndex implementation:"
rg -A 2 "fn check_values_any" lib/segment/src/index/field_index/map_index/mutable_map_index.rs

echo -e "\nChecking ImmutableMapIndex implementation:"
rg -A 2 "fn check_values_any" lib/segment/src/index/field_index/map_index/immutable_map_index.rs

echo -e "\nChecking MmapMapIndex implementation (should still use hw_counter):"
rg -A 2 "fn check_values_any" lib/segment/src/index/field_index/map_index/mmap_map_index.rs

Length of output: 974


API Compatibility Verified for Hardware Counter Adjustments

The executed script confirms that the check_values_any method in both MutableMapIndex and ImmutableMapIndex has been updated to remove the hw_counter parameter, aligning with the changes in mod.rs. The MmapMapIndex implementation still expects the hw_counter parameter, as intended.

  • MutableMapIndex: Method signature now only accepts idx and check_fn.
  • ImmutableMapIndex: Method signature updated similarly.
  • MmapMapIndex: Continues to use hw_counter, consistent with its intended behavior.

No further modifications are required at this time.

lib/segment/src/index/field_index/geo_index/mod.rs (3)

112-117: Removed hardware counter parameter from in-memory indices.

The hardware counter parameter has been appropriately removed from the points_of_hash method for both mutable and immutable indices, while maintaining it for memory-mapped indices. This is consistent with the PR objective of not measuring in-memory geo indices.


120-125: Removed hardware counter parameter from in-memory indices.

The hardware counter parameter has been successfully removed from the values_of_hash method for both mutable and immutable indices, while maintaining it for memory-mapped indices. This change follows the same pattern as the points_of_hash method.


185-196: Removed hardware counter parameter from in-memory indices.

The hardware counter parameter has been appropriately removed from the check_values_any method for mutable and immutable variants, while correctly maintaining it for memory-mapped indices. This change completes the consistent pattern of removing hardware counter tracking from in-memory index operations.

lib/segment/src/index/field_index/numeric_index/immutable_numeric_index.rs (2)

169-175: Simplified method implementation by removing hardware counter.

The check_values_any method has been streamlined by removing the hardware counter tracking logic, directly delegating to the underlying point_to_values implementation. This simplification aligns with the PR objective.


202-210: Removed hardware counter parameter from method signature.

The values_range method no longer accepts a hardware counter parameter, and the implementation has been simplified to focus solely on the core functionality of returning mapped indices. This change is consistent with the overall PR objective.

lib/segment/src/index/field_index/geo_index/immutable_geo_index.rs (3)

73-84: Simplified check_values_any implementation.

The method has been simplified by removing the hardware counter tracking logic. Now it directly returns the result from point_to_values.check_values_any without incrementing a counter. This simplification aligns with the PR objective and makes the code more readable.


102-108: Removed hardware counter parameter from method signature.

The points_of_hash method now has a simpler signature without the hardware counter parameter. The implementation remains focused on the core functionality of retrieving point counts for a given hash.


110-116: Removed hardware counter parameter from method signature.

The values_of_hash method has been updated to remove the hardware counter parameter, consistent with the other changes in the PR. The implementation continues to correctly retrieve value counts for a given hash.

lib/segment/src/index/field_index/geo_index/mutable_geo_index.rs (4)

182-187: Updated delegate macro to reflect simpler method signatures.

The delegate! macro has been updated to match the new method signatures that don't include hardware counter parameters for check_values_any, points_of_hash, and values_of_hash. This ensures consistency between the MutableGeoMapIndex and InMemoryGeoMapIndex implementations.


214-223: Simplified check_values_any implementation.

The implementation has been streamlined by directly returning the result of values.iter().any(check_fn) without extra hardware counter tracking logic. This makes the code cleaner and more focused on its core functionality.


238-240: Removed hardware counter parameter from method signature.

The points_of_hash method now has a simpler interface without the hardware counter parameter. This is consistent with the overall PR goal of not measuring in-memory indices.


242-244: Removed hardware counter parameter from method signature.

The values_of_hash method has been simplified by removing the hardware counter parameter, consistent with the other changes in the PR. The implementation remains focused on retrieving value counts from the hash map.

lib/segment/src/index/field_index/map_index/mutable_map_index.rs (3)

171-173: Simplified method signature by removing hardware counter parameter

The get_count_for_value method has been simplified by removing the hardware counter parameter and the associated counter incrementation logic.


179-183: Simplified method signature by removing hardware counter parameter

The iter_values_map method signature has been simplified by removing the hardware counter parameter. The implementation is now more straightforward without the need to track hardware access.


185-189: Simplified method signature by removing hardware counter parameter

The get_iterator method signature has been simplified by removing the hardware counter parameter. The implementation no longer tracks hardware access for iterating over values.

lib/segment/src/index/field_index/map_index/immutable_map_index.rs (3)

283-287: Simplified method signature by removing hardware counter parameter

The get_count_for_value method has been simplified by removing the hardware counter parameter and associated counter incrementation logic.


295-302: Simplified method signature by removing hardware counter parameter

The iter_values_map method signature has been simplified by removing the hardware counter parameter. Line 299 no longer needs to track hardware counter increments.


304-325: Simplified method signature by removing hardware counter parameter

The get_iterator method has been simplified by removing the hardware counter parameter. The implementation no longer tracks hardware access for range operations.

lib/segment/src/index/field_index/numeric_index/mutable_numeric_index.rs (4)

73-78: Simplified method signature by removing hardware counter parameter

The check_values_any method in the InMemoryNumericIndex struct has been simplified by removing the hardware counter parameter. The implementation is now more straightforward with a focus solely on checking if any values match the condition.


96-104: Simplified method signature by removing hardware counter parameter

The values_range method has been simplified by removing the hardware counter parameter. The implementation now directly returns an iterator over the range without tracking hardware access.


284-286: Simplified method signature by removing hardware counter parameter

The check_values_any method in the MutableNumericIndex struct has been simplified by removing the hardware counter parameter. It now forwards the call directly to the corresponding method in InMemoryNumericIndex.


300-306: Simplified method signature by removing hardware counter parameter

The values_range method in the MutableNumericIndex struct has been simplified by removing the hardware counter parameter. It now directly delegates to the InMemoryNumericIndex implementation.

@JojiiOfficial JojiiOfficial force-pushed the only_measure_on_disk_full_geo_map_numeric branch from 3bd4477 to edc0118 Compare April 3, 2025 18:32
@JojiiOfficial JojiiOfficial merged commit bd9a657 into dev Apr 3, 2025
17 checks passed
@JojiiOfficial JojiiOfficial deleted the only_measure_on_disk_full_geo_map_numeric branch April 3, 2025 18:57
pull bot pushed a commit to kp-forks/qdrant that referenced this pull request Apr 21, 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