dimitarndimitrov commented on code in PR #16949:
URL: https://github.com/apache/kafka/pull/16949#discussion_r1753395793

##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/metrics/HdrHistogram.java:
##########
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.coordinator.group.metrics;
+
+import org.HdrHistogram.Histogram;
+import org.HdrHistogram.Recorder;
+import org.HdrHistogram.ValueRecorder;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * <p>A wrapper on top of the HdrHistogram API. It handles writing to the 
histogram by delegating
+ * to an internal {@link ValueRecorder} implementation, and reading from the 
histogram by
+ * efficiently implementing the retrieval of up-to-date histogram data.
+ *
+ * <p>Note that all APIs expect a timestamp which is used by the histogram to 
discard decaying data
+ * and determine when the snapshot from which the histogram metrics are 
calculated should be
+ * refreshed.
+ */
+public final class HdrHistogram {

Review Comment:
   > Is HdrHistogram better than Yammer histogram?
   
   @junrao I think we have good evidence that it is.
   The included unit tests illustrate a bit how HdrHistogram is more accurate 
than the Yammer histogram, and JMH benchmarks point to significantly faster 
writes (I have concrete numbers from internal tests, but I'll try to include a 
JMH benchmark in the bugfix PR I'm preparing, and we can look at the results it 
gives us).
   
   > If it's better, why not use it more broadly on the server side? What's our 
recommendation for new developers who want to add histogram metrics on the 
server side?
   
   I personally would vouch for that. Part of the motivation for originally 
implementing this was seamlessly replacing the Yammer histogram usages in 
`RequestMetrics`, which can be noticeable in profiles in high-load scenarios, 
and using a more performant histogram could be a nice little win in such cases.
   
   All I'm saying is that we don't claim to have convinced the community 
already, and don't want to inadvertently undermine the other "new histogram" 
effort we were made aware of, before there's been a discussion.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to