Skip to content

[8.4] Implement slots tracker for ASM - [MOD-12167]#7291

Merged
redisearch-backport-pull-request[bot] merged 1 commit into8.4from
backport-7200-to-8.4
Nov 11, 2025
Merged

[8.4] Implement slots tracker for ASM - [MOD-12167]#7291
redisearch-backport-pull-request[bot] merged 1 commit into8.4from
backport-7200-to-8.4

Conversation

@redisearch-backport-pull-request
Copy link
Copy Markdown
Contributor

@redisearch-backport-pull-request redisearch-backport-pull-request bot commented Nov 10, 2025

Description

Backport of #7200 to 8.4.


Note

Introduces a Rust slots tracking library with a C FFI, generates a public header, wires it into the workspace, and adds an atomic key-space version to result processing.

  • Rust (workspace):
    • New crates: slots_tracker (core SlotSet/SlotsTracker with versioning and availability checks) and slots_tracker_ffi (C FFI layer).
    • FFI build: c_entrypoint/slots_tracker_ffi adds build.rs and cbindgen.toml to generate headers/slots_tracker.h.
    • Workspace updates: Adds slots_tracker to members and workspace.dependencies.
  • API (FFI/C):
    • Exposes slot management and queries: slots_tracker_set_local_slots_internal, slots_tracker_mark_partially_available_slots_internal, slots_tracker_promote_to_local_slots, slots_tracker_mark_fully_available_slots, slots_tracker_remove_deleted_slots, slots_tracker_has_fully_available_overlap, slots_tracker_check_availability.
    • Header provides static wrappers updating atomic_uint key_space_version for cheap reads across the boundary.
  • C integration:
    • Declares/defines extern atomic_uint key_space_version in src/result_processor.c to track key-space state version.

Written by Cursor Bugbot for commit f447680. This will update automatically on new commits. Configure here.

* initial component layout

* layout `slots_tracker_set_local_slots` plan

* layout `slots_tracker_set_partially_available_slots` plan

* layout `slots_tracker_set_fully_available_slots` plan

* layout `slots_tracker_remove_deleted_slots` and `slots_tracker_has_fully_available_overlap` plan

* layout `slots_tracker_check_availability` plan

* minimal refactor to the API

* implement helpers for the version management

* initial implementation of SlotsSet

* another iteration

* refine implementation

* add some tests

* formatting

* group state parts and other cleanup

* reuse functions

* rename

* set unit test module in slot_set.rs

* formatting

* move helpers

* implement separately slots_tracker for safer API and easier testing

* refactor API to use SlotsTracker

* add some tests

* tidy ups and fix lifetime

* format

* better struct exposure

* better memory management in union_relation

* add test

* rewrite some comments

* switch values anf six comments

* allow empty SlotRangeArray input (not null)

* Check complete state in tests with a custom PartialEq implementation

* update comments

* add promote_to_local_slots functionality

* add tests

* formatting

* tests cleanup

* add coverage_relation algorithm

* refactor union_relation to use new coverage_relation

* formatting

* linting

* an attempt to create an FFI correctly

* address some review comments

* another review comment fix

* update ffi and header

* fix cbindgen build

* more idiomatic

* add debug assert to promote_to_local_slots

* remove tests for unexpected situations

* refactor has_overlap to use "any"

* minor improvement

* reorder match cases for better readability

* use thread_local to avoid unsafe sync

* replace boolean assert with thread id validation

* implement version enum for slots_tracker

* address review comments

* improve comments

* rename value to version

* optimize atomic access

* simplify helpers

* use assert

* move atomic manipulations to the C side

* improve tests

* improve API comments

(cherry picked from commit 742f192)

// TODO ASM: use this to decide if we need to filter by slots
extern atomic_uint key_space_version;
atomic_uint key_space_version = 0;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Misplaced Extern Keyword

The key_space_version variable has both an extern declaration and a definition with initialization in the same file. Line 91 declares it as extern (indicating it's defined elsewhere), but line 92 immediately defines and initializes it. This creates a conflicting declaration - the extern keyword should be removed from line 91 since the variable is being defined in this file, not just declared.

Fix in Cursor Fix in Web

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 11, 2025

Codecov Report

❌ Patch coverage is 90.18519% with 106 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.73%. Comparing base (cd118a2) to head (f447680).
⚠️ Report is 2 commits behind head on 8.4.

Files with missing lines Patch % Lines
...earch_rs/c_entrypoint/slots_tracker_ffi/src/lib.rs 0.00% 99 Missing ⚠️
...c/redisearch_rs/slots_tracker/src/slots_tracker.rs 98.52% 6 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              8.4    #7291      +/-   ##
==========================================
+ Coverage   85.65%   85.73%   +0.07%     
==========================================
  Files         326      329       +3     
  Lines       50934    52014    +1080     
  Branches    10921    12001    +1080     
==========================================
+ Hits        43628    44592     +964     
- Misses       7140     7255     +115     
- Partials      166      167       +1     
Flag Coverage Δ
flow 84.17% <ø> (-0.13%) ⬇️
unit 52.53% <90.18%> (+0.79%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@redisearch-backport-pull-request redisearch-backport-pull-request bot added this pull request to the merge queue Nov 11, 2025
Merged via the queue into 8.4 with commit b0ea684 Nov 11, 2025
22 checks passed
@redisearch-backport-pull-request redisearch-backport-pull-request bot deleted the backport-7200-to-8.4 branch November 11, 2025 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant