Merge pull request #48244 from azat/fix-threadpools

Fix incorrect ThreadPool usage after ThreadPool introspection
This commit is contained in:
Alexander Tokmakov 2023-03-31 01:48:01 +03:00 committed by GitHub
commit 46e85357ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 3 deletions

View File

@ -78,6 +78,12 @@
M(BackupsThreadsActive, "Number of threads in thread pool for BACKUP running a task.") \ M(BackupsThreadsActive, "Number of threads in thread pool for BACKUP running a task.") \
M(RestoreThreads, "Number of threads in the thread pool for RESTORE.") \ M(RestoreThreads, "Number of threads in the thread pool for RESTORE.") \
M(RestoreThreadsActive, "Number of threads in the thread pool for RESTORE running a task.") \ M(RestoreThreadsActive, "Number of threads in the thread pool for RESTORE running a task.") \
M(MarksLoaderThreads, "Number of threads in thread pool for loading marks.") \
M(MarksLoaderThreadsActive, "Number of threads in the thread pool for loading marks running a task.") \
M(IOPrefetchThreads, "Number of threads in the IO prefertch thread pool.") \
M(IOPrefetchThreadsActive, "Number of threads in the IO prefetch thread pool running a task.") \
M(IOWriterThreads, "Number of threads in the IO writer thread pool.") \
M(IOWriterThreadsActive, "Number of threads in the IO writer thread pool running a task.") \
M(IOThreads, "Number of threads in the IO thread pool.") \ M(IOThreads, "Number of threads in the IO thread pool.") \
M(IOThreadsActive, "Number of threads in the IO thread pool running a task.") \ M(IOThreadsActive, "Number of threads in the IO thread pool running a task.") \
M(ThreadPoolRemoteFSReaderThreads, "Number of threads in the thread pool for remote_filesystem_read_method=threadpool.") \ M(ThreadPoolRemoteFSReaderThreads, "Number of threads in the thread pool for remote_filesystem_read_method=threadpool.") \

View File

@ -145,6 +145,12 @@ namespace CurrentMetrics
extern const Metric BackgroundFetchesPoolSize; extern const Metric BackgroundFetchesPoolSize;
extern const Metric BackgroundCommonPoolTask; extern const Metric BackgroundCommonPoolTask;
extern const Metric BackgroundCommonPoolSize; extern const Metric BackgroundCommonPoolSize;
extern const Metric MarksLoaderThreads;
extern const Metric MarksLoaderThreadsActive;
extern const Metric IOPrefetchThreads;
extern const Metric IOPrefetchThreadsActive;
extern const Metric IOWriterThreads;
extern const Metric IOWriterThreadsActive;
} }
namespace DB namespace DB
@ -2018,7 +2024,8 @@ ThreadPool & Context::getLoadMarksThreadpool() const
{ {
auto pool_size = config.getUInt(".load_marks_threadpool_pool_size", 50); auto pool_size = config.getUInt(".load_marks_threadpool_pool_size", 50);
auto queue_size = config.getUInt(".load_marks_threadpool_queue_size", 1000000); auto queue_size = config.getUInt(".load_marks_threadpool_queue_size", 1000000);
shared->load_marks_threadpool = std::make_unique<ThreadPool>(pool_size, pool_size, queue_size); shared->load_marks_threadpool = std::make_unique<ThreadPool>(
CurrentMetrics::MarksLoaderThreads, CurrentMetrics::MarksLoaderThreadsActive, pool_size, pool_size, queue_size);
} }
return *shared->load_marks_threadpool; return *shared->load_marks_threadpool;
} }
@ -2043,7 +2050,8 @@ ThreadPool & Context::getPrefetchThreadpool() const
{ {
auto pool_size = getPrefetchThreadpoolSize(); auto pool_size = getPrefetchThreadpoolSize();
auto queue_size = config.getUInt(".prefetch_threadpool_queue_size", 1000000); auto queue_size = config.getUInt(".prefetch_threadpool_queue_size", 1000000);
shared->prefetch_threadpool = std::make_unique<ThreadPool>(pool_size, pool_size, queue_size); shared->prefetch_threadpool = std::make_unique<ThreadPool>(
CurrentMetrics::IOPrefetchThreads, CurrentMetrics::IOPrefetchThreadsActive, pool_size, pool_size, queue_size);
} }
return *shared->prefetch_threadpool; return *shared->prefetch_threadpool;
} }
@ -3967,7 +3975,8 @@ ThreadPool & Context::getThreadPoolWriter() const
auto pool_size = config.getUInt(".threadpool_writer_pool_size", 100); auto pool_size = config.getUInt(".threadpool_writer_pool_size", 100);
auto queue_size = config.getUInt(".threadpool_writer_queue_size", 1000000); auto queue_size = config.getUInt(".threadpool_writer_queue_size", 1000000);
shared->threadpool_writer = std::make_unique<ThreadPool>(pool_size, pool_size, queue_size); shared->threadpool_writer = std::make_unique<ThreadPool>(
CurrentMetrics::IOWriterThreads, CurrentMetrics::IOWriterThreadsActive, pool_size, pool_size, queue_size);
} }
return *shared->threadpool_writer; return *shared->threadpool_writer;