Skip to content
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

feat(server): adoption for off-heap memory management in kout module #2704

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Pengzna
Copy link
Contributor

@Pengzna Pengzna commented Dec 9, 2024

wip...

Copy link

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 34.35115% with 86 lines in your changes missing coverage. Please review.

Project coverage is 37.15%. Comparing base (f0b1395) to head (db3ee80).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...e/hugegraph/memory/consumer/factory/IdFactory.java 0.00% 39 Missing ⚠️
...a/org/apache/hugegraph/api/traversers/KoutAPI.java 61.90% 7 Missing and 1 partial ⚠️
...graph/memory/consumer/factory/PropertyFactory.java 0.00% 8 Missing ⚠️
...g/apache/hugegraph/backend/store/BackendTable.java 0.00% 7 Missing ⚠️
...main/java/org/apache/hugegraph/util/Consumers.java 57.14% 5 Missing and 1 partial ⚠️
...graph/backend/cache/CachedSchemaTransactionV2.java 0.00% 5 Missing ⚠️
...g/apache/hugegraph/structure/HugeEdgeProperty.java 0.00% 3 Missing ⚠️
...ava/org/apache/hugegraph/schema/SchemaElement.java 33.33% 1 Missing and 1 partial ⚠️
.../java/org/apache/hugegraph/structure/HugeEdge.java 66.66% 1 Missing and 1 partial ⚠️
...ava/org/apache/hugegraph/structure/HugeVertex.java 66.66% 1 Missing and 1 partial ⚠️
... and 4 more

❗ There is a different number of reports uploaded between BASE (f0b1395) and HEAD (db3ee80). Click for more details.

HEAD has 6 uploads less than BASE
Flag BASE (f0b1395) HEAD (db3ee80)
7 1
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2704      +/-   ##
============================================
- Coverage     46.99%   37.15%   -9.85%     
+ Complexity      821      493     -328     
============================================
  Files           745      745              
  Lines         60062    60148      +86     
  Branches       7670     7687      +17     
============================================
- Hits          28225    22345    -5880     
- Misses        29014    35354    +6340     
+ Partials       2823     2449     -374     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -93,27 +97,40 @@ public String get(@Context GraphManager manager,
"'{}', max degree '{}', capacity '{}' and limit '{}'",
graph, source, direction, edgeLabel, depth,
nearest, maxDegree, capacity, limit);
MemoryPool queryPool = MemoryManager.getInstance().addQueryMemoryPool();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we bind a MemoryPool for each graph

.bindCorrespondingTaskMemoryPool(Thread.currentThread().getName(),
(TaskMemoryPool) currentTaskPool);
MemoryPool currentOperationPool = currentTaskPool.addChildPool("kout-main-operation");
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a method like graph.switchToMemoryPool("kout", "main")?


ApiMeasurer measure = new ApiMeasurer();
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer to add a wrapper method for MemoryPool init-and-gc, then call the original method?

@@ -260,6 +260,7 @@ private Iterator<HugeVertex> queryVerticesByIds(IdQuery query) {
return QueryResults.emptyIterator();
}
if (needCacheVertex(vertex)) {
vertex.convertIdToOnHeapIfNeeded();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's ok to just call convert in HeapCache.update(), at the same time, we avoid modifying the code everywhere

private static Id generateId(HugeType type, Id id) {
// NOTE: it's slower performance to use:
// String.format("%x-%s", type.code(), name)
return IdGenerator.of(type.string() + "-" + id.asString());
return new IdGenerator.StringId(type.string() + "-" + id.asString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a OnHeapIdGenerator.of() class?

@@ -58,7 +58,9 @@ public BinaryBackendEntry.BinaryId newBinaryId(byte[] bytes, Id id) {
.getCorrespondingTaskMemoryPool(
Thread.currentThread()
.getName());
return new BinaryIdOffHeap(bytes, null,
return taskMemoryPool == null ?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect this.taskMemoryPool style

@@ -58,7 +58,9 @@ public BinaryBackendEntry.BinaryId newBinaryId(byte[] bytes, Id id) {
.getCorrespondingTaskMemoryPool(
Thread.currentThread()
.getName());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer by Thread id instead of Thread name

if (MEMORY_MODE == MemoryMode.DISABLE_MEMORY_MANAGEMENT) {
return null;
}

int count = queryMemoryPools.size();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect this.xx stype

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between QueryMemoryPool and MemoryPool? if no difference, just naming MemoryPool is ok.
and can we make some special names for CorrespondingTaskMemoryPool and CurrentWorkingOperatorMemoryPool, such as RequestMemoryPool and RequestStageMemoryPool

@@ -77,7 +77,7 @@ public class MemoryManager {
private final MemoryArbitrator memoryArbitrator;
private final ExecutorService arbitrateExecutor;

private static MemoryMode MEMORY_MODE = MemoryMode.ENABLE_OFF_HEAP_MANAGEMENT;
private static MemoryMode MEMORY_MODE = MemoryMode.DISABLE_MEMORY_MANAGEMENT;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEMORY_MODE style is only for const var, and if there is only a single MemoryManager, also remove static mark: private MemoryMode memoryMode

return new BinaryIdOffHeap(bytes, null,
return taskMemoryPool == null ?
new BinaryBackendEntry.BinaryId(bytes, id) :
new BinaryIdOffHeap(bytes, null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can directly get the memory pool at one time MemoryManager.getInstance().currentMemoryPool(), it does the 2 steps:
getCorrespondingTaskMemoryPool, getCurrentWorkingOperatorMemoryPool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants