yiguolei commented on code in PR #12620: URL: https://github.com/apache/doris/pull/12620#discussion_r1013694741
########## be/src/util/blocking_priority_queue.hpp: ########## @@ -49,143 +49,126 @@ class BlockingPriorityQueue { // -- timeout_ms: 0 means wait indefinitely bool blocking_get(T* out, uint32_t timeout_ms = 0) { MonotonicStopWatch timer; + timer.start(); std::unique_lock<std::mutex> unique_lock(_lock); - - while (true) { - if (!_queue.empty()) { - // 定期提高队列中残留的任务优先级 - // 保证优先级较低的大查询不至于完全饿死 - if (_upgrade_counter > config::priority_queue_remaining_tasks_increased_frequency) { - std::priority_queue<T> tmp_queue; - while (!_queue.empty()) { - T v = _queue.top(); - _queue.pop(); - ++v; - tmp_queue.push(v); - } - swap(_queue, tmp_queue); - _upgrade_counter = 0; + bool wait_successful = false; + if (timeout_ms > 0) { + wait_successful = _get_cv.wait_for(unique_lock, std::chrono::milliseconds(timeout_ms), + [this] { return _shutdown || !_queue.empty(); }); + } else { + _get_cv.wait(unique_lock, [this] { return _shutdown || !_queue.empty(); }); + wait_successful = true; + } + _total_get_wait_time += timer.elapsed_time(); Review Comment: 我感觉这个语义不一致了, 在原来的代码里,即使wait 失败,也会调整队列中已有元素的优先级; 但是在你改的新的代码里,只有wait 成功了,才调整? -- 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