Skip to content

Conversation

@original-brownbear
Copy link
Contributor

@original-brownbear original-brownbear commented Nov 16, 2024

If this is too many changes in one PR, happy to split this up. We should fix this though, it's the reason why we're seeing slow warn logs for can_match responses in logs.

This redoes CanMatchPreFilterSearchPhase to be simpler and without the needless heavy locking.
We were locking on every shard result which could introduce a lot of contention (on the transport threads!) when a large number of data nodes (especially when they hold large shard counts) are queried. We probably could even do without the volatile in some cases but either way, this commit does away with any contention on the results since we will never access the same cell in the result array from more than a single thread.
There is no need to have a bitset here and deal with the synchronization it entails when we at the same time also set up two arrays of shard_count length and only need a single array to begin with.
=> share array for failures, min-max and matches, remove all synchronization, further simplify the code because we don't need the results object if all results just go to a single array :).

This redose CanMatchPreFilterSearchPhase to be simpler and without the
needless heavy locking.
We were locking on every shard result which could introduce a lot of
contention when a large number of data nodes (especially when they hold
large shard counts) are queried. We probably could even do without the
volatile in some cases but either way, this commit does away with any
contention on the results since we will never access the same cell in
the result array from more than a single thread.
There is no need to have a bitset here and deal with the synchronization
it entails when we at the same time also set up two arrays of
shard_count length and only need a single array to begin with.
=> share array for failures, min-max and matches, remove all
synchronization, further simplify the code.
@original-brownbear original-brownbear added >non-issue :Search Foundations/Search Catch all for Search Foundations labels Nov 16, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-foundations (Team:Search Foundations)

@elasticsearchmachine elasticsearchmachine added Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch v9.0.0 labels Nov 16, 2024
original-brownbear added a commit that referenced this pull request Jan 9, 2025
We don't need the result to be a `SearchPhaseResults`. In fact,
there is no reason for it to be a nested class in the first place.
Just flatten it into the phase itself and synchronize on `this`.

This is just a step on the way to #116881 that makes that PR much easier to review I believe.
elasticsearchmachine pushed a commit that referenced this pull request Mar 14, 2025
We don't need the result to be a `SearchPhaseResults`. In fact,
there is no reason for it to be a nested class in the first place.
Just flatten it into the phase itself and synchronize on `this`.

This is just a step on the way to #116881 that makes that PR much easier to review I believe.
@original-brownbear
Copy link
Contributor Author

This can be closed, no need to invest more in can_match when #121885 is incoming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>non-issue :Search Foundations/Search Catch all for Search Foundations Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants