Skip to content

Conversation

@original-brownbear
Copy link
Contributor

We should use DelayableWriteable here as well just like we do with per-shard results. The heap savings of making use of this tool are quite significant at times and without using it we could actually regress in terms of heap use relative to non-batched execution in corner cases of a low but larger than one number of shards per node (because the serialized representation can be considerably smaller than the materialized one, outweighing the gains from partial reduction in some cases).

We should use DelayableWriteable here as well just like we do with per-shard results.
The heap savings of making use of this tool are quite significant at times and without
using it we could actually regress in terms of heap use relative to non-batched execution
in corner cases of a low but larger than one number of shards per node.
@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine elasticsearchmachine added the Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch label Apr 15, 2025
);
try {
Iterator<InternalAggregations> aggsIter = Iterators.map(toConsume, r -> {
try (var res = r.consumeAggs()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This made me realize and fixes a small mistake on the left hand side as well. We don't need to retain the buffer after a call to expand(), not sure why I thought that before 🤦‍♂️ ... so we can save a bit of heap on average here by releasing before forwarding to the reducer.

@javanna
Copy link
Member

javanna commented Apr 16, 2025

Change is good, I do think that we need unit tests for QueryPhaseResultConsumer. Not the first time this need comes up.

@original-brownbear
Copy link
Contributor Author

Thanks Luca!

@original-brownbear original-brownbear merged commit 880aa52 into elastic:main Apr 16, 2025
16 of 17 checks passed
@original-brownbear original-brownbear deleted the delay-merged-aggs branch April 16, 2025 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport pending >non-issue :Search Foundations/Search Catch all for Search Foundations Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants