-
Notifications
You must be signed in to change notification settings - Fork 596
optimize: Optimize rockdb batch query performance #2982
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
base: master
Are you sure you want to change the base?
Changes from 6 commits
5ba6d4a
f5405a0
939ace0
502c7df
352f66b
0d9052d
45298f9
223fb28
ce4e2cb
6fe08a7
0391069
ce802b9
c06225c
a99491b
10cb0a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -784,7 +784,8 @@ protected Iterator<Vertex> queryVerticesByIds(Object[] vertexIds, boolean adjace | |
| List<Id> ids = InsertionOrderUtil.newList(); | ||
| Map<Id, HugeVertex> vertices = new HashMap<>(vertexIds.length); | ||
|
|
||
| IdQuery query = new IdQuery(type); | ||
| List<Id> backendIds = InsertionOrderUtil.newList(); | ||
|
|
||
| for (Object vertexId : vertexIds) { | ||
| HugeVertex vertex; | ||
| Id id = HugeVertex.getIdValue(vertexId); | ||
|
|
@@ -799,17 +800,30 @@ protected Iterator<Vertex> queryVerticesByIds(Object[] vertexIds, boolean adjace | |
| // Found from local tx | ||
| vertices.put(vertex.id(), vertex); | ||
| } else { | ||
| // Prepare to query from backend store | ||
| query.query(id); | ||
| // store the IDs queried from backend | ||
| backendIds.add(id); | ||
| } | ||
| ids.add(id); | ||
| } | ||
|
|
||
| if (!query.empty()) { | ||
| if (!backendIds.isEmpty()) { | ||
| // Query from backend store | ||
| query.mustSortByInput(false); | ||
| Iterator<HugeVertex> it = this.queryVerticesFromBackend(query); | ||
| QueryResults.fillMap(it, vertices); | ||
| final int batch = this.batchSize > 0 ? this.batchSize : backendIds.size(); | ||
| for (int i = 0; i < backendIds.size(); i += batch) { | ||
| int end = Math.min(i + batch, backendIds.size()); | ||
| IdQuery query = new IdQuery(type); | ||
|
||
| for (int j = i; j < end; j++) { | ||
| Id id = backendIds.get(j); | ||
| query.query(id); | ||
| } | ||
|
||
| // Single batch capacity check | ||
| Query.checkForceCapacity(query.idsSize()); | ||
|
|
||
| // Query from backend store | ||
| query.mustSortByInput(false); | ||
| Iterator<HugeVertex> it = this.queryVerticesFromBackend(query); | ||
| QueryResults.fillMap(it, vertices); | ||
| } | ||
|
||
| } | ||
|
|
||
| return new MapperIterator<>(ids.iterator(), id -> { | ||
|
|
||
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.
final int batch = this.batchSize > 0 ? this.batchSize : backendIds.size();is effectively alwaysthis.batchSizebecausequery.batch_sizeis configured with a minimum of 1 (see CoreOptions.QUERY_BATCH_SIZE). Removing the dead fallback branch will simplify the code.