Skip to content

Commit

Permalink
Fix query profiler test basic with concurrent execution
Browse files Browse the repository at this point in the history
Signed-off-by: Ticheng Lin <[email protected]>
  • Loading branch information
ticheng-aws committed Nov 29, 2023
1 parent 6bc0cd6 commit 66a7b7f
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ Map<Collector, Map<String, Long>> buildSliceLevelBreakdown() {
// doesn't represent an actual timing; rather, it indicates no invocations.
continue;
}
if (sliceLeafTimingTypeStartTime == 0L && currentSliceBreakdown.get(timingTypeCountKey) == 0L) {
// This is the case where a slice has 0 invocations for a breakdown type from its leading leaves.
// We should skip the slice start/end time computation since 0 does not represent an actual timing.
continue;
}
currentSliceBreakdown.compute(
timingTypeSliceStartTimeKey,
(key, value) -> (value == null) ? sliceLeafTimingTypeStartTime : Math.min(value, sliceLeafTimingTypeStartTime)
Expand All @@ -216,6 +221,12 @@ Map<Collector, Map<String, Long>> buildSliceLevelBreakdown() {
(key, value) -> (value == null) ? sliceLeafTimingTypeEndTime : Math.max(value, sliceLeafTimingTypeEndTime)
);
}
// Only when we've checked all leaves in a slice and still find no invocations, then we should set the slice start/end time
// to the default 0L.
if (currentSliceBreakdown.get(timingTypeCountKey) == 0L) {
currentSliceBreakdown.put(timingTypeSliceStartTimeKey, 0L);
currentSliceBreakdown.put(timingTypeSliceEndTimeKey, 0L);
}
// compute sliceMaxEndTime as max of sliceEndTime across all timing types
sliceMaxEndTime = Math.max(sliceMaxEndTime, currentSliceBreakdown.getOrDefault(timingTypeSliceEndTimeKey, Long.MIN_VALUE));
long currentSliceStartTime = currentSliceBreakdown.getOrDefault(timingTypeSliceStartTimeKey, Long.MAX_VALUE);
Expand Down

0 comments on commit 66a7b7f

Please sign in to comment.