jtuglu-netflix commented on code in PR #17847:
URL: https://github.com/apache/druid/pull/17847#discussion_r2066822234
##########
server/src/main/java/org/apache/druid/segment/realtime/SegmentGenerationMetrics.java:
##########
@@ -55,6 +56,23 @@ public class SegmentGenerationMetrics
private final AtomicLong maxSegmentHandoffTime = new
AtomicLong(NO_EMIT_SEGMENT_HANDOFF_TIME);
+ // Message gap accounting
+ private final AtomicLong minMessageGap = new AtomicLong(Long.MAX_VALUE);
+ private final AtomicLong maxMessageGap = new AtomicLong(Long.MIN_VALUE);
+ private final AtomicLong numMessageGap = new AtomicLong(0);
+ private final AtomicDouble avgMessageGap = new AtomicDouble(0);
Review Comment:
> If we keep two separate atomic fields, the snapshotting can potentially be
inconsistent due to race conditions.
Actually, from my understanding, this should never happen. There is a single
writer to these fields(a task is single threaded, and has 1 row appenderator),
and potentially multiple readers (at the moment it's a single reader). The
reader threads simply look at the latter of these atomic fields. The "worst"
case is the avg computation will be 1 row behind.
That being said, I did try your suggestion before and it was a bit slower,
so I opted for this approach:
pair:
```
Benchmark
(enableMessageGapMetrics) Mode Cnt Score Error Units
SegmentGenerationMetricsBenchmark.benchmarkMultipleReportMaxSegmentHandoffTime
true avgt 2 1.688 ns/op
SegmentGenerationMetricsBenchmark.benchmarkMultipleReportMaxSegmentHandoffTime
false avgt 2 1.701 ns/op
SegmentGenerationMetricsBenchmark.benchmarkMultipleReportMessageGap
true avgt 2 11.681 ns/op
SegmentGenerationMetricsBenchmark.benchmarkMultipleReportMessageGap
false avgt 2 11.836 ns/op
```
two atomics:
```
Benchmark
(enableMessageGapMetrics) Mode Cnt Score Error Units
SegmentGenerationMetricsBenchmark.benchmarkMultipleReportMaxSegmentHandoffTime
true avgt 2 1.690 ns/op
SegmentGenerationMetricsBenchmark.benchmarkMultipleReportMaxSegmentHandoffTime
false avgt 2 1.687 ns/op
SegmentGenerationMetricsBenchmark.benchmarkMultipleReportMessageGap
true avgt 2 8.816 ns/op
SegmentGenerationMetricsBenchmark.benchmarkMultipleReportMessageGap
false avgt 2 8.824 ns/op
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]