jtuglu-netflix commented on code in PR #17847:
URL: https://github.com/apache/druid/pull/17847#discussion_r2051631739


##########
server/src/main/java/org/apache/druid/segment/realtime/SegmentGenerationMetrics.java:
##########
@@ -105,6 +123,14 @@ public void setSinkCount(long sinkCount)
     this.sinkCount.set(sinkCount);
   }
 
+  public void reportMessageGap(final long messageGap)
+  {
+    final long numEvent = this.numMessageGap.incrementAndGet();
+    this.avgMessageGap.getAndUpdate(oldAvg -> oldAvg + ((messageGap - oldAvg) 
/ numEvent));

Review Comment:
   > Won't it be more efficient to just keep a running sum? Then only calculate 
the avg using numEvent when we get the average
   
   In short, given the emission period is variable, we could overflow on the 
sum. I figured the simplest solution was taking the performance penalty of 
floating pt division. Other offline alternatives seemed a bit more complicated 
like sampling/caching the gap values in a ring buffer and moving the avg 
calculation to emission-time, etc.



-- 
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]

Reply via email to