jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1373371 - in /jackrabbit/oak/trunk/oak-bench: base/ base/src/main/java/org/apache/jackrabbit/oak/performance/ latest/src/test/java/org/apache/jackrabbit/oak/performance/
Date Wed, 15 Aug 2012 12:40:47 GMT
Author: thomasm
Date: Wed Aug 15 12:40:47 2012
New Revision: 1373371

URL: http://svn.apache.org/viewvc?rev=1373371&view=rev
Log:
OAK-122 Performance test suite - (avoid out of memory, make them reasonably fast to run by
default but allow configuring longer running test using system properties)

Modified:
    jackrabbit/oak/trunk/oak-bench/base/pom.xml
    jackrabbit/oak/trunk/oak-bench/base/src/main/java/org/apache/jackrabbit/oak/performance/AbstractPerformanceTest.java
    jackrabbit/oak/trunk/oak-bench/base/src/main/java/org/apache/jackrabbit/oak/performance/AbstractTest.java
    jackrabbit/oak/trunk/oak-bench/base/src/main/java/org/apache/jackrabbit/oak/performance/TransientManyChildNodesTest.java
    jackrabbit/oak/trunk/oak-bench/latest/src/test/java/org/apache/jackrabbit/oak/performance/PerformanceBenchmark.java

Modified: jackrabbit/oak/trunk/oak-bench/base/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-bench/base/pom.xml?rev=1373371&r1=1373370&r2=1373371&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-bench/base/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-bench/base/pom.xml Wed Aug 15 12:40:47 2012
@@ -48,6 +48,11 @@
       <scope>provided</scope>
     </dependency>
     <dependency>
+      <groupId>com.h2database</groupId>
+      <artifactId>h2</artifactId>
+      <version>1.3.158</version>
+    </dependency>  
+    <dependency>
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
       <version>1.4</version>

Modified: jackrabbit/oak/trunk/oak-bench/base/src/main/java/org/apache/jackrabbit/oak/performance/AbstractPerformanceTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-bench/base/src/main/java/org/apache/jackrabbit/oak/performance/AbstractPerformanceTest.java?rev=1373371&r1=1373370&r2=1373371&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-bench/base/src/main/java/org/apache/jackrabbit/oak/performance/AbstractPerformanceTest.java
(original)
+++ jackrabbit/oak/trunk/oak-bench/base/src/main/java/org/apache/jackrabbit/oak/performance/AbstractPerformanceTest.java
Wed Aug 15 12:40:47 2012
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.perfor
 import java.io.File;
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.util.Collections;
 import java.util.regex.Pattern;
 
 import javax.jcr.Credentials;
@@ -28,13 +29,31 @@ import javax.jcr.SimpleCredentials;
 
 import org.apache.commons.io.output.FileWriterWithEncoding;
 import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
+import org.apache.jackrabbit.mk.MicroKernelFactory;
+import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.mk.core.MicroKernelImpl;
+import org.apache.jackrabbit.mk.index.IndexWrapper;
+import org.apache.jackrabbit.oak.api.ContentRepository;
+import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
 import org.apache.jackrabbit.oak.jcr.RepositoryImpl;
-
+import org.apache.jackrabbit.oak.spi.commit.CompositeValidatorProvider;
+import org.apache.jackrabbit.oak.spi.commit.ValidatingEditor;
+import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
+
+/**
+ * This class calls all known performance tests.
+ */
 public abstract class AbstractPerformanceTest {
 
-    private final int warmup = 1;
-
-    private final int runtime = 10;
+    /**
+     * The warmup time, in ms.
+     */
+    private final int warmup = Integer.getInteger("oak.performanceTest.warmup", 0);
+
+    /**
+     * How long each test is repeated, in ms.
+     */
+    private final int runtime = Integer.getInteger("oak.performanceTest.runtime", 100);
 
     private final Credentials credentials = new SimpleCredentials("admin",
             "admin".toCharArray());
@@ -69,9 +88,12 @@ public abstract class AbstractPerformanc
         if (microKernelPattern.matcher(microKernel).matches()
                 && testPattern.matcher(test.toString()).matches()) {
 
+            MicroKernel mk = null;
             RepositoryImpl repository;
             try {
-                repository = createRepository(microKernel);
+
+                mk = createMicroKernel(microKernel);
+                repository = createRepository(mk);
 
                 // Run the test
                 DescriptiveStatistics statistics = runTest(test, repository);
@@ -82,6 +104,10 @@ public abstract class AbstractPerformanc
                 re.printStackTrace();
             } catch (Exception e) {
                 e.printStackTrace();
+            } finally {
+                if (mk != null) {
+                    MicroKernelFactory.disposeInstance(mk);
+                }
             }
         }
     }
@@ -93,13 +119,15 @@ public abstract class AbstractPerformanc
         test.setUp(repository, credentials);
         try {
             // Run a few iterations to warm up the system
-            long warmupEnd = System.currentTimeMillis() + warmup * 1000;
-            while (System.currentTimeMillis() < warmupEnd) {
-                test.execute();
+            if (warmup > 0) {
+                long warmupEnd = System.currentTimeMillis() + warmup;
+                while (System.currentTimeMillis() < warmupEnd) {
+                    test.execute();
+                }
             }
 
             // Run test iterations, and capture the execution times
-            long runtimeEnd = System.currentTimeMillis() + runtime * 1000;
+            long runtimeEnd = System.currentTimeMillis() + runtime;
             while (System.currentTimeMillis() < runtimeEnd) {
                 statistics.addValue(test.execute());
             }
@@ -133,13 +161,25 @@ public abstract class AbstractPerformanc
         }
     }
 
-    protected RepositoryImpl createRepository(String microKernel)
-            throws RepositoryException {
+    protected MicroKernel createMicroKernel(String microKernel) {
 
         // TODO: depending on the microKernel string a particular repository
         // with that MK must be returned
 
-        return new RepositoryImpl();
+        return new MicroKernelImpl("target/mk-tck-" + System.currentTimeMillis());
+
+    }
+
+    protected RepositoryImpl createRepository(MicroKernel mk) {
+
+        // return new RepositoryImpl();
+
+        mk = new IndexWrapper(mk);
+        ValidatingEditor ve =  new ValidatingEditor(
+                new CompositeValidatorProvider(Collections.<ValidatorProvider>emptyList()));
+        ContentRepository contentRepository = new ContentRepositoryImpl(mk, null, ve);
+        return new RepositoryImpl(contentRepository, null);
+
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-bench/base/src/main/java/org/apache/jackrabbit/oak/performance/AbstractTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-bench/base/src/main/java/org/apache/jackrabbit/oak/performance/AbstractTest.java?rev=1373371&r1=1373370&r2=1373371&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-bench/base/src/main/java/org/apache/jackrabbit/oak/performance/AbstractTest.java
(original)
+++ jackrabbit/oak/trunk/oak-bench/base/src/main/java/org/apache/jackrabbit/oak/performance/AbstractTest.java
Wed Aug 15 12:40:47 2012
@@ -76,6 +76,7 @@ public abstract class AbstractTest {
         beforeTest();
         try {
             long start = System.currentTimeMillis();
+            // System.out.println("execute " + this);
             runTest();
             return System.currentTimeMillis() - start;
         } finally {
@@ -193,14 +194,22 @@ public abstract class AbstractTest {
      * @param job background job
      */
     protected void addBackgroundJob(final Runnable job) {
-        Thread thread = new Thread() {
+        Thread thread = new Thread("Background job " + job) {
             @Override
             public void run() {
                 while (running) {
+                    try {
+                        // rate-limit, to avoid 100% cpu usage
+                        Thread.sleep(10);
+                    } catch (InterruptedException e) {
+                        // ignore
+                    }
                     job.run();
                 }
             }
         };
+        thread.setDaemon(true);
+        thread.setPriority(Thread.MIN_PRIORITY);
         thread.start();
         threads.add(thread);
     }

Modified: jackrabbit/oak/trunk/oak-bench/base/src/main/java/org/apache/jackrabbit/oak/performance/TransientManyChildNodesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-bench/base/src/main/java/org/apache/jackrabbit/oak/performance/TransientManyChildNodesTest.java?rev=1373371&r1=1373370&r2=1373371&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-bench/base/src/main/java/org/apache/jackrabbit/oak/performance/TransientManyChildNodesTest.java
(original)
+++ jackrabbit/oak/trunk/oak-bench/base/src/main/java/org/apache/jackrabbit/oak/performance/TransientManyChildNodesTest.java
Wed Aug 15 12:40:47 2012
@@ -29,7 +29,7 @@ public class TransientManyChildNodesTest
 
     private static final int CHILD_COUNT = 10 * 1000;
 
-    private static final int ITERATIONS = 1000;
+    private static final int ITERATIONS = 10;
 
     private Session session;
 

Modified: jackrabbit/oak/trunk/oak-bench/latest/src/test/java/org/apache/jackrabbit/oak/performance/PerformanceBenchmark.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-bench/latest/src/test/java/org/apache/jackrabbit/oak/performance/PerformanceBenchmark.java?rev=1373371&r1=1373370&r2=1373371&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-bench/latest/src/test/java/org/apache/jackrabbit/oak/performance/PerformanceBenchmark.java
(original)
+++ jackrabbit/oak/trunk/oak-bench/latest/src/test/java/org/apache/jackrabbit/oak/performance/PerformanceBenchmark.java
Wed Aug 15 12:40:47 2012
@@ -23,6 +23,6 @@ public class PerformanceBenchmark extend
     @Test
     public void testPerformance() throws Exception {
         testPerformance("0.3", "default");
-        testPerformance("0.3", "other_mk");
+        // testPerformance("0.3", "other_mk");
     }
 }



Mime
View raw message