jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r1535595 - in /jackrabbit/oak/trunk/oak-run: ./ src/main/java/org/apache/jackrabbit/oak/benchmark/
Date Fri, 25 Oct 2013 00:39:21 GMT
Author: tripod
Date: Fri Oct 25 00:39:20 2013
New Revision: 1535595

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

- use randomUser argument to toggle individual sessions per run

Modified:
    jackrabbit/oak/trunk/oak-run/run_concurrent.sh
    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/ManyUserReadTest.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ReadDeepTreeTest.java

Modified: jackrabbit/oak/trunk/oak-run/run_concurrent.sh
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/run_concurrent.sh?rev=1535595&r1=1535594&r2=1535595&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/run_concurrent.sh (original)
+++ jackrabbit/oak/trunk/oak-run/run_concurrent.sh Fri Oct 25 00:39:20 2013
@@ -17,9 +17,11 @@
 #
 USERS="false true"
 RUNTIME=20
-BENCH=ConcurrentReadAccessControlledTreeTest
+#BENCH=ConcurrentReadAccessControlledTreeTest
+BENCH=ManyUserReadTest
+RANDOM_USER="true"
 FIXS="Oak-Tar" # Jackrabbit"
-THREADS="1 2 4 8 12 16 20"
+THREADS="0 1 2 4 8 12 16 20"
 PROFILE=false
 
 LOG=$BENCH"_$(date +'%Y%m%d_%H%M%S').csv"
@@ -28,6 +30,7 @@ echo "Fixtures: $FIXS" >> $LOG
 echo "Users: $USERS" >> $LOG
 echo "Runtime: $RUNTIME" >> $LOG
 echo "Concurrency: $THREADS" >> $LOG
+echo "Random User: $RANDOM_USER" >> $LOG
 echo "Profiling: $PROFILE" >> $LOG
 echo "--------------------------------------" >> $LOG
 for user in $USERS
@@ -37,7 +40,7 @@ for user in $USERS
     for i in $THREADS
         do
         rm -rf target/Jackrabbit-* target/Oak-Tar-*
-        cmd="java -Xmx2048m -Dprofile=$PROFILE -Druntime=$RUNTIME -jar target/oak-run-*-SNAPSHOT.jar
benchmark --csvFile $LOG --bgReaders $i --runAsAdmin $user --report false $BENCH $FIXS"
+        cmd="java -Xmx2048m -Dprofile=$PROFILE -Druntime=$RUNTIME -jar target/oak-run-*-SNAPSHOT.jar
benchmark --csvFile $LOG --bgReaders $i --runAsAdmin $user --report false --randomUser $RANDOM_USER
$BENCH $FIXS"
         echo $cmd
         $cmd 
     done

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=1535595&r1=1535594&r2=1535595&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
Fri Oct 25 00:39:20 2013
@@ -306,13 +306,27 @@ abstract class AbstractTest extends Benc
    protected Session login(Credentials credentials) {
        try {
            Session session = repository.login(credentials);
-           sessions.add(session);
+           synchronized (sessions) {
+               sessions.add(session);
+           }
            return session;
        } catch (RepositoryException e) {
            throw new RuntimeException(e);
        }
    }
-    
+
+    /**
+     * Logs out and removes the session from the internal pool.
+     * @param session the session to logout
+     */
+    protected void logout(Session session) {
+        if (session != null) {
+            session.logout();
+        }
+        synchronized (sessions) {
+            sessions.remove(session);
+        }
+    }
 
     /**
      * Returns a new writer session that will be automatically closed once
@@ -323,7 +337,9 @@ abstract class AbstractTest extends Benc
     protected Session loginWriter() {
         try {
             Session session = repository.login(credentials);
-            sessions.add(session);
+            synchronized (sessions) {
+                sessions.add(session);
+            }
             return session;
         } catch (RepositoryException e) {
             throw new RuntimeException(e);

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ManyUserReadTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ManyUserReadTest.java?rev=1535595&r1=1535594&r2=1535595&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ManyUserReadTest.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ManyUserReadTest.java
Fri Oct 25 00:39:20 2013
@@ -38,7 +38,7 @@ public class ManyUserReadTest extends Re
     private final boolean randomUser;
 
     protected ManyUserReadTest(boolean runAsAdmin, int itemsToRead, int bgReaders, boolean
doReport, boolean randomUser) {
-        super(runAsAdmin, itemsToRead, bgReaders, doReport);
+        super(runAsAdmin, itemsToRead, bgReaders, doReport, !randomUser);
         this.randomUser = randomUser;
     }
 

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ReadDeepTreeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ReadDeepTreeTest.java?rev=1535595&r1=1535594&r2=1535595&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ReadDeepTreeTest.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ReadDeepTreeTest.java
Fri Oct 25 00:39:20 2013
@@ -39,18 +39,25 @@ public class ReadDeepTreeTest extends Ab
     protected final int bgReaders;
     protected final boolean doReport;
 
+    protected final boolean singleSession;
+
     protected Session adminSession;
     protected Node testRoot;
 
     private Session testSession;
 
-    protected List<String> allPaths = new ArrayList();
+    protected List<String> allPaths = new ArrayList<String>();
 
     protected ReadDeepTreeTest(boolean runAsAdmin, int itemsToRead, int bgReaders, boolean
doReport) {
+        this(runAsAdmin, itemsToRead, bgReaders, doReport, true);
+    }
+
+    public ReadDeepTreeTest(boolean runAsAdmin, int itemsToRead, int bgReaders, boolean doReport,
boolean singleSession) {
         this.runAsAdmin = runAsAdmin;
         this.itemsToRead = itemsToRead;
         this.bgReaders = bgReaders;
         this.doReport = doReport;
+        this.singleSession = singleSession;
     }
 
     public ReadDeepTreeTest(boolean runAsAdmin, int itemsToRead, boolean doReport) {
@@ -64,7 +71,7 @@ public class ReadDeepTreeTest extends Ab
         createDeepTree();
 
         for (int i = 0; i < bgReaders; i++) {
-            final Session session = getTestSession();
+            final Session session = singleSession ? getTestSession() : null;
             addBackgroundJob(new Runnable() {
                 @Override
                 public void run() {
@@ -78,7 +85,7 @@ public class ReadDeepTreeTest extends Ab
         }
         System.out.println("Threads started: " + bgReaders);
 
-        testSession = getTestSession();
+        testSession = singleSession ? getTestSession() : null;
     }
 
     protected void createDeepTree() throws Exception {
@@ -136,29 +143,40 @@ public class ReadDeepTreeTest extends Ab
     }
 
     protected void randomRead(Session testSession, List<String> allPaths, int cnt)
throws RepositoryException {
-        int nodeCnt = 0;
-        int propertyCnt = 0;
-        int noAccess = 0;
-        int size = allPaths.size();
-        long start = System.currentTimeMillis();
-        for (int i = 0; i < cnt; i++) {
-            double rand = size * Math.random();
-            int index = (int) Math.floor(rand);
-            String path = allPaths.get(index);
-            if (testSession.itemExists(path)) {
-                Item item = testSession.getItem(path);
-                if (item.isNode()) {
-                    nodeCnt++;
+        boolean logout = false;
+        if (testSession == null) {
+            testSession = getTestSession();
+            logout = true;
+        }
+        try {
+            int nodeCnt = 0;
+            int propertyCnt = 0;
+            int noAccess = 0;
+            int size = allPaths.size();
+            long start = System.currentTimeMillis();
+            for (int i = 0; i < cnt; i++) {
+                double rand = size * Math.random();
+                int index = (int) Math.floor(rand);
+                String path = allPaths.get(index);
+                if (testSession.itemExists(path)) {
+                    Item item = testSession.getItem(path);
+                    if (item.isNode()) {
+                        nodeCnt++;
+                    } else {
+                        propertyCnt++;
+                    }
                 } else {
-                    propertyCnt++;
+                    noAccess++;
                 }
-            } else {
-                noAccess++;
             }
-        }
-        long end = System.currentTimeMillis();
-        if (doReport) {
-            System.out.println("Session " + testSession.getUserID() + " reading " + (cnt-noAccess)
+ " (Nodes: "+ nodeCnt +"; Properties: "+propertyCnt+") completed in " + (end - start));
+            long end = System.currentTimeMillis();
+            if (doReport) {
+                System.out.println("Session " + testSession.getUserID() + " reading " + (cnt-noAccess)
+ " (Nodes: "+ nodeCnt +"; Properties: "+propertyCnt+") completed in " + (end - start));
+            }
+        } finally {
+            if (logout) {
+                logout(testSession);
+            }
         }
     }
 



Mime
View raw message