-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance Optimization: Lazy Load Vertex Relations #4343
Conversation
821111c
to
dfbb92e
Compare
8a8c0d2
to
1711b2b
Compare
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.
Thank you @ntisseyre ! LGTM. I have left two nitpicks, but otherwise it looks good.
@JanusGraph/committers merging this PR using lazy consensus in a week.
janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyRelation.java
Outdated
Show resolved
Hide resolved
janusgraph-core/src/main/java/org/janusgraph/graphdb/transaction/TransactionConfiguration.java
Show resolved
Hide resolved
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.
One more nitpick is the commit message. It says "Initial commit", but better to use more concrete commit description.
bb98134
to
367df51
Compare
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.
I love the idea of lazy-loading but I am not sure if I understand when this is useful and how powerful it is. Is it possible to add a new benchmark under janusgraph-benchmark
module?
Could you also please run a full build with your feature turned on by default? You could create a bogus PR to trigger CI runs. I would love to see if that can help us capture bugs.
|
||
import java.util.Iterator; | ||
|
||
public class JanusGraphLazyProperty<V> extends JanusGraphLazyRelation<V> implements JanusGraphVertexProperty<V> { |
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.
Consider: renaming this to JanusGraphLazyVertexProperty
. A "property" can be attached to a vertex, an edge, or a vertex property.
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.
Renamed
* <p> | ||
* When enabled, it can have a boost on large scale read operations, when only certain type of relations are being read. | ||
* | ||
* @return Object with the skip db-cache reads check settings |
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.
Wrong comment?
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.
Fixed
@@ -320,6 +326,7 @@ public void close() { | |||
config.getVertexCacheSize(), effectiveVertexCacheSize, MIN_VERTEX_CACHE_SIZE); | |||
} | |||
|
|||
relTypeCache = new ConcurrentHashMap<>(30); |
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.
If only used by JanusGraphLazyRelation
, looks like there's no reason to initialize relTypeCache
if this transaction doesn't have lazyLoadRelations()
enabled?
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.
Fixed
janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyRelation.java
Show resolved
Hide resolved
9709a6f
to
d725e10
Compare
Signed-off-by: ntisseyre <ntisseyre@apple.com>
d725e10
to
cd52b37
Compare
Comments explained in #4367 (comment) make sense to me. @li-boxuan will you be able to check if you have any concerns or other comments regarding this PR? |
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.
Great contribution, thank you! I would like to see some benchmark numbers or a new benchmark checked-in for perf-related PRs, but since this feature is off by default, I am happy to accept it as it is.
Thank you @li-boxuan ! |
You should just add a new param into you test and annotate it. The benchmark test will detect all the annotated parameters and will execute tests with all combinations of all provided values. Here is an example of a boolean parameter (can be seen in this benchmark test):
You can create a similar param for lazy-loading feature. A quick thing you can do in the PR #4367 :
You can see the following report under that CI job:
Some things to notice:
For reference: janusgraph/janusgraph-benchmark/src/main/java/org/janusgraph/BenchmarkRunner.java Line 95 in 1c53402
|
Thank you @porunov ! |
It was not triggered due to failed checkstyle:
|
Oh, thanks! Fixed |
Hmm. Seems OOM.
So, it seems never executed any benchmark test with |
I have reduced it to only 5k vertices and put isLazyLoad=true to be executed first. |
Below are the tests I executed on my local laptop with minimal parallel processes running. Master branch basic benchmark tests:
Current PR basic benchmark tests:
The benchmark test introduced in #4367
Conclusion: |
Optimizing reads of large amounts of vertexes by doing lazy-load (lazy-deserialization) of vertex properties or edges.
Lazy-load is not enabled by default and should be set explicitly on a
TransactionBuilder
.Leveraging vertex's query-cache for multiQuery operations instead of rebuilding the query while loading vertex relations.