-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lazy load relations and cached query optimization
Signed-off-by: ntisseyre <ntisseyre@apple.com>
- Loading branch information
Showing
24 changed files
with
752 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...ph-backend-testutils/src/main/java/org/janusgraph/graphdb/database/LazyLoadGraphTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright 2024 JanusGraph Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package org.janusgraph.graphdb.database; | ||
|
||
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies; | ||
import org.apache.tinkerpop.gremlin.structure.Graph; | ||
import org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration; | ||
import org.janusgraph.graphdb.tinkerpop.optimize.strategy.AdjacentVertexFilterOptimizerStrategy; | ||
import org.janusgraph.graphdb.tinkerpop.optimize.strategy.AdjacentVertexHasIdOptimizerStrategy; | ||
import org.janusgraph.graphdb.tinkerpop.optimize.strategy.AdjacentVertexHasUniquePropertyOptimizerStrategy; | ||
import org.janusgraph.graphdb.tinkerpop.optimize.strategy.AdjacentVertexIsOptimizerStrategy; | ||
import org.janusgraph.graphdb.tinkerpop.optimize.strategy.JanusGraphHasStepStrategy; | ||
import org.janusgraph.graphdb.tinkerpop.optimize.strategy.JanusGraphIoRegistrationStrategy; | ||
import org.janusgraph.graphdb.tinkerpop.optimize.strategy.JanusGraphLocalQueryOptimizerStrategy; | ||
import org.janusgraph.graphdb.tinkerpop.optimize.strategy.JanusGraphMixedIndexAggStrategy; | ||
import org.janusgraph.graphdb.tinkerpop.optimize.strategy.JanusGraphMixedIndexCountStrategy; | ||
import org.janusgraph.graphdb.tinkerpop.optimize.strategy.JanusGraphMultiQueryStrategy; | ||
import org.janusgraph.graphdb.tinkerpop.optimize.strategy.JanusGraphStepStrategy; | ||
import org.janusgraph.graphdb.tinkerpop.optimize.strategy.JanusGraphUnusedMultiQueryRemovalStrategy; | ||
import org.janusgraph.graphdb.transaction.StandardTransactionBuilder; | ||
|
||
public class LazyLoadGraphTest extends StandardJanusGraph { | ||
|
||
static { | ||
TraversalStrategies graphStrategies = | ||
TraversalStrategies.GlobalCache.getStrategies(Graph.class) | ||
.clone() | ||
.addStrategies(AdjacentVertexFilterOptimizerStrategy.instance(), | ||
AdjacentVertexHasIdOptimizerStrategy.instance(), | ||
AdjacentVertexIsOptimizerStrategy.instance(), | ||
AdjacentVertexHasUniquePropertyOptimizerStrategy.instance(), | ||
JanusGraphLocalQueryOptimizerStrategy.instance(), | ||
JanusGraphHasStepStrategy.instance(), | ||
JanusGraphMultiQueryStrategy.instance(), | ||
JanusGraphUnusedMultiQueryRemovalStrategy.instance(), | ||
JanusGraphMixedIndexAggStrategy.instance(), | ||
JanusGraphMixedIndexCountStrategy.instance(), | ||
JanusGraphStepStrategy.instance(), | ||
JanusGraphIoRegistrationStrategy.instance()); | ||
|
||
//Register with cache | ||
TraversalStrategies.GlobalCache.registerStrategies(LazyLoadGraphTest.class, graphStrategies); | ||
} | ||
|
||
public LazyLoadGraphTest(GraphDatabaseConfiguration configuration) { | ||
super(configuration); | ||
} | ||
|
||
@Override | ||
public StandardTransactionBuilder buildTransaction() { | ||
return (StandardTransactionBuilder) new StandardTransactionBuilder(getConfiguration(), this) | ||
.lazyLoadRelations(); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyEdge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright 2024 JanusGraph Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package org.janusgraph.core; | ||
|
||
import org.apache.tinkerpop.gremlin.structure.Direction; | ||
import org.apache.tinkerpop.gremlin.structure.Vertex; | ||
import org.janusgraph.diskstorage.Entry; | ||
import org.janusgraph.graphdb.internal.InternalRelation; | ||
import org.janusgraph.graphdb.internal.InternalRelationType; | ||
import org.janusgraph.graphdb.internal.InternalVertex; | ||
import org.janusgraph.graphdb.transaction.StandardJanusGraphTx; | ||
|
||
public class JanusGraphLazyEdge extends JanusGraphLazyRelation implements JanusGraphEdge { | ||
|
||
public JanusGraphLazyEdge(InternalRelation janusGraphRelation, | ||
final InternalVertex vertex, | ||
final StandardJanusGraphTx tx, | ||
final InternalRelationType type) { | ||
super(janusGraphRelation, vertex, tx, type); | ||
} | ||
|
||
public JanusGraphLazyEdge(Entry dataEntry, | ||
final InternalVertex vertex, | ||
final StandardJanusGraphTx tx, | ||
final InternalRelationType type) { | ||
super(dataEntry, vertex, tx, type); | ||
} | ||
|
||
private JanusGraphEdge loadEdge() { | ||
assert this.isEdge(); | ||
return (JanusGraphEdge) this.loadValue(); | ||
} | ||
|
||
@Override | ||
public JanusGraphVertex vertex(Direction dir) { | ||
return this.loadEdge().vertex(dir); | ||
} | ||
|
||
@Override | ||
public JanusGraphVertex otherVertex(Vertex vertex) { | ||
return this.loadEdge().otherVertex(vertex); | ||
} | ||
} |
Oops, something went wrong.
eed8756
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark
org.janusgraph.JanusGraphSpeedBenchmark.basicAddAndDelete
12678.66442079929
ms/op12933.219068971923
ms/op0.98
org.janusgraph.GraphCentricQueryBenchmark.getVertices
916.0243764825278
ms/op929.0686750649414
ms/op0.99
org.janusgraph.MgmtOlapJobBenchmark.runClearIndex
216.67149341050722
ms/op215.98180543333334
ms/op1.00
org.janusgraph.MgmtOlapJobBenchmark.runReindex
341.4182077570238
ms/op348.8265452326923
ms/op0.98
org.janusgraph.JanusGraphSpeedBenchmark.basicCount
249.49973397477777
ms/op227.8074437066411
ms/op1.10
org.janusgraph.CQLMultiQueryMultiSlicesBenchmark.getValuesAllPropertiesWithAllMultiQuerySlicesUnderMaxRequestsPerConnection
4704.075343697388
ms/op4880.398383755226
ms/op0.96
org.janusgraph.CQLMultiQueryBenchmark.getElementsWithUsingEmitRepeatSteps
17089.148950020644
ms/op17909.154248616192
ms/op0.95
org.janusgraph.CQLMultiQueryMultiSlicesBenchmark.getValuesMultiplePropertiesWithSmallBatch
19038.33927982909
ms/op18799.44054118485
ms/op1.01
org.janusgraph.CQLMultiQueryMultiSlicesBenchmark.vertexCentricPropertiesFetching
55155.52174623333
ms/op55455.590322899996
ms/op0.99
org.janusgraph.CQLMultiQueryBenchmark.getAllElementsTraversedFromOuterVertex
8259.741554868839
ms/op8339.218499689177
ms/op0.99
org.janusgraph.CQLMultiQueryBenchmark.getVerticesWithDoubleUnion
378.80942984394284
ms/op371.31223395833683
ms/op1.02
org.janusgraph.CQLMultiQueryMultiSlicesBenchmark.getValuesAllPropertiesWithUnlimitedBatch
4097.631038617774
ms/op4227.4425002369935
ms/op0.97
org.janusgraph.CQLMultiQueryBenchmark.getNames
8555.594055950249
ms/op8528.923591561108
ms/op1.00
org.janusgraph.CQLMultiQueryMultiSlicesBenchmark.getValuesThreePropertiesWithAllMultiQuerySlicesUnderMaxRequestsPerConnection
5567.592398543387
ms/op5366.416493988495
ms/op1.04
org.janusgraph.CQLMultiQueryBenchmark.getLabels
7659.8008969863695
ms/op7119.612218557372
ms/op1.08
org.janusgraph.CQLMultiQueryBenchmark.getVerticesFilteredByAndStep
427.68424227969876
ms/op416.6330074327548
ms/op1.03
org.janusgraph.CQLMultiQueryBenchmark.getVerticesFromMultiNestedRepeatStepStartingFromSingleVertex
13337.651814085833
ms/op13040.1543998325
ms/op1.02
org.janusgraph.CQLMultiQueryBenchmark.getVerticesWithCoalesceUsage
361.41930296416683
ms/op366.6865794040481
ms/op0.99
org.janusgraph.CQLMultiQueryMultiSlicesBenchmark.getValuesMultiplePropertiesWithAllMultiQuerySlicesUnderMaxRequestsPerConnection
13490.815819325278
ms/op14169.280107965806
ms/op0.95
org.janusgraph.CQLMultiQueryBenchmark.getIdToOutVerticesProjection
247.62920066460927
ms/op243.11426684096145
ms/op1.02
org.janusgraph.CQLMultiQueryMultiSlicesBenchmark.getValuesMultiplePropertiesWithUnlimitedBatch
14123.495211349142
ms/op14724.027508337518
ms/op0.96
org.janusgraph.CQLMultiQueryBenchmark.getNeighborNames
8682.87428737609
ms/op8379.61509861012
ms/op1.04
org.janusgraph.CQLMultiQueryBenchmark.getElementsWithUsingRepeatUntilSteps
9231.822722551216
ms/op9197.912189783667
ms/op1.00
org.janusgraph.CQLMultiQueryBenchmark.getAdjacentVerticesLocalCounts
9322.620928881099
ms/op8786.588147997933
ms/op1.06
This comment was automatically generated by workflow using github-action-benchmark.