Skip to content

more stop flags#7531

Merged
timvisee merged 7 commits intodevfrom
more-stop-flags
Nov 14, 2025
Merged

more stop flags#7531
timvisee merged 7 commits intodevfrom
more-stop-flags

Conversation

@generall
Copy link
Member

iter_filtered_points under some special conditions could consume significant resources and didn't respect stopflag in all cases.
Now it does.

I went ahead with another implementation of stopable iterator, because it is easier and apparently also slightly faster (i did benchmark).

I tried to remove newly introduced double checking where I spotted it.

Also we want to check stopflag right after starting search, cause it could have become outdated while waiting in runtime queue.

@generall generall requested review from coszio and timvisee November 13, 2025 19:42
Copy link
Member Author

Choose a reason for hiding this comment

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

main changes in this file

@generall generall added the release:1.16.0 Pull requests that should be merged for the Qdrant 1.16.0 release. label Nov 13, 2025
coderabbitai[bot]

This comment was marked as resolved.

Copy link
Contributor

@coszio coszio left a comment

Choose a reason for hiding this comment

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

I ran the benchmark locally after introducing a couple more black_boxes

It does have better performance

Image

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

Copy link
Member

@timvisee timvisee left a comment

Choose a reason for hiding this comment

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

🙌

Comment on lines +21 to +25
// AI says, that if atomic is not updated frequently,
// it is cheap enough to check it on every iteration.
if self.is_stopped.load(Ordering::Relaxed) {
return None;
}
Copy link
Member

Choose a reason for hiding this comment

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

So here's a stupid idea:

I'm curious if we could just ignore atomics here and concurrently set the boolean.

It'd be cheaper by not using atomic operations, at the cost of potentially 'recognizing' the changed flag a bit later due to local caches.

Copy link
Member

Choose a reason for hiding this comment

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

Turns out the non-atomic variant is exactly the same for reads on x86_64 and ARM:

https://rust.godbolt.org/z/oe4f17xEo

Thanks @xzfc !

fn next(&mut self) -> Option<Self::Item> {
// AI says, that if atomic is not updated frequently,
// it is cheap enough to check it on every iteration.
if self.is_stopped.load(Ordering::Relaxed) {
Copy link
Member

Choose a reason for hiding this comment

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

I also checked the unlikely and cold_path intrinsic just for fun, but they aren't stable yet :(

@qdrant qdrant deleted a comment from coderabbitai bot Nov 14, 2025
@timvisee timvisee merged commit ccabe47 into dev Nov 14, 2025
16 checks passed
@timvisee timvisee deleted the more-stop-flags branch November 14, 2025 09:58
@agourlay
Copy link
Member

Thanks for the benchmarks supporting the change 👍

timvisee added a commit that referenced this pull request Nov 14, 2025
* add stopflag check into query_points of payload index

* propagate stopflag more

* fmt

* bench: compare better against no atomic

* use stoppable iter with IteratorExt

* clippy

* Add cancelled error helper

---------

Co-authored-by: Luis Cossío <luis.cossio@outlook.com>
Co-authored-by: timvisee <tim@visee.me>
@timvisee timvisee mentioned this pull request Nov 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:1.16.0 Pull requests that should be merged for the Qdrant 1.16.0 release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants