ESQL: Reserve memory TopN (#134235) #134321
Merged
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.
Tracks the more memory that's involved in topn.
Lucene doesn't track memory usage for TopN and can use a fair bit of it. Try this query:
We attempt to return all million documents from lucene. Is we did this with the compute engine we're track all of the memory usage. With lucene we have to reserve it.
In the case of the query above the sort keys weight 8 bytes each. 40 bytes total. Plus another 72 for Lucene's
FieldDoc. And another 40 at least for copying to the values toFieldDoc. That totals something like 152 bytes a piece. That's 145mb. Worth tracking!Esql Engine TopN
Esql does track memory for topn, but it doesn't track the memory used by the min heap itself. It's just a big array of pointers. But it can get very big!