You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2018/04/20 23:28:14 UTC

[1/4] tinkerpop git commit: TINKERPOP-1936 Improved performance of Bytecode deserialization.

Repository: tinkerpop
Updated Branches:
  refs/heads/tp33 4705c0416 -> 7e6e98548


TINKERPOP-1936 Improved performance of Bytecode deserialization.

GraphSON deserialization of Bytecode was using generic List deserialization which became especially costly for Jackson in 2.5.x because of changes that synchronized access to the deserialization cache and because the collection deserialization were no longer cacheable when type deserialization was in play. This change removed the use of generic type lists in deserialization and more directly handled the parsing of the lists thus bypassing the collection deserializer for this specific case.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/e68df44c
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/e68df44c
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/e68df44c

Branch: refs/heads/tp33
Commit: e68df44caaafd9f4037da8e03be660a4124555eb
Parents: a7c8ea1
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Apr 12 10:25:20 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Apr 16 13:47:35 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../io/graphson/TraversalSerializersV2d0.java   | 35 +++++++++++++-------
 2 files changed, 24 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e68df44c/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 0f3a71a..51c9f68 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -24,6 +24,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 === TinkerPop 3.2.9 (Release Date: NOT OFFICIALLY RELEASED YET)
 
 * Bumped to httpclient 4.5.5.
+* Improved performance of GraphSON deserialization of `Bytecode`.
 
 [[release-3-2-8]]
 === TinkerPop 3.2.8 (Release Date: April 2, 2018)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e68df44c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV2d0.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV2d0.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV2d0.java
index a696280..040fd1d 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV2d0.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV2d0.java
@@ -248,8 +248,6 @@ final class TraversalSerializersV2d0 {
     //////////////////
 
     final static class BytecodeJacksonDeserializer extends StdDeserializer<Bytecode> {
-        private static final JavaType listJavaType = TypeFactory.defaultInstance().constructCollectionType(ArrayList.class, Object.class);
-        private static final JavaType listListJavaType = TypeFactory.defaultInstance().constructCollectionType(ArrayList.class, listJavaType);
 
         public BytecodeJacksonDeserializer() {
             super(Bytecode.class);
@@ -260,17 +258,30 @@ final class TraversalSerializersV2d0 {
             final Bytecode bytecode = new Bytecode();
 
             while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
-                if (jsonParser.getCurrentName().equals(GraphSONTokens.SOURCE)) {
+                final String current = jsonParser.getCurrentName();
+                if (current.equals(GraphSONTokens.SOURCE) || current.equals(GraphSONTokens.STEP)) {
                     jsonParser.nextToken();
-                    final List<List<Object>> instructions = deserializationContext.readValue(jsonParser, listListJavaType);
-                    for (final List<Object> instruction : instructions) {
-                        bytecode.addSource((String) instruction.get(0), Arrays.copyOfRange(instruction.toArray(), 1, instruction.size()));
-                    }
-                } else if (jsonParser.getCurrentName().equals(GraphSONTokens.STEP)) {
-                    jsonParser.nextToken();
-                    final List<List<Object>> instructions = deserializationContext.readValue(jsonParser, listListJavaType);
-                    for (final List<Object> instruction : instructions) {
-                        bytecode.addStep((String) instruction.get(0), Arrays.copyOfRange(instruction.toArray(), 1, instruction.size()));
+
+                    while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
+
+                        // there should be a list now and the first item in the list is always string and is the step name
+                        // skip the start array
+                        jsonParser.nextToken();
+                        
+                        final String stepName = jsonParser.getText();
+
+                        // iterate through the rest of the list for arguments until it gets to the end
+                        final List<Object> arguments = new ArrayList<>();
+                        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
+                            // we don't know the types here, so let the deserializer figure that business out
+                            arguments.add(deserializationContext.readValue(jsonParser, Object.class));
+                        }
+
+                        // if it's not a "source" then it must be a "step"
+                        if (current.equals(GraphSONTokens.SOURCE))
+                            bytecode.addSource(stepName, arguments.toArray());
+                        else
+                            bytecode.addStep(stepName, arguments.toArray());
                     }
                 }
             }


[3/4] tinkerpop git commit: Merge branch 'tp32' into tp33

Posted by sp...@apache.org.
Merge branch 'tp32' into tp33


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/b8b46b06
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/b8b46b06
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/b8b46b06

Branch: refs/heads/tp33
Commit: b8b46b06a26c58395ef2d878c2c2ed0665c0e788
Parents: 4705c04 6b259f7
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Apr 20 19:03:42 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Apr 20 19:03:42 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../io/graphson/TraversalSerializersV2d0.java   | 35 +++++++++++++-------
 2 files changed, 24 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b8b46b06/CHANGELOG.asciidoc
----------------------------------------------------------------------


[2/4] tinkerpop git commit: Merge branch 'TINKERPOP-1936' into tp32

Posted by sp...@apache.org.
Merge branch 'TINKERPOP-1936' into tp32


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/6b259f72
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/6b259f72
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/6b259f72

Branch: refs/heads/tp33
Commit: 6b259f729137033a240254ade36e4726809b46e7
Parents: b99c56a e68df44
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Apr 20 19:03:20 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Apr 20 19:03:20 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../io/graphson/TraversalSerializersV2d0.java   | 35 +++++++++++++-------
 2 files changed, 24 insertions(+), 12 deletions(-)
----------------------------------------------------------------------



[4/4] tinkerpop git commit: TINKERPOP-1936 Implemented bytecode serialization performance enhancement for GraphSON 3.0

Posted by sp...@apache.org.
TINKERPOP-1936 Implemented bytecode serialization performance enhancement for GraphSON 3.0


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/7e6e9854
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/7e6e9854
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/7e6e9854

Branch: refs/heads/tp33
Commit: 7e6e98548625c83ad419737166fe6c679d204468
Parents: b8b46b0
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Apr 20 19:26:05 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Apr 20 19:26:05 2018 -0400

----------------------------------------------------------------------
 .../io/graphson/TraversalSerializersV3d0.java   | 33 ++++++++++++++------
 1 file changed, 23 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7e6e9854/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV3d0.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV3d0.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV3d0.java
index fd11f25..eaa7b0f 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV3d0.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV3d0.java
@@ -252,17 +252,30 @@ final class TraversalSerializersV3d0 {
             final Bytecode bytecode = new Bytecode();
 
             while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
-                if (jsonParser.getCurrentName().equals(GraphSONTokens.SOURCE)) {
+                final String current = jsonParser.getCurrentName();
+                if (current.equals(GraphSONTokens.SOURCE) || current.equals(GraphSONTokens.STEP)) {
                     jsonParser.nextToken();
-                    final List<List<Object>> instructions = deserializationContext.readValue(jsonParser, listListJavaType);
-                    for (final List<Object> instruction : instructions) {
-                        bytecode.addSource((String) instruction.get(0), Arrays.copyOfRange(instruction.toArray(), 1, instruction.size()));
-                    }
-                } else if (jsonParser.getCurrentName().equals(GraphSONTokens.STEP)) {
-                    jsonParser.nextToken();
-                    final List<List<Object>> instructions = deserializationContext.readValue(jsonParser, listListJavaType);
-                    for (final List<Object> instruction : instructions) {
-                        bytecode.addStep((String) instruction.get(0), Arrays.copyOfRange(instruction.toArray(), 1, instruction.size()));
+
+                    while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
+
+                        // there should be a list now and the first item in the list is always string and is the step name
+                        // skip the start array
+                        jsonParser.nextToken();
+
+                        final String stepName = jsonParser.getText();
+
+                        // iterate through the rest of the list for arguments until it gets to the end
+                        final List<Object> arguments = new ArrayList<>();
+                        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
+                            // we don't know the types here, so let the deserializer figure that business out
+                            arguments.add(deserializationContext.readValue(jsonParser, Object.class));
+                        }
+
+                        // if it's not a "source" then it must be a "step"
+                        if (current.equals(GraphSONTokens.SOURCE))
+                            bytecode.addSource(stepName, arguments.toArray());
+                        else
+                            bytecode.addStep(stepName, arguments.toArray());
                     }
                 }
             }