You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by md...@apache.org on 2013/10/15 17:30:04 UTC

svn commit: r1532387 - in /jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark: BenchmarkRunner.java ConcurrentCreateNodesTest.java SequentialCreateNodesTest.java

Author: mduerig
Date: Tue Oct 15 15:30:03 2013
New Revision: 1532387

URL: http://svn.apache.org/r1532387
Log:
OAK-1099: node creation noticeably slower with mongoMk compared to tarMk
Benchmark demonstrating the issue. Credits to Stefan Egli for providing a patch

Added:
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentCreateNodesTest.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/SequentialCreateNodesTest.java
Modified:
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java

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=1532387&r1=1532386&r2=1532387&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 Tue Oct 15 15:30:03 2013
@@ -141,6 +141,8 @@ public class BenchmarkRunner {
             ReadManyTest.uniform("UniformReadEmpty", 1, ReadManyTest.EMPTY),
             ReadManyTest.uniform("UniformReadFiles", 1, ReadManyTest.FILES),
             ReadManyTest.uniform("UniformReadNodes", 1, ReadManyTest.NODES),
+            new ConcurrentCreateNodesTest(),
+            new SequentialCreateNodesTest(),
         };
 
         Set<String> argset = Sets.newHashSet(options.nonOptionArguments());

Added: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentCreateNodesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentCreateNodesTest.java?rev=1532387&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentCreateNodesTest.java (added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentCreateNodesTest.java Tue Oct 15 15:30:03 2013
@@ -0,0 +1,87 @@
+/*
+ * 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;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+public class ConcurrentCreateNodesTest extends AbstractTest {
+
+    protected static final String ROOT_NODE_NAME = "test" + TEST_ID;
+	private static final int WORKER_COUNT = 20;
+	private static final int NODE_COUNT_LEVEL2 = 50;
+
+	@Override
+	protected void beforeSuite() throws Exception {
+        Session session = loginWriter();
+        Node rootNode = session.getRootNode();
+        if (rootNode.hasNode(ROOT_NODE_NAME)) {
+        	Node root = rootNode.getNode(ROOT_NODE_NAME);
+        	root.remove();
+        }
+        Node root = session.getRootNode().addNode(ROOT_NODE_NAME, "nt:unstructured");
+        session.save();
+        for (int i = 1; i < WORKER_COUNT; i++) {
+            addBackgroundJob(new Writer(i));
+        }
+    }
+
+    private class Writer implements Runnable {
+
+        private final Session session = loginWriter();
+		private final int id;
+
+        private Writer(int id) {
+        	this.id = id;
+        }
+        
+        @Override
+        public void run() {
+            try {
+                session.refresh(false);
+                
+            	Node root = session.getRootNode().getNode(ROOT_NODE_NAME);
+                Node node = root.addNode("node" + id, "nt:unstructured");
+                for (int j = 0; j < NODE_COUNT_LEVEL2; j++) {
+                    Node newNode = node.addNode("node" + j, "nt:unstructured");
+                    session.save();
+                }
+                node.remove();
+                session.save();
+            } catch (RepositoryException e) {
+            	e.printStackTrace();
+                throw new RuntimeException(e);
+            }
+        }
+
+    }
+    
+    @Override
+    public void runTest() throws Exception {
+    	new Writer(0).run();
+    }
+    
+    @Override
+    protected void afterSuite() throws Exception {
+        Session session = loginWriter();
+        Node root = session.getRootNode().getNode(ROOT_NODE_NAME);
+        root.remove();
+        session.save();
+    }
+
+}

Added: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/SequentialCreateNodesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/SequentialCreateNodesTest.java?rev=1532387&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/SequentialCreateNodesTest.java (added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/SequentialCreateNodesTest.java Tue Oct 15 15:30:03 2013
@@ -0,0 +1,60 @@
+/*
+ * 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;
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+public class SequentialCreateNodesTest extends AbstractTest {
+
+    protected static final String ROOT_NODE_NAME = "test" + TEST_ID;
+	private static final int NODE_COUNT = 25;
+
+    @Override
+    public void beforeTest() throws Exception {
+        Session session = loginWriter();
+        Node root = session.getRootNode().addNode(ROOT_NODE_NAME, "nt:unstructured");
+        for (int i = 0; i < NODE_COUNT; i++) {
+            Node node = root.addNode("node" + i, "nt:unstructured");
+            session.save();
+        }
+    }
+
+    @Override
+	protected void runTest() throws Exception {
+        
+    	final Session session = loginWriter(); // TODO: anonymous is slow
+        
+    	Node root = session.getRootNode().getNode(ROOT_NODE_NAME);
+        for (int i = 0; i < NODE_COUNT; i++) {
+            Node node = root.getNode("node" + i);
+            for (int j = 0; j < NODE_COUNT; j++) {
+                Node newNode = node.addNode("node" + j, "nt:unstructured");
+                session.save();
+            }
+        }
+	}
+    
+    @Override
+    public void afterTest() throws Exception {
+        Session session = loginWriter();
+        Node root = session.getRootNode().getNode(ROOT_NODE_NAME);
+        root.remove();
+        session.save();
+    }
+
+}