xinyiZzz commented on a change in pull request #8476:
URL: https://github.com/apache/incubator-doris/pull/8476#discussion_r829152380



##########
File path: be/src/runtime/row_batch.cpp
##########
@@ -39,8 +40,8 @@ namespace doris {
 const int RowBatch::AT_CAPACITY_MEM_USAGE = 8 * 1024 * 1024;
 const int RowBatch::FIXED_LEN_BUFFER_LIMIT = AT_CAPACITY_MEM_USAGE / 2;
 
-RowBatch::RowBatch(const RowDescriptor& row_desc, int capacity, MemTracker* 
mem_tracker)
-        : _mem_tracker(mem_tracker),
+RowBatch::RowBatch(const RowDescriptor& row_desc, int capacity)
+        : 
_mem_tracker(thread_local_ctx.get()->_thread_mem_tracker_mgr->mem_tracker()),

Review comment:
       I understand that modifying the mem tracker of `rowbatch` is not 
directly related to the thread used.
   
   My understanding of this question is: whether there is a `rowbatch`, consume 
tls A mem tracker when new, release tls B mem tracker when delete, and both 
trackers are not equal to 0 when they are finally destructed.
   
   The actual code now avoids the above problem. Through 
`RowBatch::acquire_state` and `RowBatch::transfer_resource_ownership`, complete 
the mem_tracker update and memory ownership transfer of buffers in two 
`row_batch`, avoiding the new and delete of buffers in a `rowbatch` on 
different trackers.
   
   For example: In `OlapScanNode::get_next`, the `rowbatch` created by Scanner 
will be transferred to the external parameter `row_batch` through 
`RowBatch::acquire_state`, and the mem tracker of the buffer will be modified. 
Ownership is transferred in two row_batches via `update_mem_tracker`.
   
   But I'm not sure if the buffer mem_tracker is updated in all similar places, 
which requires manual maintenance to ensure that the new and delete of a buffer 
are in the same tracker. **I will test further. **
   
   Similarly, `mem pool` also has a similar situation, `mem pool` also provides 
`MemPool::acquire_data` and `MemPool::exchange_data` to complete the transfer 
of chunks. However, I used to add the tls mem tracker when allocate in each 
`chunk`, and found that the `chunk` tracker is different from the tls mem 
tracker when the `mem pool` is destructed.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to