-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Inline aggregation logic into QueryPhaseResultConsumer #126730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Inline aggregation logic into QueryPhaseResultConsumer #126730
Conversation
This refactoring removes some needless indirection but more importantly, it sets up a significant improvement to aggs: passing them to the reducer as they become available and without retaining them in a list (serialized or materialized) any longer than necessary. I chose to do this step first to make that change shorter and more focussed as it will involve a bit of non-trivial concurrency.
Pinging @elastic/es-analytical-engine (Team:Analytics) |
} finally { | ||
toConsume.forEachRemaining(QuerySearchResult::releaseAggs); | ||
} | ||
} | ||
|
||
private static AggregatorsReducer createReducer(int resultSetSize, AggregationReduceContext reduceContext, InternalAggregations first) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The follow-up from this would be to create the reducer up-front and in the size of either the final resultset (if no partial reduces come into play) or the size of the next partial reduce and consume aggregations directly into the aggregator as results come in.
I chose to do this in 2 steps as making this performance while receiving results concurrently will require forcing all results onto a single thread which is little code but non-trivial to reason about :)
This change gets us close enough to make it little code though :)
Pinging @elastic/es-search-foundations (Team:Search Foundations) |
…umer' into inline-into-query-phase-res-consumer
This refactoring removes some needless indirection but more importantly, it sets up a significant improvement to aggs: passing them to the reducer as they become available and without retaining them in a list (serialized or materialized) any longer than necessary.
I chose to do this step first to make that change shorter and more focussed as it will involve a bit of non-trivial concurrency.