mayankkunwar commented on code in PR #6444:
URL: https://github.com/apache/artemis/pull/6444#discussion_r3281895153


##########
artemis-ffm/src/test/java/org/apache/artemis/nativo/jlibaio/test/jmh/AioCompareBenchmark.java:
##########
@@ -0,0 +1,193 @@
+/*
+ * 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.artemis.nativo.jlibaio.test.jmh;
+
+import org.apache.artemis.nativo.jlibaio.LibaioContext;
+import org.apache.artemis.nativo.jlibaio.LibaioFile;
+import org.apache.artemis.nativo.jlibaio.SubmitInfo;
+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.Param;
+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 java.io.File;
+import java.lang.foreign.MemorySegment;
+import java.nio.ByteBuffer;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+@State(Scope.Benchmark)
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@Fork(value = 2)
+@Warmup(iterations = 5, time = 200, timeUnit = TimeUnit.MILLISECONDS)
+@Measurement(iterations = 10, time = 200, timeUnit = TimeUnit.MILLISECONDS)
+public class AioCompareBenchmark {
+
+   private static final int FILE_SIZE = 10000 * 4096;
+   private static final int BLOCK_SIZE = 4096;
+
+   @Param({"2048"})
+   private int LIBAIO_QUEUE_SIZE;
+
+   @Param({"10000"})
+   private int recordCount;
+
+   private File file;
+   private LibaioContext<SubmitInfo> control;
+   private LibaioFile<SubmitInfo> libaioFile;
+
+   private MemorySegment headerSegment;
+   private ByteBuffer headerBuffer;
+
+   private MemorySegment recordSegment;
+   private ByteBuffer recordBuffer;
+
+   private final AtomicReference<CountDownLatch> currentLatch = new 
AtomicReference<>();
+
+   private Thread pollThread;
+   private volatile boolean polling = true;
+
+   private final SubmitInfo callback = new SubmitInfo() {
+      @Override
+      public void onError(int errno, String message) {
+         //ignore
+      }
+
+      @Override
+      public void done() {
+         CountDownLatch latch = currentLatch.get();
+         if (latch != null) {
+            latch.countDown();
+         }
+      }
+   };
+
+   private long fileId = 1L;
+
+   @Setup(Level.Trial)
+   public void setuo() throws Exception {
+      file = File.createTempFile("aio-bench-", ".dat");
+
+      control = new LibaioContext<>(LIBAIO_QUEUE_SIZE, true, true);
+      libaioFile = control.openFile(file, true);
+
+      //one-time file initialization
+      libaioFile.fallocate(FILE_SIZE);
+
+      headerSegment = LibaioContext.newAlignedBuffer(BLOCK_SIZE, BLOCK_SIZE);
+      headerBuffer = headerSegment.asByteBuffer();
+
+      recordSegment = LibaioContext.newAlignedBuffer(BLOCK_SIZE, BLOCK_SIZE);
+      recordBuffer = recordSegment.asByteBuffer();
+
+      initRecord(headerBuffer);   // filling the record clock with 1
+      initRecord(recordBuffer);   // filling the record clock with 1
+
+      fillHeader(fileId);
+      updateRecord(recordBuffer, fileId, 0L);
+
+      polling = true;
+      pollThread = new Thread(() -> {
+         while (polling && !Thread.currentThread().isInterrupted()) {
+            try {
+               control.poll();
+            } catch (Throwable e) {
+               if (polling) {
+                  throw new RuntimeException(e);
+               }
+               break;
+            }
+         }
+      }, "aio-jmh-poll-thread");
+      pollThread.setDaemon(true);
+      pollThread.start();
+   }
+
+   @TearDown(Level.Trial)
+   public void tearDown() throws Exception {
+      polling = false;
+      if (pollThread != null) {
+         pollThread.interrupt();
+         pollThread.join(TimeUnit.SECONDS.toMillis(10));
+      }
+
+      if (libaioFile != null) {
+         libaioFile.close();
+      }
+      if (control != null) {
+         control.close();
+      }
+      if (headerSegment != null && headerSegment.address() != 0) {
+         LibaioContext.freeBuffer(headerSegment);
+      }
+      if (recordSegment != null && recordSegment.address() != 0) {
+         LibaioContext.freeBuffer(recordSegment);
+      }
+      if (file != null) {
+         file.delete();
+      }
+   }
+
+   @Benchmark
+   public void writeHeaderAndRecord() throws Exception {
+      CountDownLatch latch = new CountDownLatch(recordCount * 100);
+      currentLatch.set(latch);
+
+      try {
+         //            fillHeader(fileId);
+         //            libaioFile.write(0L, BLOCK_SIZE, headerBuffer, 
callback);

Review Comment:
   Sure, let me remove them.



##########
artemis-ffm/src/test/java/org/apache/artemis/nativo/jlibaio/test/jmh/AioCompareBenchmark.java:
##########
@@ -0,0 +1,193 @@
+/*
+ * 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.artemis.nativo.jlibaio.test.jmh;
+
+import org.apache.artemis.nativo.jlibaio.LibaioContext;
+import org.apache.artemis.nativo.jlibaio.LibaioFile;
+import org.apache.artemis.nativo.jlibaio.SubmitInfo;
+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.Param;
+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 java.io.File;
+import java.lang.foreign.MemorySegment;
+import java.nio.ByteBuffer;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+@State(Scope.Benchmark)
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@Fork(value = 2)
+@Warmup(iterations = 5, time = 200, timeUnit = TimeUnit.MILLISECONDS)
+@Measurement(iterations = 10, time = 200, timeUnit = TimeUnit.MILLISECONDS)
+public class AioCompareBenchmark {

Review Comment:
   okay



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