Improve vertex label lookup
Fix for #1709 Signed-off-by: Pavel Ershov [email protected]
Thank you for contributing to JanusGraph!
In order to streamline the review of the contribution we ask you to ensure the following steps have been taken:
For all changes:
- [ ] Is there an issue associated with this PR? Is it referenced in the commit message?
- [ ] Does your PR body contain #xyz where xyz is the issue number you are trying to resolve?
- [ ] Has your PR been rebased against the latest commit within the target branch (typically
master)? - [ ] Is your initial contribution a single, squashed commit?
For code changes:
- [ ] Have you written and/or updated unit tests to verify your changes?
- [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
- [ ] If applicable, have you updated the LICENSE.txt file, including the main LICENSE.txt file in the root of this repository?
- [ ] If applicable, have you updated the NOTICE.txt file, including the main NOTICE.txt file found in the root of this repository?
For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
- [ ] If this PR is a documentation-only change, have you added a
[skip ci]tag to the first line of your commit message to avoid spending CPU cycles in Travis CI when no code, tests, or build configuration are modified?
Note:
Please ensure that once the PR is submitted, you check Travis CI for build issues and submit an update to your PR as soon as possible.
Root cause is it added relations container
We use multiples EventListener in our traversal that do some work on newly added/changed vertices. When we add multuple vertices with properties and trying to access to label in same tx from listeners it lead to sequntial scan added relations container this apect is inefficient.
Test JanusGraphPerformanceMemoryTest.labelRetrivial demonstrte this case, 5s on master vs 0,5s on this branch
We see same issue when we want to rewrite properties in same tx. Rewrite properties required remove from added relation container is it sequntial scan operations, see https://github.com/JanusGraph/janusgraph/pull/1701
For avoid this issues we may avoid this pattern of use OR add label cache, use more complex structure for added relations container
I think current approach may be simplified, for avoid redundant operation we need use SimpleVertexQueryProcessor for this label query. I will try this and test
And remove new field from AbstractVertex that increase vertex size to 8 byte

The committers are authorized under a signed CLA.
- :white_check_mark: Pavel (079e09c70bf38869351d998ec6e9b7fd0cf3fa72)
Current approach introduced new field to AbstractVerex, so vertex size is increased. I don't think it will good for some use cases.
Need more investigation. May be some query cache will help with this type of issue https://github.com/JanusGraph/janusgraph/blob/master/janusgraph-core/src/main/java/org/janusgraph/graphdb/database/StandardJanusGraph.java#L306
@mad Is this ready for review? If so, can you rebase it? Otherwise, we can convert it to a draft.