import org.apache.tinkerpop.gremlin.jsr223.JavaTranslatorimport org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyTranslator//// EXECUTED LOCALLY (e.g. CLIENT APPLICATION) ////g = EmptyGraph.instance().traversal()t = g.V().has('name','marko').repeat(out()).times(2).groupCount().by('name'); []bytecode = t.bytecode// send the bytecode over the wire//// EXECUTED REMOTELY (e.g. GREMLIN SERVER) ////groovy = new GremlinGroovyScriptEngine()bindings = groovy.createBindings()bindings.put('g',g)compiled = groovy.compile(GroovyTranslator.of('g').translate(bytecode))x = JavaTranslator.of(g).translate(bytecode); []y = compiled.eval(bindings); []z = groovy.eval(GroovyTranslator.of('g').translate(bytecode), bindings); []x == yy == zz == xx.toString()clock(1000){ JavaTranslator.of(g).translate(bytecode) }clock(1000){ compiled.eval(bindings) } // cachingclock(1000){ groovy.reset(); groovy.eval(GroovyTranslator.of('g').translate(bytecode), bindings) } // no caching
gremlin> x = JavaTranslator.of(g).translate(bytecode); []gremlin> y = compiled.eval(bindings); []gremlin> z = groovy.eval(GroovyTranslator.of('g').translate(bytecode), bindings); []gremlin> x == y==>truegremlin> y == z==>truegremlin> z == x==>truegremlin> x.toString()==>[GraphStep(vertex,[]), HasStep([name.eq(marko)]), RepeatStep([VertexStep(OUT,vertex), RepeatEndStep],until(loops(2)),emit(false)), GroupCountStep(value(name))]gremlin>
gremlin> clock(1000){ JavaTranslator.of(g).translate(bytecode) }==>0.004768085gremlin> clock(1000){ compiled.eval(bindings) } // caching==>0.015168259gremlin> clock(1000){ groovy.reset(); groovy.eval(GroovyTranslator.of('g').translate(bytecode), bindings) } // no caching==>40.790075693gremlin>
I love the idea, but here are my concerns:How can difference in client and server JVM compiler versions affect bytecode evaluation by a server? What if client was compiled with newer compiler, and the server does not recognize the version of bytecode sent by the client? I would assume it will fail. And what will happen when serialVersionUID differs if client and server are on different versions of application (not the tinkerpop version)? There will be no problem with groovy string in either case, but the java bytecode evaluation may fail, right?
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/22b8b005-1101-4c5c-bdb4-942a4cff585f%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/2849e02e-d0f2-416f-bcb2-5b9f23578098%40googlegroups.com.
Bytecode
There's no controlling for gc or anything here so take these numbers as a rough estimate.
However, once compilation time for gremilin-groovy and graphson-bytecode deserialization are accounted for then the numbers become a bit different. Groovy may see some slow down, but it's not obviously significant. However graphson -> bytecode deserializatoin slows down the total bytecode execution by 4-5x.
For the same case as above graphson/bytecode consistently executes at 0.45 - 0.8 ms / query during the 1000 iteration sample. This is roughly 3-5x slower than native Java and groovy (accounting for script compilation)
https://gist.github.com/erickj/30aa179a73ab1e2a2b7355b63a34b487#file-results-timed_compile-true
Re: executing the groovy string script vs precompiled scripts - I chose not to call reset() as Marko did above since it seems like a single scriptengine instance wouldn't be reset between each execution in production, but would simply run with a new context. However correct me if I'm wrong on this.
Soooo.... what's my point? I'm not really sure. To be honest all queries executed a fair bit faster than I expected. Even noticing that bytecode execution is significantly slower when taking graphson parsing into account, sub millisecond execution time still seems very fast however maybe gremlin execution isn't as slow as it what was billed above.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/259b1efe-1dea-4170-bf88-1167c2e2072b%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/259b1efe-1dea-4170-bf88-1167c2e2072b%40googlegroups.com.
Robert Dale