Skip to content

Commit

Permalink
Fix slice collectors to leaves association with profile enabled (open…
Browse files Browse the repository at this point in the history
…search-project#11134)

Signed-off-by: Ticheng Lin <[email protected]>
  • Loading branch information
ticheng-aws committed Nov 9, 2023
1 parent 0ba5d58 commit 1c1cec3
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,26 @@ public Map<String, Long> toBreakdownMap() {
// creates a new weight and breakdown map for each rewritten query. This new breakdown map captures the timing information for
// the new rewritten query. The sliceCollectorsToLeaves is empty because this breakdown for rewritten query gets created later
// in search leaf path which doesn't have collector. Also, this is not needed since this breakdown is per leaf and there is no
// concurrency involved. An empty sliceCollectorsToLeaves could also happen in the case of early termination.
// concurrency involved.
AbstractProfileBreakdown<QueryTimingType> breakdown = contexts.values().iterator().next();
queryNodeTime = breakdown.toNodeTime() + createWeightTime;
maxSliceNodeTime = 0L;
minSliceNodeTime = 0L;
avgSliceNodeTime = 0L;
if (contexts.size() > 1) {
// If the leaf counts in contexts map don't match those in sliceCollectorsToLeaves, this means that the current
// node is outside the concurrent search path, which occurred before the contextIndexSearcher::searchLeaf.
// For example, in the post filter query, we may create a profile node during filtered collector context creation.
// In this case, as there is no concurrent implementation, we can simply return the accumulated breakdown result
// instead of the statistical result.
final Map<String, Long> queryBreakdownMap = new HashMap<>(topLevelBreakdownMapWithWeightTime);
for (final AbstractProfileBreakdown<QueryTimingType> context : contexts.values()) {
for (final Map.Entry<String, Long> entry : context.toBreakdownMap().entrySet()) {
queryBreakdownMap.merge(entry.getKey(), entry.getValue(), Long::sum);
}
}
return queryBreakdownMap;
}
Map<String, Long> queryBreakdownMap = new HashMap<>(breakdown.toBreakdownMap());
queryBreakdownMap.put(QueryTimingType.CREATE_WEIGHT.toString(), createWeightTime);
queryBreakdownMap.put(QueryTimingType.CREATE_WEIGHT + TIMING_TYPE_COUNT_SUFFIX, 1L);
Expand Down

0 comments on commit 1c1cec3

Please sign in to comment.