jpountz commented on code in PR #14413: URL: https://github.com/apache/lucene/pull/14413#discussion_r2031202618
########## lucene/sandbox/src/java/org/apache/lucene/sandbox/search/QueryProfilerBreakdown.java: ########## @@ -17,46 +17,113 @@ package org.apache.lucene.sandbox.search; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; import java.util.Collections; +import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import org.apache.lucene.search.Query; import org.apache.lucene.util.CollectionUtil; /** * A record of timings for the various operations that may happen during query execution. A node's * time may be composed of several internal attributes (rewriting, weighting, scoring, etc). */ class QueryProfilerBreakdown { - - /** The accumulated timings for this query node */ - private final QueryProfilerTimer[] timers; + private static final Collection<QueryProfilerTimingType> QUERY_LEVEL_TIMING_TYPE = + Arrays.stream(QueryProfilerTimingType.values()).filter(t -> !t.isSliceLevel()).toList(); + private final Map<QueryProfilerTimingType, QueryProfilerTimer> queryProfilerTimers; + private final ConcurrentMap<Long, QuerySliceProfilerBreakdown> queryThreadBreakdowns; /** Sole constructor. */ public QueryProfilerBreakdown() { - timers = new QueryProfilerTimer[QueryProfilerTimingType.values().length]; - for (int i = 0; i < timers.length; ++i) { - timers[i] = new QueryProfilerTimer(); + queryProfilerTimers = new HashMap<>(); Review Comment: Or use an EnumMap? ########## lucene/sandbox/src/java/org/apache/lucene/sandbox/search/QueryProfilerTimer.java: ########## @@ -33,9 +33,21 @@ * </pre> */ class QueryProfilerTimer { - private boolean doTiming; - private long timing, count, lastCount, start; + private long timing, count, lastCount, start, earliestTimerStartTime; Review Comment: This `earliestTimerStartTime` was useful when breaking down by slice, I'm not sure it's still useful when breaking down by thread? ########## lucene/sandbox/src/java/org/apache/lucene/sandbox/search/QueryProfilerTimingType.java: ########## @@ -21,16 +21,29 @@ /** This enum breaks down the query into different sections to describe what was timed. */ public enum QueryProfilerTimingType { - CREATE_WEIGHT, - COUNT, - BUILD_SCORER, - NEXT_DOC, - ADVANCE, - MATCH, - SCORE, - SHALLOW_ADVANCE, - COMPUTE_MAX_SCORE, - SET_MIN_COMPETITIVE_SCORE; + COUNT(true), + BUILD_SCORER(true), + NEXT_DOC(true), + ADVANCE(true), + MATCH(true), + SCORE(true), + SHALLOW_ADVANCE(true), + COMPUTE_MAX_SCORE(true), + SET_MIN_COMPETITIVE_SCORE(true), + + // IMPORTANT: Global timer types must be defined after all the + // slice level timers to preserve the contiguous enum ordinals + CREATE_WEIGHT(false); + + private boolean sliceLevel; Review Comment: We don't need this anymore now that we're no longer breaking down by slice? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org