You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2020/02/04 22:22:45 UTC

[GitHub] [druid] jihoonson commented on a change in pull request #9308: Add MemoryOpenHashTable, a table similar to ByteBufferHashTable.

jihoonson commented on a change in pull request #9308: Add MemoryOpenHashTable, a table similar to ByteBufferHashTable.
URL: https://github.com/apache/druid/pull/9308#discussion_r374891624
 
 

 ##########
 File path: benchmarks/src/main/java/org/apache/druid/benchmark/MemoryBenchmark.java
 ##########
 @@ -0,0 +1,169 @@
+/*
+ * 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.druid.benchmark;
+
+import org.apache.datasketches.memory.WritableMemory;
+import org.apache.druid.common.config.NullHandling;
+import org.apache.druid.query.groupby.epinephelinae.collection.HashTableUtils;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.infra.Blackhole;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+
+@State(Scope.Benchmark)
+@Fork(value = 1)
+@Warmup(iterations = 10)
+@Measurement(iterations = 15)
+public class MemoryBenchmark
+{
+  static {
+    NullHandling.initializeForTests();
+  }
+
+  @Param({"4", "5", "8", "9", "12", "16", "31", "32", "64", "128"})
+  public int numBytes;
+
+  @Param({"offheap"})
+  public String where;
+
+  private ByteBuffer buffer1;
+  private ByteBuffer buffer2;
+  private ByteBuffer buffer3;
+  private WritableMemory memory1;
+  private WritableMemory memory2;
+  private WritableMemory memory3;
+
+  @Setup
+  public void setUp()
+  {
+    if ("onheap".equals(where)) {
+      buffer1 = ByteBuffer.allocate(numBytes).order(ByteOrder.nativeOrder());
+      buffer2 = ByteBuffer.allocate(numBytes).order(ByteOrder.nativeOrder());
+      buffer3 = ByteBuffer.allocate(numBytes).order(ByteOrder.nativeOrder());
+    } else if ("offheap".equals(where)) {
+      buffer1 = ByteBuffer.allocateDirect(numBytes).order(ByteOrder.nativeOrder());
+      buffer2 = ByteBuffer.allocateDirect(numBytes).order(ByteOrder.nativeOrder());
+      buffer3 = ByteBuffer.allocateDirect(numBytes).order(ByteOrder.nativeOrder());
+    }
+
+    memory1 = WritableMemory.wrap(buffer1, ByteOrder.nativeOrder());
+    memory2 = WritableMemory.wrap(buffer2, ByteOrder.nativeOrder());
+    memory3 = WritableMemory.wrap(buffer3, ByteOrder.nativeOrder());
+
+    // Scribble in some randomy but consistent (same seed) garbage.
 
 Review comment:
   randomy -> randomly?

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

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org