You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ke...@apache.org on 2024/07/27 18:33:56 UTC

(tinkerpop) branch bytecode-perf-test created (now 8bbc4f20ca)

This is an automated email from the ASF dual-hosted git repository.

kenhuuu pushed a change to branch bytecode-perf-test
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git


      at 8bbc4f20ca serverAdd

This branch includes the following new commits:

     new 8bbc4f20ca serverAdd

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(tinkerpop) 01/01: serverAdd

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kenhuuu pushed a commit to branch bytecode-perf-test
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 8bbc4f20caeb03f04d1bb4d402707b3973393a45
Author: Ken Hu <10...@users.noreply.github.com>
AuthorDate: Sat Jul 27 11:33:41 2024 -0700

    serverAdd
---
 .../traversal/dsl/graph/GraphTraversal.java        |  1 +
 .../traversal/dsl/graph/GraphTraversalSource.java  |  9 +++++
 .../traversal/step/sideEffect/ServerAdd.java       | 40 ++++++++++++++++++++++
 .../gremlin/driver/util/ProfilingApplication.java  | 17 +++++++--
 4 files changed, 64 insertions(+), 3 deletions(-)

diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
index f01afa8197..7e34d94966 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
@@ -4051,6 +4051,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
         public static final String or = "or";
         public static final String and = "and";
         public static final String inject = "inject";
+        public static final String serverAdd = "serverAdd";
         public static final String dedup = "dedup";
         public static final String where = "where";
         public static final String has = "has";
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
index dc15306fce..7a71606be0 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
@@ -36,6 +36,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.map.MergeEdgeStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.MergeVertexStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IoStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.InjectStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.ServerAdd;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.RequirementsStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
 import org.apache.tinkerpop.gremlin.structure.Direction;
@@ -450,6 +451,14 @@ public class GraphTraversalSource implements TraversalSource {
         return traversal.addStep(new InjectStep<S>(traversal, s));
     }
 
+    public <S> GraphTraversal<S, S> serverAdd() {
+        // a single null is [null]
+        final GraphTraversalSource clone = this.clone();
+        clone.bytecode.addStep(GraphTraversal.Symbols.serverAdd);
+        final GraphTraversal.Admin<S, S> traversal = new DefaultGraphTraversal<>(clone);
+        return traversal.addStep(new ServerAdd<S>(traversal));
+    }
+
     /**
      * Spawns a {@link GraphTraversal} starting with all vertices or some subset of vertices as specified by their
      * unique identifier.
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/ServerAdd.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/ServerAdd.java
new file mode 100644
index 0000000000..bb13fe7d74
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/ServerAdd.java
@@ -0,0 +1,40 @@
+/*
+ * 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.traversal.step.sideEffect;
+
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.util.iterator.ArrayIterator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class ServerAdd<S> extends StartStep<S> {
+    public ServerAdd(final Traversal.Admin traversal) {
+        super(traversal);
+        final int size = 1000000;
+        List injects = new ArrayList<>(size);
+        for (int i = 0; i < size; i++) {
+            injects.add(i);
+        }
+        this.start = new ArrayIterator<>(injects.toArray());
+    }
+}
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java
index 898f3b1977..e2bf962895 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java
@@ -23,6 +23,12 @@ import org.apache.commons.lang3.concurrent.BasicThreadFactory;
 import org.apache.tinkerpop.gremlin.driver.Channelizer;
 import org.apache.tinkerpop.gremlin.driver.Client;
 import org.apache.tinkerpop.gremlin.driver.Cluster;
+import org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection;
+import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
+import org.apache.tinkerpop.gremlin.util.function.Lambda;
 import org.apache.tinkerpop.gremlin.util.ser.Serializers;
 import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
 
@@ -43,6 +49,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.IntStream;
 
+import static org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.unfold;
+
 /**
  * An internal application used to test out configuration parameters for Gremlin Driver.
  *
@@ -133,17 +142,19 @@ public class ProfilingApplication {
     }
 
     public double executeLatency() throws Exception {
-        final Client client = cluster.connect();
+        final Client client = cluster.connect().alias("g");
         final String executionId = "[" + executionName + "]";
+//        GraphTraversal traversal = traversal().withRemote(DriverRemoteConnection.using(client)).V().repeat(__.both()).times(15);
+        GraphTraversal traversal = traversal().withRemote(DriverRemoteConnection.using(client)).serverAdd().unfold();
         try {
             client.init();
 
             final long start = System.nanoTime();
             int size = 0;
-            final Iterator itr = client.submitAsync(script).get().iterator();
+//            final Iterator itr = client.submitAsync(query).get().iterator();
             try {
                 while (true) {
-                    itr.next();
+                    traversal.next();
                     size++;
                 }
             } catch (NoSuchElementException nsee) {