activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-5578 - enable org.apache.activemq.kahaDB.files.skipMetadataUpdate for tests to validate. remove some redundant call to limit and add latencey test to validate the need for outof band or pool
Date Fri, 22 Apr 2016 11:29:53 GMT
Repository: activemq
Updated Branches:
  refs/heads/master 3e7847aea -> 930a74c69


https://issues.apache.org/jira/browse/AMQ-5578 - enable org.apache.activemq.kahaDB.files.skipMetadataUpdate
for tests to validate. remove some redundant call to limit and add latencey test to validate
the need for outof band or pool allocation of journals


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/930a74c6
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/930a74c6
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/930a74c6

Branch: refs/heads/master
Commit: 930a74c696bb0160473a28720407b0952d461cbe
Parents: 3e7847a
Author: gtully <gary.tully@gmail.com>
Authored: Fri Apr 22 12:29:31 2016 +0100
Committer: gtully <gary.tully@gmail.com>
Committed: Fri Apr 22 12:29:31 2016 +0100

----------------------------------------------------------------------
 .../store/kahadb/disk/journal/Journal.java      |  5 +-
 .../PreallocationJournalLatencyTest.java        | 81 ++++++++++++++++++++
 pom.xml                                         |  1 +
 3 files changed, 83 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/930a74c6/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/journal/Journal.java
----------------------------------------------------------------------
diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/journal/Journal.java
b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/journal/Journal.java
index e186e19..da0d5b4 100644
--- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/journal/Journal.java
+++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/journal/Journal.java
@@ -62,7 +62,7 @@ public class Journal {
 
     private static final int MAX_BATCH_SIZE = 32*1024*1024;
 
-    private static final int PREALLOC_CHUNK_SIZE = 1 << 20;
+    private static final int PREALLOC_CHUNK_SIZE = 1024*1024;
 
     // ITEM_HEAD_SPACE = length + type+ reserved space + SOR
     public static final int RECORD_HEAD_SPACE = 4 + 1;
@@ -282,7 +282,6 @@ public class Journal {
 
     private void doPreallocationZeros(RecoverableRandomAccessFile file) {
         ByteBuffer buffer = ByteBuffer.allocate(maxFileLength);
-        buffer.limit(maxFileLength);
 
         try {
             FileChannel channel = file.getChannel();
@@ -326,8 +325,6 @@ public class Journal {
     private void doPreallocationChunkedZeros(RecoverableRandomAccessFile file) {
 
         ByteBuffer buffer = ByteBuffer.allocate(PREALLOC_CHUNK_SIZE);
-        buffer.position(0);
-        buffer.limit(PREALLOC_CHUNK_SIZE);
 
         try {
             FileChannel channel = file.getChannel();

http://git-wip-us.apache.org/repos/asf/activemq/blob/930a74c6/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/disk/journal/PreallocationJournalLatencyTest.java
----------------------------------------------------------------------
diff --git a/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/disk/journal/PreallocationJournalLatencyTest.java
b/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/disk/journal/PreallocationJournalLatencyTest.java
new file mode 100644
index 0000000..35ab321
--- /dev/null
+++ b/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/disk/journal/PreallocationJournalLatencyTest.java
@@ -0,0 +1,81 @@
+/**
+ * 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.activemq.store.kahadb.disk.journal;
+
+import org.apache.activemq.management.TimeStatisticImpl;
+import org.apache.activemq.store.kahadb.KahaDBStore;
+import org.apache.activemq.util.ByteSequence;
+import org.apache.activemq.util.Wait;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.Random;
+
+import static org.junit.Assert.assertTrue;
+
+public class PreallocationJournalLatencyTest {
+
+    private static final Logger LOG = LoggerFactory.getLogger(PreallocationJournalLatencyTest.class);
+    final Random rand = new Random();
+
+    @Test
+    public void preallocationLatency() throws Exception {
+
+        TimeStatisticImpl sparse = executeTest(Journal.PreallocationStrategy.SPARSE_FILE.name());
+        TimeStatisticImpl chunked_zeros = executeTest(Journal.PreallocationStrategy.CHUNKED_ZEROS.name());
+        TimeStatisticImpl zeros = executeTest(Journal.PreallocationStrategy.ZEROS.name());
+        LOG.info("  sparse: " + sparse);
+        LOG.info(" chunked: " + chunked_zeros);
+        LOG.info("   zeros: " + zeros);
+
+    }
+
+    private TimeStatisticImpl executeTest(String preallocationStrategy)throws Exception {
+        int randInt = rand.nextInt(100);
+        File dataDirectory = new File("./target/activemq-data/kahadb" + randInt);
+
+        KahaDBStore store = new KahaDBStore();
+        store.deleteAllMessages();
+        store.setDirectory(dataDirectory);
+        store.setPreallocationStrategy(preallocationStrategy);
+        store.start();
+
+        final File journalLog = new File(dataDirectory, "db-1.log");
+        assertTrue("file exists", Wait.waitFor(new Wait.Condition() {
+            @Override
+            public boolean isSatisified() throws Exception {
+                return journalLog.exists();
+            }
+        }));
+
+        final Journal journal = store.getJournal();
+        ByteSequence byteSequence = new ByteSequence(new byte[8*1024]);
+
+        TimeStatisticImpl timeStatistic = new TimeStatisticImpl("append", "duration");
+        for (int i=0;i<300000; i++) {
+            final long start = System.currentTimeMillis();
+            journal.write(byteSequence, true);
+            timeStatistic.addTime(System.currentTimeMillis() - start);
+        }
+        LOG.info("current journal dataFile id: " + journal.getCurrentDataFileId());
+        store.stop();
+        return timeStatistic;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/activemq/blob/930a74c6/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index a83f91b..efc4aef 100755
--- a/pom.xml
+++ b/pom.xml
@@ -1204,6 +1204,7 @@
             <failIfNoTests>false</failIfNoTests>
             <systemPropertyVariables>
                 <java.awt.headless>true</java.awt.headless>
+                <org.apache.activemq.kahaDB.files.skipMetadataUpdate>true</org.apache.activemq.kahaDB.files.skipMetadataUpdate>
             </systemPropertyVariables>
             <argLine>-Xmx512m</argLine>
           </configuration>


Mime
View raw message