Skip to content

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

original-brownbear
Copy link
Member

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.

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.
@elasticsearchmachine elasticsearchmachine added Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.1.0 labels Apr 11, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

} finally {
toConsume.forEachRemaining(QuerySearchResult::releaseAggs);
}
}

private static AggregatorsReducer createReducer(int resultSetSize, AggregationReduceContext reduceContext, InternalAggregations first) {
Copy link
Member Author

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 :)

@javanna javanna added the :Search Foundations/Search Catch all for Search Foundations label Apr 14, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch label Apr 14, 2025
@elasticsearchmachine
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Aggregations Aggregations >non-issue :Search Foundations/Search Catch all for Search Foundations Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants