Skip to content

Remove AsyncRawScorer - #8685

Merged
generall merged 17 commits into
devfrom
remove-async-raw-scorer
Apr 17, 2026
Merged

generall merged 17 commits into
devfrom
remove-async-raw-scorer

Conversation

@ffuugoo

@ffuugoo ffuugoo commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

This PR refactors ImmutableDenseVectors and DenseVectorStorageImpl, so that default RawScorerImpl correctly uses io_uring, and we can get rid of AsyncRawScorerImpl.

I've tested all changes against scorer_mmap/vector_search benchmark, no noticeable impact on performance as far as I can tell.

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 --workspace --all-features command?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@ffuugoo
ffuugoo requested review from generall and xzfc April 15, 2026 13:15
coderabbitai[bot]

This comment was marked as resolved.

}))
}

fn type_id() -> any::TypeId;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I had to add a simple runtime-detection of storage-type...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd rather use enum instead of any::TypeId.

fn kind() -> UniversalKind;
enum UniversalKind {
    Mmap,
    #[cfg(…)]
    IoUring,
    S3,
}

Or even this if we want to call some specialized method:

fn downcast(&self) -> UniversalImplRef<'_>;
enum UniversalImplRef<'a> {
    Mmap(&'a UniversalMmapFile),
    ...
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I guess UniversalKind would be better. I initially wanted to do this check directly in for_each_in_batch, but that requires 'static, so I went with this without reconsidering.

I'll fix this before merging.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines +143 to +146
#[cfg(target_os = "linux")]
if S::type_id() == std::any::TypeId::of::<common::universal_io::IoUringFile>() {
return self.for_each_in_batch_async(keys, f);
}

@ffuugoo ffuugoo Apr 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

...so that I can select a "specialized" implementation here.

But with other changes in this PR, hot-path is moved right after this check, so performance impact is non-existent.

My idea, is once all scorers are refactored, we can move this micro-batching inside MmapFile::read_batch, and then we can get rid of runtime check.

But currently, pretty much every scorer is using this micro-batching on the level "above" read_batch call, so adding another layer of micro-batching in read_batch would degrade mmap perf, and refactoring every scorer at once to remove micro-batching would be too extensive. 🙄

Comment on lines +325 to +328
#[cfg(target_os = "linux")]
if S::type_id() == std::any::TypeId::of::<common::universal_io::IoUringFile>() {
return self.for_each_in_batch_async(keys, f);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

(and also here)

@qdrant qdrant deleted a comment from coderabbitai Bot Apr 15, 2026
@coderabbitai

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@generall
generall merged commit 9ba216b into dev Apr 17, 2026
12 checks passed
@generall
generall deleted the remove-async-raw-scorer branch April 17, 2026 18:18
timvisee pushed a commit that referenced this pull request May 8, 2026
* Merge `scorer_mmap` and `vector_search` benchmarks

* Move micro-batching logic from `RawScorerImpl::score_points` into `QueryScorer::score_stored_batch`

* Propagate micro-batching logic from dense scorers...

...into `ImmutableDenseVectors`/`ChunkedVectors`

* Implement io_uring-specialized `ImmutableDenseVectors::for_each_in_batch_async`

* Implement io_uring-specialized `ChunkedVectors::for_each_in_batch_async`

* Add `UniversalRead::type_id` method for runtime storage-type queries

* fixup! Implement io_uring-specialized `ImmutableDenseVectors::for_each_in_batch_async`

Enable io_uring-specialized scoring on Linux

* fixup! Implement io_uring-specialized `ChunkedVectors::for_each_in_batch_async`

Enable io_uring-specialized scoring on Linux

* Refactor `DenseVectorStorageImpl::read_vectors`...

...to use `ImmutableDenseVectors::for_each_in_batch` instead of `read_vectors_async`

* Remove `AsyncRawScorer`

* fixup! Propagate micro-batching logic from dense scorers...

Fix bugs

* fixup! Propagate micro-batching logic from dense scorers...

* fixup! Merge `scorer_mmap` and `vector_search` benchmarks

Fix clippy 🙄

* fixup! Add `UniversalRead::type_id` method for runtime storage-type queries

Change to `UniversalRead::kind` that returns `UniversalKind` enum

* fixup! Implement io_uring-specialized `ImmutableDenseVectors::for_each_in_batch_async`

Use `UniversalRead::kind` instead of `type_id`

* fixup! Implement io_uring-specialized `ChunkedVectors::for_each_in_batch_async`

Use `UniversalRead::kind` instead of `type_id`

* review: rename point_id -> point_offset to match the type [skip-ci]

---------

Co-authored-by: generall <[email protected]>
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