[ 
https://issues.apache.org/jira/browse/GOBBLIN-1087?focusedWorklogId=404859&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-404859
 ]

ASF GitHub Bot logged work on GOBBLIN-1087:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 17/Mar/20 17:07
            Start Date: 17/Mar/20 17:07
    Worklog Time Spent: 10m 
      Work Description: sv2000 commented on pull request #2928: GOBBLIN-1087: 
Track and report histogram of observed lag from Gobblin…
URL: https://github.com/apache/incubator-gobblin/pull/2928#discussion_r393835783
 
 

 ##########
 File path: 
gobblin-modules/gobblin-kafka-common/src/jmh/java/org/apache/gobblin/source/extractor/extract/kafka/HdrHistogramPerformanceBenchmark.java
 ##########
 @@ -0,0 +1,130 @@
+/*
+ * 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.gobblin.source.extractor.extract.kafka;
+
+import java.util.concurrent.TimeUnit;
+import java.util.stream.IntStream;
+
+import org.HdrHistogram.Histogram;
+import org.apache.commons.math3.random.RandomDataGenerator;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.options.ChainedOptionsBuilder;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+
+import lombok.extern.slf4j.Slf4j;
+
+
+/**
+ * A micro-benchmark to measure the time taken to serialize a {@link 
Histogram} instance to its String representation. The
+ * benchmark uses a Random number generator to generate values according to a 
Uniform Distribution, an adversarial pattern
+ * for a Histogram that is likely to produce more count buckets in comparison 
with a skewed distribution. The benchmark
+ * provides an upper bound on memory footprint of the histogram, serialization 
time, as well as the size of the
+ * serialized representation.
+ */
+@Warmup (iterations = 3)
+@Measurement (iterations = 10)
+@BenchmarkMode (value = Mode.AverageTime)
+@Fork (value = 1)
+@OutputTimeUnit (TimeUnit.MILLISECONDS)
+@Slf4j
+public class HdrHistogramPerformanceBenchmark {
+
+  @State (value = Scope.Benchmark)
+  public static class HistogramState {
+    private static long MIN_VALUE = 1;
+    private static long MAX_VALUE = TimeUnit.HOURS.toMillis(24);
+
+    private Histogram histogram1;
+    private Histogram histogram2;
+    private Histogram histogram3;
+    private Histogram histogram4;
+
+    private final RandomDataGenerator random = new RandomDataGenerator();
+
+    @Setup (value = Level.Iteration)
+    public void setUp() {
+      this.histogram1 = buildHistogram(1000000);
+      this.histogram2 = buildHistogram(2000000);
+      this.histogram3 = buildHistogram(4000000);
+      this.histogram4 = buildHistogram(10000000);
 
 Review comment:
   There are 2 ways to address this question:
   1. The Histogram performance itself (e.g. adding a value or memory size) are 
independent of number of samples. They are only dependent on the range of 
values and the precision needed to report a value.  The benchmark numbers 
indeed confirm that the size is indeed constant across different counts and is 
around 150 KB. The benchmark also confirms that the serialization constants are 
also more or less independent of number of samples observed. 
   2. Assuming a typical container processing rates in the order of 10-20 MB/s. 
Assuming records of size 1K, which corresponds to 10-20K records/second, a 
histogram should hold counts for 3-6M records within a flush interval of 5 
minutes. 
   
   I have updated the description of this PR to include results from running 
the benchmark on a Macbook.
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 404859)
    Time Spent: 1h  (was: 50m)

> Track and report histogram of observed lag from Gobblin Kafka pipeline
> ----------------------------------------------------------------------
>
>                 Key: GOBBLIN-1087
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-1087
>             Project: Apache Gobblin
>          Issue Type: Improvement
>          Components: gobblin-kafka
>    Affects Versions: 0.15.0
>            Reporter: Sudarshan Vasudevan
>            Assignee: Shirshanka Das
>            Priority: Major
>             Fix For: 0.15.0
>
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> In this PR, we instrument the KafkaExtractor to track the observed latency of 
> Kafka consumer records processed by the pipeline. Here, observed latency is 
> measured as the time difference between processing time of the record and the 
> original creation time. The latency distribution is tracked in an 
> HdrHistogram, which is serialized into a string when emitted as part of a 
> GobblinTrackingEvent.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to