mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Do not create extra thread in PipelineExecutor if num_threads is 1.
This commit is contained in:
parent
3f35d143b3
commit
faf118fb15
@ -720,29 +720,35 @@ void PipelineExecutor::executeImpl(size_t num_threads)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < num_threads; ++i)
|
if (num_threads > 1)
|
||||||
{
|
{
|
||||||
threads.emplace_back([this, thread_group, thread_num = i, num_threads]
|
|
||||||
|
for (size_t i = 0; i < num_threads; ++i)
|
||||||
{
|
{
|
||||||
/// ThreadStatus thread_status;
|
threads.emplace_back([this, thread_group, thread_num = i, num_threads]
|
||||||
|
{
|
||||||
|
/// ThreadStatus thread_status;
|
||||||
|
|
||||||
setThreadName("QueryPipelineEx");
|
setThreadName("QueryPipelineEx");
|
||||||
|
|
||||||
if (thread_group)
|
if (thread_group)
|
||||||
CurrentThread::attachTo(thread_group);
|
CurrentThread::attachTo(thread_group);
|
||||||
|
|
||||||
SCOPE_EXIT(
|
SCOPE_EXIT(
|
||||||
if (thread_group)
|
if (thread_group)
|
||||||
CurrentThread::detachQueryIfNotDetached();
|
CurrentThread::detachQueryIfNotDetached();
|
||||||
);
|
);
|
||||||
|
|
||||||
executeSingleThread(thread_num, num_threads);
|
executeSingleThread(thread_num, num_threads);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto & thread : threads)
|
||||||
|
if (thread.joinable())
|
||||||
|
thread.join();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
for (auto & thread : threads)
|
executeSingleThread(0, num_threads);
|
||||||
if (thread.joinable())
|
|
||||||
thread.join();
|
|
||||||
|
|
||||||
finished_flag = true;
|
finished_flag = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user