limit threadpool size in concurrent hash join

Signed-off-by: Duc Canh Le <duccanh.le@ahrefs.com>
This commit is contained in:
Duc Canh Le 2024-09-10 03:12:44 +00:00
parent cc165f9349
commit 11478b949f
2 changed files with 6 additions and 1 deletions

View File

@ -23,6 +23,7 @@
#include <Common/scope_guard_safe.h>
#include <Common/setThreadName.h>
#include <Common/typeid_cast.h>
#include <Core/Settings.h>
namespace ProfileEvents
{
@ -81,11 +82,14 @@ ConcurrentHashJoin::ConcurrentHashJoin(
: context(context_)
, table_join(table_join_)
, slots(toPowerOfTwo(std::min<UInt32>(static_cast<UInt32>(slots_), 256)))
, max_threads(context->getSettingsRef().max_threads > 0 ? std::min(slots, context->getSettingsRef().max_threads.value) : slots)
, pool(std::make_unique<ThreadPool>(
CurrentMetrics::ConcurrentHashJoinPoolThreads,
CurrentMetrics::ConcurrentHashJoinPoolThreadsActive,
CurrentMetrics::ConcurrentHashJoinPoolThreadsScheduled,
slots))
/*max_threads_*/ max_threads,
/*max_free_threads_*/ max_threads,
/*queue_size_*/ slots))
, stats_collecting_params(stats_collecting_params_)
{
hash_joins.resize(slots);

View File

@ -70,6 +70,7 @@ private:
ContextPtr context;
std::shared_ptr<TableJoin> table_join;
size_t slots;
size_t max_threads;
std::unique_ptr<ThreadPool> pool;
std::vector<std::shared_ptr<InternalHashJoin>> hash_joins;