diff options
author | babenko <[email protected]> | 2024-12-07 16:11:49 +0300 |
---|---|---|
committer | babenko <[email protected]> | 2024-12-07 16:30:46 +0300 |
commit | 1f88159da6c7212dc21c80a8322bc7a4ab260e07 (patch) | |
tree | 99221589c11f4dac4aa3e2e78a9595bd68e2fd83 | |
parent | 9f614b2e21a8d3264bf0afbd7cb7b20e5dac3ac6 (diff) |
YT-18571: Rename Configure methods to better match the intent
commit_hash:85637bbc4fcc2974d979c5100fcb12b8cf66a76c
22 files changed, 66 insertions, 65 deletions
diff --git a/yt/yt/core/bus/tcp/dispatcher_impl.cpp b/yt/yt/core/bus/tcp/dispatcher_impl.cpp index 26df9ef38c7..5a6334ddbc8 100644 --- a/yt/yt/core/bus/tcp/dispatcher_impl.cpp +++ b/yt/yt/core/bus/tcp/dispatcher_impl.cpp @@ -186,8 +186,8 @@ void TTcpDispatcher::TImpl::Configure(const TTcpDispatcherConfigPtr& config) Config_ = config; if (XferPoller_) { - XferPoller_->Reconfigure(Config_->ThreadPoolSize); - XferPoller_->Reconfigure(Config_->ThreadPoolPollingPeriod); + XferPoller_->SetThreadCount(Config_->ThreadPoolSize); + XferPoller_->SetPollingPeriod(Config_->ThreadPoolPollingPeriod); } } diff --git a/yt/yt/core/concurrency/fair_share_thread_pool.cpp b/yt/yt/core/concurrency/fair_share_thread_pool.cpp index a72c2eb8765..a5a4d9285dc 100644 --- a/yt/yt/core/concurrency/fair_share_thread_pool.cpp +++ b/yt/yt/core/concurrency/fair_share_thread_pool.cpp @@ -524,7 +524,7 @@ public: CallbackEventCount_, GetThreadTags(ThreadNamePrefix_))) { - Configure(threadCount); + SetThreadCount(threadCount); EnsureStarted(); } @@ -533,9 +533,9 @@ public: Shutdown(); } - void Configure(int threadCount) override + void SetThreadCount(int threadCount) override { - TThreadPoolBase::Configure(threadCount); + TThreadPoolBase::SetThreadCount(threadCount); } IInvokerPtr GetInvoker(const TFairShareThreadPoolTag& tag) override @@ -560,10 +560,10 @@ private: TThreadPoolBase::DoShutdown(); } - void DoConfigure(int threadCount) override + void DoSetThreadCount(int threadCount) override { Queue_->Configure(threadCount); - TThreadPoolBase::DoConfigure(threadCount); + TThreadPoolBase::DoSetThreadCount(threadCount); } TSchedulerThreadPtr SpawnThread(int index) override diff --git a/yt/yt/core/concurrency/fair_share_thread_pool.h b/yt/yt/core/concurrency/fair_share_thread_pool.h index 77178465c86..0c4212adcbe 100644 --- a/yt/yt/core/concurrency/fair_share_thread_pool.h +++ b/yt/yt/core/concurrency/fair_share_thread_pool.h @@ -13,7 +13,7 @@ struct IFairShareThreadPool { virtual IInvokerPtr GetInvoker(const TFairShareThreadPoolTag& tag) = 0; - virtual void Configure(int threadCount) = 0; + virtual void SetThreadCount(int threadCount) = 0; virtual void Shutdown() = 0; }; diff --git a/yt/yt/core/concurrency/new_fair_share_thread_pool.cpp b/yt/yt/core/concurrency/new_fair_share_thread_pool.cpp index 6ae7082c2f1..a0e9fd4e8e2 100644 --- a/yt/yt/core/concurrency/new_fair_share_thread_pool.cpp +++ b/yt/yt/core/concurrency/new_fair_share_thread_pool.cpp @@ -622,7 +622,7 @@ public: void Configure(TDuration pollingPeriod) { - TNotifyManager::Reconfigure(pollingPeriod); + TNotifyManager::SetPollingPeriod(pollingPeriod); } // (arkady-e1ppa): Explanation of memory orders and fences around Stopped_: @@ -1317,7 +1317,7 @@ public: ThreadNamePrefix_, options)) { - Configure(threadCount); + SetThreadCount(threadCount); } ~TTwoLevelFairShareThreadPool() @@ -1325,12 +1325,12 @@ public: Shutdown(); } - void Configure(int threadCount) override + void SetThreadCount(int threadCount) override { - TThreadPoolBase::Configure(threadCount); + TThreadPoolBase::SetThreadCount(threadCount); } - void Configure(TDuration pollingPeriod) override + void SetPollingPeriod(TDuration pollingPeriod) override { Queue_->Configure(pollingPeriod); } @@ -1369,10 +1369,10 @@ private: Queue_->Drain(); } - void DoConfigure(int threadCount) override + void DoSetThreadCount(int threadCount) override { Queue_->Configure(threadCount); - TThreadPoolBase::DoConfigure(threadCount); + TThreadPoolBase::DoSetThreadCount(threadCount); } TSchedulerThreadPtr SpawnThread(int index) override diff --git a/yt/yt/core/concurrency/notify_manager.cpp b/yt/yt/core/concurrency/notify_manager.cpp index 12b2270e588..fb2c9239cf1 100644 --- a/yt/yt/core/concurrency/notify_manager.cpp +++ b/yt/yt/core/concurrency/notify_manager.cpp @@ -174,12 +174,11 @@ NThreading::TEventCount* TNotifyManager::GetEventCount() return EventCount_.Get(); } -void TNotifyManager::Reconfigure(TDuration pollingPeriod) +void TNotifyManager::SetPollingPeriod(TDuration pollingPeriod) { PollingPeriod_.store(pollingPeriod); } -// Returns true if was locked. bool TNotifyManager::UnlockNotifies() { return NotifyLock_.exchange(false); diff --git a/yt/yt/core/concurrency/notify_manager.h b/yt/yt/core/concurrency/notify_manager.h index a52eb564b1c..1760b084e84 100644 --- a/yt/yt/core/concurrency/notify_manager.h +++ b/yt/yt/core/concurrency/notify_manager.h @@ -37,7 +37,7 @@ public: NThreading::TEventCount* GetEventCount(); - void Reconfigure(TDuration pollingPeriod); + void SetPollingPeriod(TDuration pollingPeriod); private: static constexpr TCpuInstant SentinelMinEnqueuedAt = std::numeric_limits<TCpuInstant>::max(); diff --git a/yt/yt/core/concurrency/thread_pool.cpp b/yt/yt/core/concurrency/thread_pool.cpp index a4be681162b..3758619d60b 100644 --- a/yt/yt/core/concurrency/thread_pool.cpp +++ b/yt/yt/core/concurrency/thread_pool.cpp @@ -154,7 +154,7 @@ public: options.PollingPeriod)) , Invoker_(Queue_) { - Configure(threadCount); + SetThreadCount(threadCount); } ~TThreadPool() @@ -168,14 +168,14 @@ public: return Invoker_; } - void Configure(int threadCount) override + void SetThreadCount(int threadCount) override { - TThreadPoolBase::Configure(threadCount); + TThreadPoolBase::SetThreadCount(threadCount); } - void Configure(TDuration pollingPeriod) override + void SetPollingPeriod(TDuration pollingPeriod) override { - Queue_->Reconfigure(pollingPeriod); + Queue_->SetPollingPeriod(pollingPeriod); } int GetThreadCount() override diff --git a/yt/yt/core/concurrency/thread_pool.h b/yt/yt/core/concurrency/thread_pool.h index 053d877e178..533e699dca5 100644 --- a/yt/yt/core/concurrency/thread_pool.h +++ b/yt/yt/core/concurrency/thread_pool.h @@ -18,14 +18,16 @@ struct IThreadPool //! Returns the current thread count. /*! - * This can differ from value set by #Configure + * This can differ from value set by #SetThreadCount * because it clamped between 1 and the maximum thread count. */ virtual int GetThreadCount() = 0; - //! Enables changing thread pool configuration at runtime. - virtual void Configure(int threadCount) = 0; - virtual void Configure(TDuration pollingPeriod) = 0; + //! Updates thread count at runtime. + virtual void SetThreadCount(int threadCount) = 0; + + //! Updates polling period at runtime. + virtual void SetPollingPeriod(TDuration pollingPeriod) = 0; //! Returns the invoker for enqueuing callbacks into the thread pool. virtual const IInvokerPtr& GetInvoker() = 0; diff --git a/yt/yt/core/concurrency/thread_pool_detail.cpp b/yt/yt/core/concurrency/thread_pool_detail.cpp index f51e7110f39..dd26a6b6d04 100644 --- a/yt/yt/core/concurrency/thread_pool_detail.cpp +++ b/yt/yt/core/concurrency/thread_pool_detail.cpp @@ -21,9 +21,9 @@ TThreadPoolBase::TThreadPoolBase(TString threadNamePrefix) /*priority*/ 100)) { } -void TThreadPoolBase::Configure(int threadCount) +void TThreadPoolBase::SetThreadCount(int threadCount) { - DoConfigure(std::clamp(threadCount, 1, MaxThreadCount)); + DoSetThreadCount(std::clamp(threadCount, 1, MaxThreadCount)); } void TThreadPoolBase::Shutdown() @@ -79,7 +79,7 @@ int TThreadPoolBase::GetThreadCount() return std::ssize(Threads_); } -void TThreadPoolBase::DoConfigure(int threadCount) +void TThreadPoolBase::DoSetThreadCount(int threadCount) { ThreadCount_.store(threadCount); if (StartFlag_.load()) { diff --git a/yt/yt/core/concurrency/thread_pool_detail.h b/yt/yt/core/concurrency/thread_pool_detail.h index 31ef28b922e..f147c61b7ad 100644 --- a/yt/yt/core/concurrency/thread_pool_detail.h +++ b/yt/yt/core/concurrency/thread_pool_detail.h @@ -18,7 +18,7 @@ public: explicit TThreadPoolBase(TString threadNamePrefix); - void Configure(int threadCount); + void SetThreadCount(int threadCount); void Shutdown(); void EnsureStarted(); @@ -42,7 +42,7 @@ protected: virtual void DoStart(); virtual void DoShutdown(); - virtual void DoConfigure(int threadCount); + virtual void DoSetThreadCount(int threadCount); virtual TSchedulerThreadPtr SpawnThread(int index) = 0; }; diff --git a/yt/yt/core/concurrency/thread_pool_poller.cpp b/yt/yt/core/concurrency/thread_pool_poller.cpp index 8147883e28f..88a32319cb3 100644 --- a/yt/yt/core/concurrency/thread_pool_poller.cpp +++ b/yt/yt/core/concurrency/thread_pool_poller.cpp @@ -210,14 +210,14 @@ public: AuxInvoker_ = FairShareThreadPool_->GetInvoker("aux", "default"); } - void Reconfigure(int threadCount) override + void SetThreadCount(int threadCount) override { - FairShareThreadPool_->Configure(threadCount); + FairShareThreadPool_->SetThreadCount(threadCount); } - void Reconfigure(TDuration pollingPeriod) override + void SetPollingPeriod(TDuration pollingPeriod) override { - FairShareThreadPool_->Configure(pollingPeriod); + FairShareThreadPool_->SetPollingPeriod(pollingPeriod); } bool TryRegister(const IPollablePtr& pollable, TString poolName) override @@ -528,14 +528,14 @@ public: Poller_->Start(); } - void Reconfigure(int threadCount) override + void SetThreadCount(int threadCount) override { - return Poller_->Reconfigure(threadCount); + return Poller_->SetThreadCount(threadCount); } - void Reconfigure(TDuration pollingPeriod) override + void SetPollingPeriod(TDuration pollingPeriod) override { - return Poller_->Reconfigure(pollingPeriod); + return Poller_->SetPollingPeriod(pollingPeriod); } void Shutdown() override diff --git a/yt/yt/core/concurrency/thread_pool_poller.h b/yt/yt/core/concurrency/thread_pool_poller.h index 32b22bc9d75..477a902b3c4 100644 --- a/yt/yt/core/concurrency/thread_pool_poller.h +++ b/yt/yt/core/concurrency/thread_pool_poller.h @@ -10,10 +10,10 @@ struct IThreadPoolPoller : public IPoller { //! Reconfigures number of polling threads. - virtual void Reconfigure(int threadCount) = 0; + virtual void SetThreadCount(int threadCount) = 0; //! Reconfigures polling period of thread pool. - virtual void Reconfigure(TDuration pollingPeriod) = 0; + virtual void SetPollingPeriod(TDuration pollingPeriod) = 0; }; DEFINE_REFCOUNTED_TYPE(IThreadPoolPoller) diff --git a/yt/yt/core/concurrency/two_level_fair_share_thread_pool.cpp b/yt/yt/core/concurrency/two_level_fair_share_thread_pool.cpp index 3d0f46c2c2d..bf19093e2ba 100644 --- a/yt/yt/core/concurrency/two_level_fair_share_thread_pool.cpp +++ b/yt/yt/core/concurrency/two_level_fair_share_thread_pool.cpp @@ -658,7 +658,7 @@ public: ThreadNamePrefix_, std::move(poolWeightProvider))) { - Configure(threadCount); + SetThreadCount(threadCount); EnsureStarted(); } @@ -667,12 +667,12 @@ public: Shutdown(); } - void Configure(int threadCount) override + void SetThreadCount(int threadCount) override { - TThreadPoolBase::Configure(threadCount); + TThreadPoolBase::SetThreadCount(threadCount); } - void Configure(TDuration /*pollingPeriod*/) override + void SetPollingPeriod(TDuration /*pollingPeriod*/) override { } int GetThreadCount() override @@ -709,10 +709,10 @@ private: TThreadPoolBase::DoShutdown(); } - void DoConfigure(int threadCount) override + void DoSetThreadCount(int threadCount) override { Queue_->Configure(threadCount); - TThreadPoolBase::DoConfigure(threadCount); + TThreadPoolBase::DoSetThreadCount(threadCount); } TSchedulerThreadPtr SpawnThread(int index) override diff --git a/yt/yt/core/concurrency/two_level_fair_share_thread_pool.h b/yt/yt/core/concurrency/two_level_fair_share_thread_pool.h index cb013de5856..b465279a669 100644 --- a/yt/yt/core/concurrency/two_level_fair_share_thread_pool.h +++ b/yt/yt/core/concurrency/two_level_fair_share_thread_pool.h @@ -22,8 +22,8 @@ struct ITwoLevelFairShareThreadPool : public virtual TRefCounted { virtual int GetThreadCount() = 0; - virtual void Configure(int threadCount) = 0; - virtual void Configure(TDuration pollingPeriod) = 0; + virtual void SetThreadCount(int threadCount) = 0; + virtual void SetPollingPeriod(TDuration pollingPeriod) = 0; virtual IInvokerPtr GetInvoker( const TString& poolName, diff --git a/yt/yt/core/concurrency/unittests/fair_share_thread_pool_ut.cpp b/yt/yt/core/concurrency/unittests/fair_share_thread_pool_ut.cpp index a05f5bc864e..db37880121c 100644 --- a/yt/yt/core/concurrency/unittests/fair_share_thread_pool_ut.cpp +++ b/yt/yt/core/concurrency/unittests/fair_share_thread_pool_ut.cpp @@ -24,7 +24,7 @@ TEST(TFairShareThreadPoolTest, Configure) auto invoker = threadPool->GetInvoker(ToString(RandomNumber<size_t>(10))); futures.push_back(callback.AsyncVia(invoker).Run()); if (i % 100 == 0) { - threadPool->Configure(RandomNumber<size_t>(10) + 1); + threadPool->SetThreadCount(RandomNumber<size_t>(10) + 1); } } diff --git a/yt/yt/core/concurrency/unittests/thread_pool_poller_ut.cpp b/yt/yt/core/concurrency/unittests/thread_pool_poller_ut.cpp index a4760ad45fb..ceb204dbcd4 100644 --- a/yt/yt/core/concurrency/unittests/thread_pool_poller_ut.cpp +++ b/yt/yt/core/concurrency/unittests/thread_pool_poller_ut.cpp @@ -127,7 +127,7 @@ TEST_F(TThreadPoolPollerTest, SimpleReconfigure) auto pollable = New<TPollableMock>(); EXPECT_TRUE(Poller->TryRegister(pollable)); - Poller->Reconfigure(InitialThreadCount * 2); + Poller->SetThreadCount(InitialThreadCount * 2); std::vector<TFuture<void>> futures{ Poller->Unregister(pollable), @@ -184,7 +184,7 @@ TEST_F(TThreadPoolPollerTest, Stress) auxThreads.emplace_back([&] { for (int j = 0; j < 10; ++j) { for (int i = 1, sign = -1; i < 10; ++i, sign *= -1) { - Poller->Reconfigure(InitialThreadCount + sign * i); + Poller->SetThreadCount(InitialThreadCount + sign * i); } std::this_thread::yield(); } diff --git a/yt/yt/core/concurrency/unittests/thread_pool_ut.cpp b/yt/yt/core/concurrency/unittests/thread_pool_ut.cpp index 19cdb60f888..b77616c9a5e 100644 --- a/yt/yt/core/concurrency/unittests/thread_pool_ut.cpp +++ b/yt/yt/core/concurrency/unittests/thread_pool_ut.cpp @@ -25,7 +25,7 @@ TEST(TThreadPoolTest, Configure) futures.push_back(callback.AsyncVia(threadPool->GetInvoker()).Run()); if (i % 100 == 0) { threadCount = RandomNumber<size_t>(10) + 1; - threadPool->Configure(threadCount); + threadPool->SetThreadCount(threadCount); EXPECT_EQ(threadPool->GetThreadCount(), threadCount); } } @@ -34,11 +34,11 @@ TEST(TThreadPoolTest, Configure) .Get(); // Thread pool doesn't contain less than one thread whatever you configured. - threadPool->Configure(0); + threadPool->SetThreadCount(0); EXPECT_EQ(threadPool->GetThreadCount(), 1); // Thread pool doesn't contain more than maximal threads count whatever you configured. - threadPool->Configure(1e8); + threadPool->SetThreadCount(1e8); EXPECT_LE(threadPool->GetThreadCount(), 1e8); threadPool->Shutdown(); diff --git a/yt/yt/core/concurrency/unittests/two_level_fair_share_thread_pool_ut.cpp b/yt/yt/core/concurrency/unittests/two_level_fair_share_thread_pool_ut.cpp index 66e9c6a3ee2..c155f00fb89 100644 --- a/yt/yt/core/concurrency/unittests/two_level_fair_share_thread_pool_ut.cpp +++ b/yt/yt/core/concurrency/unittests/two_level_fair_share_thread_pool_ut.cpp @@ -27,7 +27,7 @@ TEST(TTwoLevelFairShareThreadPoolTest, Configure) ToString(RandomNumber<size_t>(10))); futures.push_back(callback.AsyncVia(invoker).Run()); if (i % 100 == 0) { - threadPool->Configure(RandomNumber<size_t>(10) + 1); + threadPool->SetThreadCount(RandomNumber<size_t>(10) + 1); } } diff --git a/yt/yt/core/logging/log_manager.cpp b/yt/yt/core/logging/log_manager.cpp index 791a7790a3a..6ff87e0b497 100644 --- a/yt/yt/core/logging/log_manager.cpp +++ b/yt/yt/core/logging/log_manager.cpp @@ -883,7 +883,7 @@ private: RequestSuppressionEnabled_.store(config->RequestSuppressionTimeout != TDuration::Zero()); AbortOnAlert_.store(config->AbortOnAlert); - CompressionThreadPool_->Configure(config->CompressionThreadCount); + CompressionThreadPool_->SetThreadCount(config->CompressionThreadCount); if (RequestSuppressionEnabled_) { SuppressedRequestIdSet_.SetTtl((config->RequestSuppressionTimeout + DequeuePeriod) * 2); diff --git a/yt/yt/core/net/unittests/net_ut.cpp b/yt/yt/core/net/unittests/net_ut.cpp index a5295c70290..f11d95e72ee 100644 --- a/yt/yt/core/net/unittests/net_ut.cpp +++ b/yt/yt/core/net/unittests/net_ut.cpp @@ -46,10 +46,10 @@ protected: TEST_F(TNetTest, ReconfigurePoller) { for (int i = 1; i <= 10; ++i) { - Poller_->Reconfigure(i); + Poller_->SetThreadCount(i); } for (int i = 9; i >= 10; --i) { - Poller_->Reconfigure(i); + Poller_->SetThreadCount(i); } } diff --git a/yt/yt/core/rpc/dispatcher.cpp b/yt/yt/core/rpc/dispatcher.cpp index 4398f2bc119..64edfdc3aea 100644 --- a/yt/yt/core/rpc/dispatcher.cpp +++ b/yt/yt/core/rpc/dispatcher.cpp @@ -31,10 +31,10 @@ public: void Configure(const TDispatcherConfigPtr& config) { - HeavyPool_->Configure(config->HeavyPoolSize); - HeavyPool_->Configure(config->HeavyPoolPollingPeriod); - CompressionPool_->Configure(config->CompressionPoolSize); - FairShareCompressionPool_->Configure(config->CompressionPoolSize); + HeavyPool_->SetThreadCount(config->HeavyPoolSize); + HeavyPool_->SetPollingPeriod(config->HeavyPoolPollingPeriod); + CompressionPool_->SetThreadCount(config->CompressionPoolSize); + FairShareCompressionPool_->SetThreadCount(config->CompressionPoolSize); AlertOnMissingRequestInfo_.store(config->AlertOnMissingRequestInfo); SendTracingBaggage_.store(config->SendTracingBaggage); } diff --git a/yt/yt/library/process/io_dispatcher.cpp b/yt/yt/library/process/io_dispatcher.cpp index 457a588b957..c6e7e2f67ff 100644 --- a/yt/yt/library/process/io_dispatcher.cpp +++ b/yt/yt/library/process/io_dispatcher.cpp @@ -30,7 +30,7 @@ TIODispatcher* TIODispatcher::Get() void TIODispatcher::Configure(const TIODispatcherConfigPtr& config) { - Poller_->Reconfigure(config->ThreadPoolPollingPeriod); + Poller_->SetPollingPeriod(config->ThreadPoolPollingPeriod); } IInvokerPtr TIODispatcher::GetInvoker() |