javeme commented on code in PR #2704:
URL: 
https://github.com/apache/incubator-hugegraph/pull/2704#discussion_r2296092639


##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/memory/consumer/factory/IdFactory.java:
##########
@@ -58,7 +58,9 @@ public BinaryBackendEntry.BinaryId newBinaryId(byte[] bytes, 
Id id) {
                                                                               
.getCorrespondingTaskMemoryPool(
                                                                                
       Thread.currentThread()
                                                                                
             .getName());
-                return new BinaryIdOffHeap(bytes, null,
+                return taskMemoryPool == null ?
+                       new BinaryBackendEntry.BinaryId(bytes, id) :
+                       new BinaryIdOffHeap(bytes, null,

Review Comment:
   and can we rename some methods for a more concise and consistent style:
   1. getCorrespondingTaskMemoryPool => currentTaskMemoryPool
   2. getCurrentWorkingOperatorMemoryPool => currentOperatorMemoryPool
   3. MemoryPool.getSnapShot() => MemoryPool.getStats()



##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/Consumers.java:
##########
@@ -105,11 +110,25 @@ public void start(String name) {
                  this.workers, name, this.queueSize);
         for (int i = 0; i < this.workers; i++) {
             this.runningFutures.add(
-                    this.executor.submit(new 
ContextCallable<>(this::runAndDone)));
+                    this.executor.submit(
+                            new ContextCallable<>(() -> 
this.runAndDone(MemoryManager.getInstance()

Review Comment:
   should we move this TaskMemoryPool-bind code into ContextCallable?



##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/memory/consumer/factory/IdFactory.java:
##########
@@ -58,7 +58,9 @@ public BinaryBackendEntry.BinaryId newBinaryId(byte[] bytes, 
Id id) {
                                                                               
.getCorrespondingTaskMemoryPool(
                                                                                
       Thread.currentThread()
                                                                                
             .getName());
-                return new BinaryIdOffHeap(bytes, null,
+                return taskMemoryPool == null ?
+                       new BinaryBackendEntry.BinaryId(bytes, id) :
+                       new BinaryIdOffHeap(bytes, null,

Review Comment:
   also move MemoryPoolStats out from impl?



##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/traversers/KoutAPI.java:
##########
@@ -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();
+        Optional.ofNullable(queryPool).ifPresent(pool -> {
+            MemoryPool currentTaskPool = pool.addChildPool("kout-main-task");
+            MemoryManager.getInstance()
+                         
.bindCorrespondingTaskMemoryPool(Thread.currentThread().getName(),
+                                                          (TaskMemoryPool) 
currentTaskPool);
+            MemoryPool currentOperationPool = 
currentTaskPool.addChildPool("kout-main-operation");

Review Comment:
   we can let:
   1. MemoryPool.addChildPool return QueryMemoryPool
   2. QueryMemoryPool.addChildPool return TaskMemoryPool
   3. TaskMemoryPooll.addChildPool return OperatorMemoryPool



##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/Consumers.java:
##########
@@ -105,11 +110,25 @@ public void start(String name) {
                  this.workers, name, this.queueSize);
         for (int i = 0; i < this.workers; i++) {
             this.runningFutures.add(
-                    this.executor.submit(new 
ContextCallable<>(this::runAndDone)));
+                    this.executor.submit(
+                            new ContextCallable<>(() -> 
this.runAndDone(MemoryManager.getInstance()
+                                                                               
      .getCorrespondingTaskMemoryPool(
+                                                                               
              Thread.currentThread()
+                                                                               
                    .getName())))));
         }
     }
 
-    private Void runAndDone() {
+    private Void runAndDone(MemoryPool taskPool) {
+        MemoryPool currentTaskPool = null;
+        if (Objects.nonNull(taskPool)) {
+            currentTaskPool = 
taskPool.findRootQueryPool().addChildPool("kout-consume-task");
+            MemoryManager.getInstance()
+                         
.bindCorrespondingTaskMemoryPool(Thread.currentThread().getName(),
+                                                          (TaskMemoryPool) 
currentTaskPool);
+            MemoryPool currentOperationPool =
+                    currentTaskPool.addChildPool("kout-consume-operation");

Review Comment:
   the Consumers is a general class, seems it's not appropriate to put the 
upper-level kout code here



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@hugegraph.apache.org
For additional commands, e-mail: issues-h...@hugegraph.apache.org

Reply via email to