jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1527256 - in /jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark: AbstractTest.java BenchmarkRunner.java ConcurrentReadTest.java ConcurrentReadWriteTest.java ConcurrentWriteReadTest.java ConcurrentWriteTest.java
Date Sat, 28 Sep 2013 22:51:06 GMT
Author: jukka
Date: Sat Sep 28 22:51:05 2013
New Revision: 1527256

URL: http://svn.apache.org/r1527256
Log:
OAK-641: Improved benchmark tooling

Improved concurrency tests

Added:
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentWriteReadTest.java
  (with props)
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentWriteTest.java
  (with props)
Modified:
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadTest.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadWriteTest.java

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java?rev=1527256&r1=1527255&r2=1527256&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java
Sat Sep 28 22:51:05 2013
@@ -280,12 +280,9 @@ abstract class AbstractTest extends Benc
             public void run() {
                 while (running) {
                     job.run();
-                    Thread.yield();
                 }
             }
         };
-        thread.setDaemon(true);
-        thread.setPriority(Thread.MIN_PRIORITY);
         thread.start();
         threads.add(thread);
     }

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java?rev=1527256&r1=1527255&r2=1527256&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
Sat Sep 28 22:51:05 2013
@@ -88,6 +88,8 @@ public class BenchmarkRunner {
             new SmallFileWriteTest(),
             new ConcurrentReadTest(),
             new ConcurrentReadWriteTest(),
+            new ConcurrentWriteReadTest(),
+            new ConcurrentWriteTest(),
             new SimpleSearchTest(),
             new SQL2SearchTest(),
             new DescendantSearchTest(),

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadTest.java?rev=1527256&r1=1527255&r2=1527256&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadTest.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadTest.java
Sat Sep 28 22:51:05 2013
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.oak.benchm
 
 import java.util.Random;
 
+import javax.jcr.InvalidItemStateException;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
@@ -30,9 +31,25 @@ public class ConcurrentReadTest extends 
 
     protected static final int NODE_COUNT = 100;
 
-    private static final int READER_COUNT = getScale(20);
+    private final int backgroundReaderCount;
 
-    private Reader reader;
+    private final int backgroundWriterCount;
+
+    private final boolean foregroundIsReader;
+
+    private Runnable foregroundTask;
+
+    protected ConcurrentReadTest(
+            int backgroundReaderCount, int backgroundWriterCount,
+            boolean foregroundIsReader) {
+        this.backgroundReaderCount = backgroundReaderCount;
+        this.backgroundWriterCount = backgroundWriterCount;
+        this.foregroundIsReader = foregroundIsReader;
+    }
+
+    public ConcurrentReadTest() {
+        this(getScale(20), 0, true);
+    }
 
     @Override
     public void beforeSuite() throws Exception {
@@ -46,14 +63,21 @@ public class ConcurrentReadTest extends 
             session.save();
         }
 
-        reader = new Reader();
+        if (foregroundIsReader) {
+            foregroundTask = new Reader();
+        } else {
+            foregroundTask = new Writer();
+        }
 
-        for (int i = 0; i < READER_COUNT; i++) {
+        for (int i = 0; i < backgroundReaderCount; i++) {
             addBackgroundJob(new Reader());
         }
+        for (int i = 0; i < backgroundWriterCount; i++) {
+            addBackgroundJob(new Writer());
+        }
     }
 
-    class Reader implements Runnable {
+    private class Reader implements Runnable {
 
         private final Random random = new Random();
 
@@ -61,9 +85,47 @@ public class ConcurrentReadTest extends 
 
         public void run() {
             try {
-                int i = random.nextInt(NODE_COUNT);
-                int j = random.nextInt(NODE_COUNT);
-                session.getRootNode().getNode("testroot/node" + i + "/node" + j);
+                session.refresh(false);
+                for (int i = 0; i < 10000; i++) {
+                    int a = random.nextInt(NODE_COUNT);
+                    int b = random.nextInt(NODE_COUNT);
+                    session.getRootNode().getNode("testroot/node" + a + "/node" + b);
+                }
+            } catch (RepositoryException e) {
+                throw new RuntimeException(e);
+            }
+        }
+
+    }
+
+    private class Writer implements Runnable {
+
+        private final Random random = new Random();
+
+        private final Session session = loginWriter();
+
+        private long count;
+
+        public void run() {
+            try {
+                session.refresh(false);
+                for (int i = 0; i < 10; i++) {
+                    int a = random.nextInt(NODE_COUNT);
+                    int b = random.nextInt(NODE_COUNT);
+                    Node node = session.getRootNode().getNode(
+                            "testroot/node" + a + "/node" + b);
+                    boolean done = false;
+                    while (!done) {
+                        try {
+                            node.setProperty("count", count++);
+                            session.save();
+                            done = true;
+                        } catch (InvalidItemStateException e) {
+                            // retry with a fresh session
+                            session.refresh(false);
+                        }
+                    }
+                }
             } catch (RepositoryException e) {
                 throw new RuntimeException(e);
             }
@@ -73,9 +135,7 @@ public class ConcurrentReadTest extends 
 
     @Override
     public void runTest() throws Exception {
-        for (int i = 0; i < 1000; i++) {
-            reader.run();
-        }
+        foregroundTask.run();
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadWriteTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadWriteTest.java?rev=1527256&r1=1527255&r2=1527256&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadWriteTest.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadWriteTest.java
Sat Sep 28 22:51:05 2013
@@ -16,46 +16,14 @@
  */
 package org.apache.jackrabbit.oak.benchmark;
 
-import java.util.Random;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
 /**
  * A {@link ConcurrentReadTest} with a single writer thread that continuously
  * updates the nodes being accessed by the readers.
  */
 public class ConcurrentReadWriteTest extends ConcurrentReadTest {
 
-    @Override
-    public void beforeSuite() throws Exception {
-        super.beforeSuite();
-
-        addBackgroundJob(new Writer());
-    }
-
-    class Writer implements Runnable {
-
-        private final Random random = new Random();
-
-        private final Session session = loginWriter();
-
-        private long count;
-
-        public void run() {
-            try {
-                int i = random.nextInt(NODE_COUNT);
-                int j = random.nextInt(NODE_COUNT);
-                Node node = session.getRootNode().getNode(
-                        "testroot/node" + i + "/node" + j);
-                node.setProperty("count", count++);
-                session.save();
-            } catch (RepositoryException e) {
-                throw new RuntimeException(e);
-            }
-        }
-
+    public ConcurrentReadWriteTest() {
+        super(getScale(20), 1, true);
     }
 
 }

Added: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentWriteReadTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentWriteReadTest.java?rev=1527256&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentWriteReadTest.java
(added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentWriteReadTest.java
Sat Sep 28 22:51:05 2013
@@ -0,0 +1,30 @@
+/*
+ * 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.jackrabbit.oak.benchmark;
+
+/**
+ * A variant of {@link ConcurrentReadTest} with a that tests the performance
+ * of a single writer thread that continuously updates the nodes being
+ * accessed by the background readers.
+ */
+public class ConcurrentWriteReadTest extends ConcurrentReadTest {
+
+    public ConcurrentWriteReadTest() {
+        super(getScale(20), 0, false);
+    }
+
+}

Propchange: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentWriteReadTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentWriteTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentWriteTest.java?rev=1527256&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentWriteTest.java
(added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentWriteTest.java
Sat Sep 28 22:51:05 2013
@@ -0,0 +1,30 @@
+/*
+ * 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.jackrabbit.oak.benchmark;
+
+/**
+ * A variant of {@link ConcurrentReadTest} with a that tests the performance
+ * of a single writer thread that continuously updates the nodes being
+ * updated by background writers. No reader threads are used in this test.
+ */
+public class ConcurrentWriteTest extends ConcurrentReadTest {
+
+    public ConcurrentWriteTest() {
+        super(0, getScale(20), false);
+    }
+
+}

Propchange: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentWriteTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message