orientechnologies / orientdb-gremlin

TinkerPop3 Graph Structure Implementation for OrientDB
Apache License 2.0
91 stars 32 forks source link

High Cost of first query using OrientGraphFactory #122

Open du00cs opened 7 years ago

du00cs commented 7 years ago

Hi, I notice that there are high cost of first query using OrientGraphFactory.

OrientGraph g = factory.getNoTx();
List<Object> list = g.traversal().V()...toList();
g.close();

First query will exceed 100ms in my test, getNoTx cost 517ms g.traversal().V()...toList() cost 266ms.

How can I improve the performance?

Usnul commented 6 years ago

likely class loader is to blame. Java will only load classes when they are being used, meaning when you instantiate an object with large class hierarchy behind it - it will take a lot of time. Try:

OrientGraph g0 = factory.getNoTx(); //force class loader
OrientGraph g = factory.getNoTx(); //<- measure this
List<Object> list = g.traversal().V()...toList();
g.close();