[GitHub] spmallette opened a new pull request #1062: TINKERPOP-2163 Improved performance of JavaTranslator method selection

2019-02-15 Thread GitBox
spmallette opened a new pull request #1062: TINKERPOP-2163 Improved performance 
of JavaTranslator method selection
URL: https://github.com/apache/tinkerpop/pull/1062
 
 
   https://issues.apache.org/jira/browse/TINKERPOP-2163
   
   Every time I think there's nothing else to squeeze out of this class I find 
something new. This time I cached results of `Method.getParameters()` as well 
as varargs checks. The former offered the bigger benefit as calls to that 
method forced a `clone()` of the parameter array, but the latter also helped.
   
   Prior to the change on `tp33` we were getting:
   
   ```text
   Benchmark Mode  CntScore 
  Error  Units
   JavaTranslatorBenchmark.testTranslationLong  thrpt   2025812.057 
±   504.233  ops/s
   JavaTranslatorBenchmark.testTranslationMediumthrpt   20   316019.034 
± 13852.097  ops/s
   JavaTranslatorBenchmark.testTranslationShort thrpt   20  1403109.145 
± 41460.176  ops/s
   JavaTranslatorBenchmark.testTranslationWithStrategy  thrpt   2049316.015 
±  1701.437  ops/s
   ```
   
   and now, with this change, we're looking at:
   
   ```text
   Benchmark Mode  CntScore 
  Error  Units
   JavaTranslatorBenchmark.testTranslationLong  thrpt   2030270.986 
±   553.973  ops/s
   JavaTranslatorBenchmark.testTranslationMediumthrpt   20   385286.380 
±  6572.709  ops/s
   JavaTranslatorBenchmark.testTranslationShort thrpt   20  1724457.005 
± 11173.083  ops/s
   JavaTranslatorBenchmark.testTranslationWithStrategy  thrpt   2060989.899 
±   533.268  ops/s
   ```
   
   That's roughly 20% improvement. Not bad.
   
   All tests pass with `docker/build.sh -t -n -i`
   
   VOTE +1
   
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[tinkerpop] branch master updated: More serialization benchmarks

2019-02-15 Thread jorgebg
This is an automated email from the ASF dual-hosted git repository.

jorgebg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git


The following commit(s) were added to refs/heads/master by this push:
 new 555d726  More serialization benchmarks
555d726 is described below

commit 555d726d1937e4e4213890e4e8c51f189475f724
Author: Jorge Bay Gondra 
AuthorDate: Fri Feb 15 10:09:10 2019 +0100

More serialization benchmarks
---
 .../gremlin/driver/SerializationBenchmark.java | 52 +-
 1 file changed, 50 insertions(+), 2 deletions(-)

diff --git 
a/gremlin-tools/gremlin-benchmark/src/main/java/org/apache/tinkerpop/gremlin/driver/SerializationBenchmark.java
 
b/gremlin-tools/gremlin-benchmark/src/main/java/org/apache/tinkerpop/gremlin/driver/SerializationBenchmark.java
index d68b8ab..d919add 100644
--- 
a/gremlin-tools/gremlin-benchmark/src/main/java/org/apache/tinkerpop/gremlin/driver/SerializationBenchmark.java
+++ 
b/gremlin-tools/gremlin-benchmark/src/main/java/org/apache/tinkerpop/gremlin/driver/SerializationBenchmark.java
@@ -19,13 +19,18 @@
 package org.apache.tinkerpop.gremlin.driver;
 
 import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
 import io.netty.buffer.Unpooled;
 import org.apache.tinkerpop.benchmark.util.AbstractBenchmarkBase;
 import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
+import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
+import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
 import org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1;
 import org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0;
 import org.apache.tinkerpop.gremlin.driver.ser.SerializationException;
 import org.apache.tinkerpop.gremlin.driver.ser.binary.DataType;
+import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex;
 import org.openjdk.jmh.annotations.Benchmark;
 
 import java.nio.charset.StandardCharsets;
@@ -46,7 +51,7 @@ public class SerializationBenchmark extends 
AbstractBenchmarkBase {
 
 private static final ByteBuf RequestMessageBinaryBuffer1 = 
Unpooled.wrappedBuffer(new byte[]{
 // flag
-0x1,
+(byte)0x81,
 // uuid
 (byte) 0xd3, (byte) 0xfd, 0x35, 0x40, 0x67, 0x18, 0x46, (byte) 
0x87,(byte) 0x95, 0x6b, (byte) 0xc8, 0x61,
 (byte) 0x8a, 0x26, (byte) 0xe3, 0x35,
@@ -60,7 +65,7 @@ public class SerializationBenchmark extends 
AbstractBenchmarkBase {
 
 private static final ByteBuf RequestMessageBinaryBuffer2 = 
Unpooled.wrappedBuffer(new byte[]{
 // flag
-0x1,
+(byte)0x81,
 // uuid
 (byte) 0xd3, (byte) 0xfd, 0x35, 0x40, 0x67, 0x18, 0x46, (byte) 
0x87,(byte) 0x95, 0x6b, (byte) 0xc8, 0x61,
 (byte) 0x8a, 0x26, (byte) 0xe3, 0x35,
@@ -90,9 +95,26 @@ public class SerializationBenchmark extends 
AbstractBenchmarkBase {
 
 private static final UUID id = UUID.randomUUID();
 
+private static final ResponseMessage response = ResponseMessage
+
.build(UUID.randomUUID()).code(ResponseStatusCode.SUCCESS).result(new 
ReferenceVertex(1, "person"))
+.create();
+
+private static final Bytecode bytecode = new Bytecode();
+private static final RequestMessage request = RequestMessage
+
.build(Tokens.OPS_BYTECODE).processor("traversal").overrideRequestId(UUID.randomUUID())
+.add(Tokens.ARGS_GREMLIN, bytecode)
+.create();
+
 private static final GraphBinaryMessageSerializerV1 binarySerializer = new 
GraphBinaryMessageSerializerV1();
 private static final GraphSONMessageSerializerV3d0 graphsonSerializer = 
new GraphSONMessageSerializerV3d0();
 
+static {
+bytecode.addStep("V");
+bytecode.addStep("values", "name");
+bytecode.addStep("order");
+bytecode.addStep("tail", 5);
+}
+
 @Benchmark
 public RequestMessage testReadMessage1Binary() throws 
SerializationException {
 RequestMessageBinaryBuffer1.readerIndex(0);
@@ -119,6 +141,32 @@ public class SerializationBenchmark extends 
AbstractBenchmarkBase {
 }
 
 @Benchmark
+public void testWriteResponseBinary() throws SerializationException {
+ByteBuf buffer = binarySerializer.serializeResponseAsBinary(response, 
ByteBufAllocator.DEFAULT);
+buffer.release();
+}
+
+@Benchmark
+public void testWriteResponseGraphSON() throws SerializationException {
+ByteBuf buffer = 
graphsonSerializer.serializeResponseAsBinary(response, 
ByteBufAllocator.DEFAULT);
+buffer.release();
+}
+
+@Benchmark
+public void testWriteBytecodeBinary() throws SerializationException {
+
+ByteBuf buffer = binarySerializer.serializeRequestAsBinary(request, 
ByteBufAllocator.DEFAULT);
+buffer.relea