jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1526092 - in /jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark: AbstractTest.java ConcurrentReadTest.java ConcurrentReadWriteTest.java
Date Wed, 25 Sep 2013 02:56:55 GMT
Author: jukka
Date: Wed Sep 25 02:56:54 2013
New Revision: 1526092

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

Decouple the login/logout time from the concurrent read/write tests

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/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=1526092&r1=1526091&r2=1526092&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
Wed Sep 25 02:56:54 2013
@@ -279,13 +279,8 @@ abstract class AbstractTest extends Benc
             @Override
             public void run() {
                 while (running) {
-                    try {
-                        // rate-limit, to avoid 100% cpu usage
-                        Thread.sleep(10);
-                    } catch (InterruptedException e) {
-                        // ignore
-                    }
                     job.run();
+                    Thread.yield();
                 }
             }
         };

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=1526092&r1=1526091&r2=1526092&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
Wed Sep 25 02:56:54 2013
@@ -21,7 +21,6 @@ import java.util.Random;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
 
 /**
  * Test case that traverses 10k unstructured nodes (100x100) while 50 concurrent
@@ -33,25 +32,24 @@ public class ConcurrentReadTest extends 
 
     private static final int READER_COUNT = getScale(20);
 
+    private Reader reader;
+
     @Override
     public void beforeSuite() throws Exception {
-        Session session = getRepository().login(
-                new SimpleCredentials("admin", "admin".toCharArray()));
-        try {
-            Node root = session.getRootNode().addNode("testroot", "nt:unstructured");
-            for (int i = 0; i < NODE_COUNT; i++) {
-                Node node = root.addNode("node" + i, "nt:unstructured");
-                for (int j = 0; j < NODE_COUNT; j++) {
-                    node.addNode("node" + j, "nt:unstructured");
-                }
-                session.save();
+        Session session = loginWriter();
+        Node root = session.getRootNode().addNode("testroot", "nt:unstructured");
+        for (int i = 0; i < NODE_COUNT; i++) {
+            Node node = root.addNode("node" + i, "nt:unstructured");
+            for (int j = 0; j < NODE_COUNT; j++) {
+                node.addNode("node" + j, "nt:unstructured");
             }
+            session.save();
+        }
 
-            for (int i = 0; i < READER_COUNT; i++) {
-                addBackgroundJob(new Reader());
-            }
-        } finally {
-            session.logout();
+        reader = new Reader();
+
+        for (int i = 0; i < READER_COUNT; i++) {
+            addBackgroundJob(new Reader());
         }
     }
 
@@ -59,18 +57,13 @@ public class ConcurrentReadTest extends 
 
         private final Random random = new Random();
 
+        private final Session session = loginWriter(); // TODO: anonymous is slow
+
         public void run() {
             try {
-                Session session = getRepository().login(
-                        new SimpleCredentials("admin", "admin".toCharArray()));
-                try {
-                    int i = random.nextInt(NODE_COUNT);
-                    int j = random.nextInt(NODE_COUNT);
-                    session.getRootNode()
-                        .getNode("testroot/node" + i + "/node" + j);
-                } finally {
-                    session.logout();
-                }
+                int i = random.nextInt(NODE_COUNT);
+                int j = random.nextInt(NODE_COUNT);
+                session.getRootNode().getNode("testroot/node" + i + "/node" + j);
             } catch (RepositoryException e) {
                 throw new RuntimeException(e);
             }
@@ -80,7 +73,6 @@ public class ConcurrentReadTest extends 
 
     @Override
     public void runTest() throws Exception {
-        Reader reader = new Reader();
         for (int i = 0; i < 1000; i++) {
             reader.run();
         }
@@ -88,20 +80,14 @@ public class ConcurrentReadTest extends 
 
     @Override
     public void afterSuite() throws Exception {
-        Session session = getRepository().login(
-                new SimpleCredentials("admin", "admin".toCharArray()));
-        try {
-            Node root = session.getRootNode().getNode("testroot");
-            for (int i = 0; i < NODE_COUNT; i++) {
-                root.getNode("node" + i).remove();
-                session.save();
-            }
-
-            root.remove();
+        Session session = loginWriter();
+        Node root = session.getRootNode().getNode("testroot");
+        for (int i = 0; i < NODE_COUNT; i++) {
+            root.getNode("node" + i).remove();
             session.save();
-        } finally {
-            session.logout();
         }
+        root.remove();
+        session.save();
     }
 
 }

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=1526092&r1=1526091&r2=1526092&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
Wed Sep 25 02:56:54 2013
@@ -21,7 +21,6 @@ import java.util.Random;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
 
 /**
  * A {@link ConcurrentReadTest} with a single writer thread that continuously
@@ -38,26 +37,20 @@ public class ConcurrentReadWriteTest ext
 
     class Writer implements Runnable {
 
-        private Session session;
-
         private final Random random = new Random();
 
+        private final Session session = loginWriter();
+
         private long count;
 
         public void run() {
             try {
-                session = getRepository().login(
-                        new SimpleCredentials("admin", "admin".toCharArray()));
-                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();
-                } finally {
-                    session.logout();
-                }
+                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);
             }



Mime
View raw message