Hello Eugene - we responded to your last email on this topic when you first posted it, but perhaps you didn't see it. Here is the original thread:
https://lists.apache.org/thread.html/a7e6cfeadad10852a2deed8616e47df6738c13c47119c12f98dcd3e1@%3Cdev.tinkerpop.apache.org%3E On Thu, Dec 28, 2017 at 8:08 AM, Eugene Chung <[email protected]> wrote: > Hello, TinkerPop developers! > > > I’m the user of JanusGraph, as you may know, which is the graph database on > top of the gremlin server. > Recently on the investigation of why the gremlin-server uses UUID as its > request id, > I saw that the Builder class of > org.apache.tinkerpop.gremlin.driver.message.RequestMessage > class sets its requestId field as UUID.randomUUID() by default. > > But I think it should be fixed not to be set by default. The reasons are > below; > > - UUID.randomUUID() uses SecureRandom which grabs the lock at JVM level, > which means whole threads calling this API compete against each other. > - Getting random value from SecureRandom is somewhat CPU-intensive job. > - If a gremlin client sends requestId by itself, the costs above are > useless. > > > If you guys think my suggestion is reasonable, I will make this as git pull > request. > > > > > > > Index: gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/ > driver/message/RequestMessage.java > IDEA additional info: > Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP > <+>UTF-8 > =================================================================== > --- gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/ > driver/message/RequestMessage.java (revision > fa0a0ee64331bb1e67248137bd97fe > 001554ac10) > +++ gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/ > driver/message/RequestMessage.java (date 1512465656000) > @@ -112,7 +112,7 @@ > */ > public static final class Builder { > public static final String OP_PROCESSOR_NAME = ""; > - private UUID requestId = UUID.randomUUID(); > + private UUID requestId; > private String op; > private String processor = OP_PROCESSOR_NAME; > private Map<String, Object> args = new HashMap<>(); > @@ -155,7 +155,7 @@ > * Create the request message given the settings provided to the > {@link Builder}. > */ > public RequestMessage create() { > - return new RequestMessage(requestId, op, processor, args); > + return new RequestMessage(requestId == null ? > UUID.randomUUID() : requestId, op, processor, args); > } > } >
