Gabriel39 commented on code in PR #35642: URL: https://github.com/apache/doris/pull/35642#discussion_r1623229932
########## be/src/pipeline/exec/exchange_sink_buffer.cpp: ########## @@ -50,35 +50,40 @@ namespace vectorized { BroadcastPBlockHolder::~BroadcastPBlockHolder() { // lock the parent queue, if the queue could lock success, then return the block // to the queue, to reuse the block - std::shared_ptr<BroadcastPBlockHolderQueue> tmp_queue = _parent_creator.lock(); - if (tmp_queue != nullptr) { - tmp_queue->push(BroadcastPBlockHolder::create_shared(std::move(_pblock))); + std::shared_ptr<BroadcastPBlockHolderMemLimiter> limiter = _parent_creator.lock(); + if (limiter != nullptr) { + limiter->release(*this); } // If the queue already deconstruted, then release pblock automatically since it // is a unique ptr. } -void BroadcastPBlockHolderQueue::push(std::shared_ptr<BroadcastPBlockHolder> holder) { +void BroadcastPBlockHolderMemLimiter::acquire(BroadcastPBlockHolder& holder) { std::unique_lock l(_holders_lock); - holder->set_parent_creator(shared_from_this()); - _holders.push(holder); if (_broadcast_dependency) { - _broadcast_dependency->set_ready(); + holder.set_parent_creator(shared_from_this()); + auto size = holder._pblock->column_values().size(); + _total_queue_buffer_size += size; + _total_queue_blocks_count++; + if (_total_queue_buffer_size >= config::exchg_node_buffer_size_bytes || + _total_queue_blocks_count >= config::num_broadcast_buffer) { + _broadcast_dependency->block(); + } } } -std::shared_ptr<BroadcastPBlockHolder> BroadcastPBlockHolderQueue::pop() { +void BroadcastPBlockHolderMemLimiter::release(const BroadcastPBlockHolder& holder) { std::unique_lock l(_holders_lock); - if (_holders.empty()) { - return {}; - } - std::shared_ptr<BroadcastPBlockHolder> res = _holders.top(); - _holders.pop(); - if (_holders.empty() && _broadcast_dependency != nullptr) { - _broadcast_dependency->block(); + if (_broadcast_dependency) { Review Comment: `_broadcast_dependency` never should be nullptr -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org