You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2010/08/11 19:11:20 UTC

svn commit: r984475 - in /jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark: CreateManyChildNodesTest.java TransientManyChildNodesTest.java UpdateManyChildNodesTest.java

Author: jukka
Date: Wed Aug 11 17:11:20 2010
New Revision: 984475

URL: http://svn.apache.org/viewvc?rev=984475&view=rev
Log:
JCR-2707: improve performance when saving a node with a large number of child nodes (e.g. > 10k child node entries)

Add a few performance benchmarks for handling nodes with lots of child nodes

Added:
    jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/CreateManyChildNodesTest.java   (with props)
    jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/TransientManyChildNodesTest.java   (with props)
    jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/UpdateManyChildNodesTest.java   (with props)

Added: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/CreateManyChildNodesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/CreateManyChildNodesTest.java?rev=984475&view=auto
==============================================================================
--- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/CreateManyChildNodesTest.java (added)
+++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/CreateManyChildNodesTest.java Wed Aug 11 17:11:20 2010
@@ -0,0 +1,57 @@
+/*
+ * 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.benchmark;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+/**
+ * Test for measuring the performance of creating a node with
+ * {@value #CHILD_COUNT} child nodes.
+ */
+public class CreateManyChildNodesTest extends PerformanceTest {
+
+    private static final int CHILD_COUNT = 10 * 1000;
+
+    private Session session;
+
+    public void beforeSuite() throws RepositoryException {
+        session = getRepository().login(getCredentials());
+    }
+
+    public void beforeTest() throws RepositoryException {
+    }
+
+    public void runTest() throws Exception {
+        Node node = session.getRootNode().addNode("testnode", "nt:unstructured");
+        for (int i = 0; i < CHILD_COUNT; i++) {
+            node.addNode("node" + i, "nt:unstructured");
+        }
+        session.save();
+    }
+
+    public void afterTest() throws RepositoryException {
+        session.getRootNode().getNode("testnode").remove();
+        session.save();
+    }
+
+    public void afterSuite() throws RepositoryException {
+        session.logout();
+    }
+
+}

Propchange: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/CreateManyChildNodesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/TransientManyChildNodesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/TransientManyChildNodesTest.java?rev=984475&view=auto
==============================================================================
--- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/TransientManyChildNodesTest.java (added)
+++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/TransientManyChildNodesTest.java Wed Aug 11 17:11:20 2010
@@ -0,0 +1,64 @@
+/*
+ * 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.benchmark;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+/**
+ * Test for measuring the performance of {@value #ITERATIONS} iterations of
+ * transiently adding and removing a child node to a node that already has
+ * {@value #CHILD_COUNT} existing child nodes.
+ */
+public class TransientManyChildNodesTest extends PerformanceTest {
+
+    private static final int CHILD_COUNT = 10 * 1000;
+
+    private static final int ITERATIONS = 1000;
+
+    private Session session;
+
+    private Node node;
+
+    public void beforeSuite() throws RepositoryException {
+        session = getRepository().login(getCredentials());
+        node = session.getRootNode().addNode("testnode", "nt:unstructured");
+        for (int i = 0; i < CHILD_COUNT; i++) {
+            node.addNode("node" + i, "nt:unstructured");
+        }
+    }
+
+    public void beforeTest() throws RepositoryException {
+    }
+
+    public void runTest() throws Exception {
+        for (int i = 0; i < ITERATIONS; i++) {
+            node.addNode("onemore", "nt:unstructured").remove();
+        }
+    }
+
+    public void afterTest() throws RepositoryException {
+    }
+
+    public void afterSuite() throws RepositoryException {
+        session.getRootNode().getNode("testnode").remove();
+        session.save();
+        session.logout();
+    }
+
+}

Propchange: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/TransientManyChildNodesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/UpdateManyChildNodesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/UpdateManyChildNodesTest.java?rev=984475&view=auto
==============================================================================
--- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/UpdateManyChildNodesTest.java (added)
+++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/UpdateManyChildNodesTest.java Wed Aug 11 17:11:20 2010
@@ -0,0 +1,62 @@
+/*
+ * 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.benchmark;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+/**
+ * Test for measuring the performance of adding one extra child node to 
+ * node with {@value #CHILD_COUNT} existing child nodes.
+ */
+public class UpdateManyChildNodesTest extends PerformanceTest {
+
+    private static final int CHILD_COUNT = 10 * 1000;
+
+    private Session session;
+
+    private Node node;
+
+    public void beforeSuite() throws RepositoryException {
+        session = getRepository().login(getCredentials());
+        node = session.getRootNode().addNode("testnode", "nt:unstructured");
+        for (int i = 0; i < CHILD_COUNT; i++) {
+            node.addNode("node" + i, "nt:unstructured");
+        }
+    }
+
+    public void beforeTest() throws RepositoryException {
+    }
+
+    public void runTest() throws Exception {
+        node.addNode("onemore", "nt:unstructured");
+        session.save();
+    }
+
+    public void afterTest() throws RepositoryException {
+        node.getNode("onemore").remove();
+        session.save();
+    }
+
+    public void afterSuite() throws RepositoryException {
+        session.getRootNode().getNode("testnode").remove();
+        session.save();
+        session.logout();
+    }
+
+}

Propchange: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/UpdateManyChildNodesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native