Faster+Simpler CanMatchPreFilterSearchPhase #116881
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
CanMatchPreFilterSearchPhaseto 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 :).