Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions be/src/vec/runtime/shared_hash_table_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ bool SharedHashTableController::should_build_hash_table(const TUniqueId& fragmen

SharedHashTableContextPtr SharedHashTableController::get_context(int my_node_id) {
std::lock_guard<std::mutex> lock(_mutex);
auto it = _shared_contexts.find(my_node_id);
if (it == _shared_contexts.cend()) {
if (!_shared_contexts.count(my_node_id)) {
_shared_contexts.insert({my_node_id, std::make_shared<SharedHashTableContext>()});
}
return _shared_contexts[my_node_id];
Expand Down
24 changes: 17 additions & 7 deletions be/src/vec/runtime/vdata_stream_recvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ Status VDataStreamRecvr::SenderQueue::add_block(const PBlock& pblock, int be_num
COUNTER_UPDATE(_recvr->_rows_produced_counter, block->rows());
COUNTER_UPDATE(_recvr->_blocks_produced_counter, 1);

_block_queue.emplace_back(std::move(block), block_byte_size);
bool empty = !block->rows();

if (!empty) {
_block_queue.emplace_back(std::move(block), block_byte_size);
}
// if done is nullptr, this function can't delay this response
if (done != nullptr && _recvr->exceeds_limit(block_byte_size)) {
MonotonicStopWatch monotonicStopWatch;
Expand All @@ -169,8 +173,10 @@ Status VDataStreamRecvr::SenderQueue::add_block(const PBlock& pblock, int be_num
_pending_closures.emplace_back(*done, monotonicStopWatch);
*done = nullptr;
}
_recvr->update_blocks_memory_usage(block_byte_size);
_data_arrival_cv.notify_one();
_recvr->_blocks_memory_usage->add(block_byte_size);
if (!empty) {
_data_arrival_cv.notify_one();
}
return Status::OK();
}

Expand Down Expand Up @@ -207,8 +213,12 @@ void VDataStreamRecvr::SenderQueue::add_block(Block* block, bool use_move) {
COUNTER_UPDATE(_recvr->_rows_produced_counter, block->rows());
COUNTER_UPDATE(_recvr->_blocks_produced_counter, 1);

_block_queue.emplace_back(std::move(nblock), block_mem_size);
_data_arrival_cv.notify_one();
bool empty = !nblock->rows();

if (!empty) {
_block_queue.emplace_back(std::move(nblock), block_mem_size);
_data_arrival_cv.notify_one();
}

// Careful: Accessing members of _recvr that are allocated by Object pool
// should be done before the following logic, because the _lock will be released
Expand Down Expand Up @@ -389,8 +399,8 @@ bool VDataStreamRecvr::sender_queue_empty(int sender_id) {
}

bool VDataStreamRecvr::ready_to_read() {
for (size_t i = 0; i < _sender_queues.size(); i++) {
if (_sender_queues[i]->should_wait()) {
for (const auto& queue : _sender_queues) {
if (queue->should_wait()) {
return false;
}
}
Expand Down
4 changes: 3 additions & 1 deletion be/src/vec/runtime/vdata_stream_recvr.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ class VDataStreamRecvr::PipSenderQueue : public SenderQueue {
}

void add_block(Block* block, bool use_move) override {
if (block->rows() == 0) return;
if (block->rows() == 0) {
return;
}
{
std::unique_lock<std::mutex> l(_lock);
if (_is_cancelled) {
Expand Down