Author: tripod
Date: Thu Mar 6 00:31:23 2014
New Revision: 1574730
URL: http://svn.apache.org/r1574730
Log:
OAK-1504 Create benchmark tests to measure effect of mod_count and everyone
cache
Added:
jackrabbit/oak/trunk/oak-run/run_everyone_acl.sh (with props)
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentEveryoneACLTest.java
Modified:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
Added: jackrabbit/oak/trunk/oak-run/run_everyone_acl.sh
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/run_everyone_acl.sh?rev=1574730&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/run_everyone_acl.sh (added)
+++ jackrabbit/oak/trunk/oak-run/run_everyone_acl.sh Thu Mar 6 00:31:23 2014
@@ -0,0 +1,57 @@
+#!/bin/sh
+#
+# 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.
+#
+TITLE=ConcurrentEveryoneACLTest
+BENCH="ConcurrentEveryoneACLTest"
+ADMIN="false true"
+RUNTIME=5
+RANDOM_USER="true"
+FIXS="Oak-Tar" # Jackrabbit"
+THREADS="1,2,4,8,10,15,20,50"
+PROFILE=false
+NUM_ITEMS=1000
+
+LOG=$TITLE"_$(date +'%Y%m%d_%H%M%S').csv"
+echo "Benchmarks: $BENCH" > $LOG
+echo "Fixtures: $FIXS" >> $LOG
+echo "Admin User: $ADMIN" >> $LOG
+echo "Runtime: $RUNTIME" >> $LOG
+echo "Num Items: $NUM_ITEMS" >> $LOG
+echo "Concurrency: $THREADS" >> $LOG
+echo "Random User: $RANDOM_USER" >> $LOG
+echo "Profiling: $PROFILE" >> $LOG
+echo "--------------------------------------" >> $LOG
+
+for bm in $BENCH
+ do
+ for user in $ADMIN
+ do
+ # we start new VMs for each fixture to minimize memory impacts between
them
+ for fix in $FIXS
+ do
+ echo "Executing benchmarks as admin: $user on $fix" | tee -a $LOG
+ echo "-----------------------------------------------------------" |
tee -a $LOG
+ rm -rf target/Jackrabbit-* target/Oak-Tar-*
+ cmd="java -Xmx2048m -Dprofile=$PROFILE -Druntime=$RUNTIME
-Dwarmup=5 -jar target/oak-run-*-SNAPSHOT.jar benchmark --itemsToRead
$NUM_ITEMS --csvFile $LOG --concurrency $THREADS --runAsAdmin $user --report
false --randomUser $RANDOM_USER $bm $fix"
+ echo $cmd
+ $cmd
+ done
+ done
+done
+echo "-----------------------------------------"
+echo "Benchmark completed. see $LOG for details:"
+cat $LOG
Propchange: jackrabbit/oak/trunk/oak-run/run_everyone_acl.sh
------------------------------------------------------------------------------
svn:executable = *
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=1574730&r1=1574729&r2=1574730&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
Thu Mar 6 00:31:23 2014
@@ -161,6 +161,7 @@ public class BenchmarkRunner {
report.value(options),
randomUser.value(options)),
new ConcurrentWriteACLTest(),
+ new ConcurrentEveryoneACLTest(runAsAdmin.value(options),
itemsToRead.value(options)),
ReadManyTest.linear("LinearReadEmpty", 1, ReadManyTest.EMPTY),
ReadManyTest.linear("LinearReadFiles", 1, ReadManyTest.FILES),
ReadManyTest.linear("LinearReadNodes", 1, ReadManyTest.NODES),
Added:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentEveryoneACLTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentEveryoneACLTest.java?rev=1574730&view=auto
==============================================================================
---
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentEveryoneACLTest.java
(added)
+++
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentEveryoneACLTest.java
Thu Mar 6 00:31:23 2014
@@ -0,0 +1,130 @@
+/*
+ * 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 java.util.Random;
+
+import javax.jcr.ItemVisitor;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.security.AccessControlEntry;
+import javax.jcr.security.AccessControlManager;
+import javax.jcr.security.Privilege;
+import javax.jcr.util.TraversingItemVisitor;
+
+import org.apache.jackrabbit.api.security.JackrabbitAccessControlList;
+import
org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils;
+import org.apache.jackrabbit.core.security.principal.EveryonePrincipal;
+import
org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AccessControlConstants;
+
+/**
+ * Test case that randomly reads from 10k unstructured nodes that are all
access controlled with an everyone ACL.
+ */
+public class ConcurrentEveryoneACLTest extends AbstractTest {
+
+ private final Random random = new Random();
+
+ protected static final int NODE_COUNT = 100;
+
+ protected static final String ROOT_NODE_NAME = "test" + TEST_ID;
+
+ private final boolean runAsAdmin;
+
+ private final int itemsToRead;
+
+ public ConcurrentEveryoneACLTest(boolean runAsAdmin, int itemsToRead) {
+ this.runAsAdmin = runAsAdmin;
+ this.itemsToRead = itemsToRead;
+ }
+
+ @Override
+ public void beforeSuite() throws Exception {
+ Session session = loginWriter();
+ AccessControlManager acMgr = session.getAccessControlManager();
+ Privilege[] privileges = new Privilege[] {
+ acMgr.privilegeFromName(Privilege.JCR_READ),
+ acMgr.privilegeFromName(Privilege.JCR_READ_ACCESS_CONTROL)
+ };
+ final 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");
+ for (int j = 0; j < NODE_COUNT; j++) {
+ Node newNode = node.addNode("node" + j, "nt:unstructured");
+ JackrabbitAccessControlList acl =
AccessControlUtils.getAccessControlList(session, newNode.getPath());
+ acl.addEntry(EveryonePrincipal.getInstance(), privileges,
true);
+ acMgr.setPolicy(newNode.getPath(), acl);
+ }
+ session.save();
+ }
+ // deny everyone on root node
+ JackrabbitAccessControlList acl =
AccessControlUtils.getAccessControlList(session, root.getPath());
+ acl.addEntry(EveryonePrincipal.getInstance(), privileges, false);
+ acMgr.setPolicy(root.getPath(), acl);
+ session.save();
+
+ final int[] numACEs = new int[1];
+ ItemVisitor v = new TraversingItemVisitor.Default() {
+ @Override
+ protected void entering(Node node, int i) throws
RepositoryException {
+ if (node.isNodeType(AccessControlConstants.NT_REP_ACE)) {
+ numACEs[0]++;
+ }
+ super.entering(node, i);
+ }
+ @Override
+ protected void entering(Property prop, int i) throws
RepositoryException {
+ super.entering(prop, i);
+ }
+ };
+ v.visit(root);
+ System.out.println("Num ACEs: " + numACEs[0]);
+
+ session.logout();
+ }
+
+ @Override
+ public void afterSuite() throws Exception {
+ Session session = loginWriter();
+ Node root = session.getRootNode().getNode(ROOT_NODE_NAME);
+ root.remove();
+ session.logout();
+ }
+
+ @Override
+ public void runTest() throws Exception {
+ Session session = null;
+ try {
+ session = runAsAdmin ? loginWriter() : loginAnonymous();
+ for (int i=0; i<itemsToRead; i++) {
+ session.refresh(false);
+ int a = random.nextInt(NODE_COUNT);
+ int b = random.nextInt(NODE_COUNT);
+ String path = "/" + ROOT_NODE_NAME + "/node" + a + "/node" + b
+ "/jcr:primaryType";
+ session.getProperty(path).getString();
+ }
+ } finally {
+ if (session != null) {
+ session.logout();
+ }
+ }
+ }
+
+
+}