Skip to content

Commit 41b86a0

Browse files
committed
Updated javadocs on estimates and replaced 1.5-size with 0.5
1 parent 51fe8fc commit 41b86a0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

server/src/main/java/org/elasticsearch/action/search/QueryPhaseResultConsumer.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ public SearchPhaseController.ReducedQueryPhase reduce() throws Exception {
231231
while ((batchedResult = batchedResults.poll()) != null) {
232232
topDocsStats.add(batchedResult.v1());
233233
consumePartialMergeResult(batchedResult.v2(), topDocsList, aggsList);
234+
// Add the estimate of the agg size
234235
addEstimateAndMaybeBreak(batchedResult.v2().estimatedSize);
235236
}
236237
for (QuerySearchResult result : buffer) {
@@ -458,12 +459,13 @@ private long ramBytesUsedQueryResult(QuerySearchResult result) {
458459
* Returns an estimation of the size that a reduce of the provided size
459460
* would take on memory.
460461
* This size is estimated as roughly 1.5 times the size of the serialized
461-
* aggregations that need to be reduced. This estimation can be completely
462-
* off for some aggregations but it is corrected with the real size after
463-
* the reduce completes.
462+
* aggregations that need to be reduced.
463+
* This method expects an already accounted size, so only an extra 0.5x is returned.
464+
* This estimation can be completely off for some aggregations
465+
* but it is corrected with the real size after the reduce completes.
464466
*/
465467
private static long estimateRamBytesUsedForReduce(long size) {
466-
return Math.round(1.5d * size);
468+
return Math.round(0.5d * size);
467469
}
468470

469471
private void consume(QuerySearchResult result, Runnable next) {

0 commit comments

Comments
 (0)