You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by tw...@apache.org on 2015/12/31 17:15:49 UTC
[2/2] incubator-tinkerpop git commit: New gremlin-benchmark module
added with microbenchmark base class inspired by the Netty projects use of
JMH. Simple addV/addVertex benchmarks added to test insert performance.
New gremlin-benchmark module added with microbenchmark base class inspired by the Netty projects use of JMH. Simple addV/addVertex benchmarks added to test insert performance.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/70640684
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/70640684
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/70640684
Branch: refs/heads/TINKERPOP-1016
Commit: 70640684f75139ee65b3deb58c91c139f58f14c8
Parents: b89e860
Author: Ted Wilmes <tw...@gmail.com>
Authored: Thu Dec 31 10:15:27 2015 -0600
Committer: Ted Wilmes <tw...@gmail.com>
Committed: Thu Dec 31 10:15:27 2015 -0600
----------------------------------------------------------------------
gremlin-benchmark/pom.xml | 115 ++++++++++++
.../benchmark/util/AbstractMicrobenchmark.java | 79 ++++++++
.../process/GraphTraversalBenchmark.java | 54 ++++++
gremlin-performance/pom.xml | 182 -------------------
.../process/GraphTraversalPerformance.java | 81 ---------
5 files changed, 248 insertions(+), 263 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/70640684/gremlin-benchmark/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-benchmark/pom.xml b/gremlin-benchmark/pom.xml
new file mode 100644
index 0000000..c7cafc0
--- /dev/null
+++ b/gremlin-benchmark/pom.xml
@@ -0,0 +1,115 @@
+<!--
+Copyright (c) 2014, Oracle America, Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the name of Oracle nor the names of its contributors may be used
+ to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>tinkerpop</artifactId>
+ <groupId>org.apache.tinkerpop</groupId>
+ <version>3.1.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>gremlin-benchmark</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache TinkerPop :: Gremlin Benchmark</name>
+ <dependencies>
+ <!-- TESTING -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-core</artifactId>
+ <version>3.1.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>tinkergraph-gremlin</artifactId>
+ <version>3.1.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-shaded</artifactId>
+ <version>3.1.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openjdk.jmh</groupId>
+ <artifactId>jmh-core</artifactId>
+ <version>${jmh.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openjdk.jmh</groupId>
+ <artifactId>jmh-generator-annprocess</artifactId>
+ <version>${jmh.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <jmh.version>1.11.2</jmh.version>
+ <javac.target>1.6</javac.target>
+ <skipPerformanceTests>true</skipPerformanceTests>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/*Benchmark*.java</include>
+ </includes>
+ <excludes>
+ <exclude>**/Abstract*</exclude>
+ <exclude>**/AbstractMicrobenchmark.java</exclude>
+ <exclude>**/*$*.class</exclude>
+ <exclude>**/*_jmhType*</exclude>
+ </excludes>
+ <systemPropertyVariables>
+ <perfReportDir>${project.build.directory}/reports/performance/</perfReportDir>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/70640684/gremlin-benchmark/src/test/java/org/apache/tinkerpop/benchmark/util/AbstractMicrobenchmark.java
----------------------------------------------------------------------
diff --git a/gremlin-benchmark/src/test/java/org/apache/tinkerpop/benchmark/util/AbstractMicrobenchmark.java b/gremlin-benchmark/src/test/java/org/apache/tinkerpop/benchmark/util/AbstractMicrobenchmark.java
new file mode 100644
index 0000000..9e6a781
--- /dev/null
+++ b/gremlin-benchmark/src/test/java/org/apache/tinkerpop/benchmark/util/AbstractMicrobenchmark.java
@@ -0,0 +1,79 @@
+/*
+ * 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.tinkerpop.benchmark.util;
+
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.options.ChainedOptionsBuilder;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+
+/**
+ * Base class for all JMH benchmarks. Based upon Netty's AbstractMicrobenchmark.
+ */
+@Warmup(iterations = AbstractMicrobenchmark.DEFAULT_WARMUP_ITERATIONS)
+@Measurement(iterations = AbstractMicrobenchmark.DEFAULT_MEASURE_ITERATIONS)
+@Fork(AbstractMicrobenchmark.DEFAULT_FORKS)
+public abstract class AbstractMicrobenchmark {
+
+ protected static final int DEFAULT_WARMUP_ITERATIONS = 10;
+ protected static final int DEFAULT_MEASURE_ITERATIONS = 10;
+ protected static final int DEFAULT_FORKS = 2;
+
+ protected static final String[] JVM_ARGS = {
+ "-server", "-Xms512m", "-Xmx512m"
+ };
+
+ @Test
+ public void run() throws Exception {
+ String className = getClass().getSimpleName();
+
+ ChainedOptionsBuilder runnerOptions = new OptionsBuilder()
+ .include(".*" + className + ".*")
+ .jvmArgs(JVM_ARGS);
+
+ if (getWarmupIterations() > 0) {
+ runnerOptions.warmupIterations(getWarmupIterations());
+ }
+
+ if (getMeasureIterations() > 0) {
+ runnerOptions.measurementIterations(getMeasureIterations());
+ }
+
+ if (getForks() > 0) {
+ runnerOptions.forks(getForks());
+ }
+
+ new Runner(runnerOptions.build()).run();
+ }
+
+ protected int getWarmupIterations() {
+ return DEFAULT_WARMUP_ITERATIONS;
+ }
+
+ protected int getMeasureIterations() {
+ return DEFAULT_MEASURE_ITERATIONS;
+ }
+
+ protected int getForks() {
+ return DEFAULT_FORKS;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/70640684/gremlin-benchmark/src/test/java/org/apache/tinkerpop/gremlin/process/GraphTraversalBenchmark.java
----------------------------------------------------------------------
diff --git a/gremlin-benchmark/src/test/java/org/apache/tinkerpop/gremlin/process/GraphTraversalBenchmark.java b/gremlin-benchmark/src/test/java/org/apache/tinkerpop/gremlin/process/GraphTraversalBenchmark.java
new file mode 100644
index 0000000..ea81b61
--- /dev/null
+++ b/gremlin-benchmark/src/test/java/org/apache/tinkerpop/gremlin/process/GraphTraversalBenchmark.java
@@ -0,0 +1,54 @@
+/*
+ * 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.tinkerpop.gremlin.process;
+
+import org.apache.tinkerpop.benchmark.util.AbstractMicrobenchmark;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.State;
+
+/**
+ * @author Ted Wilmes
+ */
+public class GraphTraversalBenchmark extends AbstractMicrobenchmark {
+
+ @State(Scope.Thread)
+ public static class GraphState {
+ volatile Graph graph = TinkerGraph.open();
+ }
+
+ @State(Scope.Thread)
+ public static class TraversalState {
+ volatile GraphTraversalSource g = TinkerGraph.open().traversal();
+ }
+
+ @Benchmark
+ public Vertex testAddVertex(GraphState state) { return state.graph.addVertex("foo"); }
+
+ @Benchmark
+ public Vertex testAddV(TraversalState state) {
+ return state.g.addV("foo").next();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/70640684/gremlin-performance/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-performance/pom.xml b/gremlin-performance/pom.xml
deleted file mode 100644
index da2a835..0000000
--- a/gremlin-performance/pom.xml
+++ /dev/null
@@ -1,182 +0,0 @@
-<!--
-Copyright (c) 2014, Oracle America, Inc.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of Oracle nor the names of its contributors may be used
- to endorse or promote products derived from this software without
- specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGE.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>tinkerpop</artifactId>
- <groupId>org.apache.tinkerpop</groupId>
- <version>3.1.1-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>gremlin-performance</artifactId>
- <packaging>jar</packaging>
-
- <name>JMH benchmark sample: Java</name>
-
- <!--
- This is the demo/sample template build script for building Java benchmarks with JMH.
- Edit as needed.
- -->
-
- <prerequisites>
- <maven>3.0</maven>
- </prerequisites>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tinkerpop</groupId>
- <artifactId>gremlin-core</artifactId>
- <version>3.1.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tinkerpop</groupId>
- <artifactId>tinkergraph-gremlin</artifactId>
- <version>3.1.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tinkerpop</groupId>
- <artifactId>gremlin-shaded</artifactId>
- <version>3.1.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.openjdk.jmh</groupId>
- <artifactId>jmh-core</artifactId>
- <version>${jmh.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openjdk.jmh</groupId>
- <artifactId>jmh-generator-annprocess</artifactId>
- <version>${jmh.version}</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <jmh.version>1.11.2</jmh.version>
- <javac.target>1.6</javac.target>
- <uberjar.name>benchmarks</uberjar.name>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.1</version>
- <configuration>
- <compilerVersion>${javac.target}</compilerVersion>
- <source>${javac.target}</source>
- <target>${javac.target}</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>2.2</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <finalName>${uberjar.name}</finalName>
- <transformers>
- <transformer
- implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
- <mainClass>org.openjdk.jmh.Main</mainClass>
- </transformer>
- </transformers>
- <filters>
- <filter>
- <!--
- Shading signed JARs will fail without this.
- http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
- -->
- <artifact>*:*</artifact>
- <excludes>
- <exclude>META-INF/*.SF</exclude>
- <exclude>META-INF/*.DSA</exclude>
- <exclude>META-INF/*.RSA</exclude>
- </excludes>
- </filter>
- </filters>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- <pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-clean-plugin</artifactId>
- <version>2.5</version>
- </plugin>
- <plugin>
- <artifactId>maven-deploy-plugin</artifactId>
- <version>2.8.1</version>
- </plugin>
- <plugin>
- <artifactId>maven-install-plugin</artifactId>
- <version>2.5.1</version>
- </plugin>
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.4</version>
- </plugin>
- <plugin>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.9.1</version>
- </plugin>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <version>2.6</version>
- </plugin>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <version>3.3</version>
- </plugin>
- <plugin>
- <artifactId>maven-source-plugin</artifactId>
- <version>2.2.1</version>
- </plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.17</version>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/70640684/gremlin-performance/src/main/java/org/apache/tinkerpop/gremlin/process/GraphTraversalPerformance.java
----------------------------------------------------------------------
diff --git a/gremlin-performance/src/main/java/org/apache/tinkerpop/gremlin/process/GraphTraversalPerformance.java b/gremlin-performance/src/main/java/org/apache/tinkerpop/gremlin/process/GraphTraversalPerformance.java
deleted file mode 100644
index fcb36bd..0000000
--- a/gremlin-performance/src/main/java/org/apache/tinkerpop/gremlin/process/GraphTraversalPerformance.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.tinkerpop.gremlin.process;
-
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import org.openjdk.jmh.annotations.Benchmark;
-import org.openjdk.jmh.annotations.BenchmarkMode;
-import org.openjdk.jmh.annotations.Mode;
-import org.openjdk.jmh.annotations.OutputTimeUnit;
-import org.openjdk.jmh.annotations.Scope;
-import org.openjdk.jmh.annotations.State;
-import org.openjdk.jmh.profile.StackProfiler;
-import org.openjdk.jmh.runner.Runner;
-import org.openjdk.jmh.runner.RunnerException;
-import org.openjdk.jmh.runner.options.Options;
-import org.openjdk.jmh.runner.options.OptionsBuilder;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * Created by twilmes on 12/24/15.
- */
-public class GraphTraversalPerformance {
-
- @State(Scope.Thread)
- public static class GraphState {
- volatile Graph graph = TinkerGraph.open();
- }
-
- @State(Scope.Thread)
- public static class TraversalState {
- volatile GraphTraversalSource g = TinkerGraph.open().traversal();
- }
-
- @Benchmark
-// @BenchmarkMode(Mode.AverageTime)
-// @OutputTimeUnit(TimeUnit.MICROSECONDS)
- public Vertex testAddVertex(GraphState state) {
- return state.graph.addVertex("foo");
- }
-
- @Benchmark
-// @BenchmarkMode(Mode.AverageTime)
-// @OutputTimeUnit(TimeUnit.MICROSECONDS)
- public Vertex testAddV(TraversalState state) {
- return state.g.addV("foo").next();
- }
-
-
- public static void main(String[] args) throws RunnerException {
- Options opt = new OptionsBuilder()
- .include(GraphTraversalPerformance.class.getSimpleName())
- .warmupIterations(5)
- .measurementIterations(10)
- .addProfiler(StackProfiler.class)
- .forks(1)
- .build();
-
- new Runner(opt).run();
- }
-}