bereng commented on code in PR #2464:
URL: https://github.com/apache/cassandra/pull/2464#discussion_r1264841232


##########
test/microbench/org/apache/cassandra/test/microbench/DeletionTimeDeSerBench.java:
##########
@@ -0,0 +1,363 @@
+/*
+ * 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.cassandra.test.microbench;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+import java.nio.file.NoSuchFileException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.cassandra.db.DeletionTime;
+import org.apache.cassandra.db.DeletionTime.Serializer;
+import org.apache.cassandra.io.util.DataInputBuffer;
+import org.apache.cassandra.io.util.DataInputPlus;
+import org.apache.cassandra.io.util.DataOutputBuffer;
+import org.apache.cassandra.io.util.DataOutputStreamPlus;
+import org.apache.cassandra.io.util.FileInputStreamPlus;
+import org.apache.cassandra.io.util.FileOutputStreamPlus;
+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.State;
+import org.openjdk.jmh.annotations.TearDown;
+import org.openjdk.jmh.annotations.Threads;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.infra.Blackhole;
+
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@Warmup(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS)
+@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
+@Fork(value = 3, jvmArgsAppend = "-Xmx512M")
+@Threads(1)
+@State(Scope.Benchmark)
+public class DeletionTimeDeSerBench
+{
+    final static int BUFFER_SIZE = 1024 * 1024;
+    final static int DT_STD_SIZE = 8 + 4; // Long + Int
+
+    final static Random random = new Random(100);
+    final static List<DeletionTime> TEST_DTS_70PC_LIVE = generateDTs(7);
+    final static List<DeletionTime> TEST_DTS_30PC_LIVE = generateDTs(3);
+
+    // Parameters
+    final static String ncSstableParam = "NC";
+    final static String oaSstableParam = "OA";
+    @Param({ ncSstableParam, oaSstableParam })
+    String sstableParam;
+
+    final static String live70PcParam = "70PcLive";
+    final static String live30PcParam = "30PcLive";
+    @Param({ live70PcParam, live30PcParam })
+    String liveDTPcParam;
+
+    final static String RAMParam = "RAM";
+    final static String diskParam = "Disk";
+    @Param({ RAMParam,  diskParam })
+    String diskRAMParam;
+
+    // Files
+    File serMMapedFile = new File(DeletionTimeDeSerBench.class + "_Sermmap");
+    ByteBuffer serMMap = allocateMmapedByteBuffer(serMMapedFile, BUFFER_SIZE);
+    File deserMMapedFile = new File(DeletionTimeDeSerBench.class + 
"_Desermmap");
+    ByteBuffer deserMMap = allocateMmapedByteBuffer(deserMMapedFile, 
BUFFER_SIZE);
+    File diskFile = new File(DeletionTimeDeSerBench.class + "_DTBenchTest");
+
+    @TearDown
+    public void tearDown()
+    {
+        serMMapedFile.delete();
+        deserMMapedFile.delete();
+        diskFile.delete();
+    }
+
+    @Benchmark
+    public void testE2ESerializeDT(final Blackhole bh) throws IOException
+    {
+        ByteBuffer buffer = serMMap;
+        Serializer serializer = getSerializer(sstableParam);
+        List<DeletionTime> dts = getDTs(liveDTPcParam);
+        
+        try(DataOutputStreamPlus out = getSerOut(diskRAMParam, serMMap))
+        {
+            for (int i = 0, m = dts.size(); i < m; i++)

Review Comment:
   We talked offline and some jmh confirms the plain for seems to perform 
better. Fixed in the latest commit already. Resolving but feel free to reopen 
if needed.



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