You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gobblin.apache.org by GitBox <gi...@apache.org> on 2020/03/17 17:07:42 UTC

[GitHub] [incubator-gobblin] sv2000 commented on a change in pull request #2928: GOBBLIN-1087: Track and report histogram of observed lag from Gobblin…

sv2000 commented on a change in 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:
users@infra.apache.org


With regards,
Apache Git Services