From 6e5dd027b16c766aec084bf96e35eb7238164740 Mon Sep 17 00:00:00 2001 From: linrunqi08 Date: Wed, 25 Dec 2024 05:06:48 +0000 Subject: [PATCH] fix comments --- core/app_config/AppConfig.cpp | 12 ++++++------ core/app_config/AppConfig.h | 7 +++++++ core/pipeline/limiter/ConcurrencyLimiter.cpp | 2 -- core/plugin/flusher/sls/FlusherSLS.cpp | 4 ++-- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/core/app_config/AppConfig.cpp b/core/app_config/AppConfig.cpp index 833b48ed09..5ea46c076d 100644 --- a/core/app_config/AppConfig.cpp +++ b/core/app_config/AppConfig.cpp @@ -1192,14 +1192,14 @@ void AppConfig::LoadResourceConf(const Json::Value& confJson) { LOG_INFO(sLogger, ("bind_interface", mBindInterface)); } - // mSendRequestConcurrency was limited in [15, 80] - if (mSendRequestConcurrency < 15) { - mSendRequestConcurrency = 15; + // mSendRequestConcurrency was limited + if (mSendRequestConcurrency < mMinSendRequestConcurrency) { + mSendRequestConcurrency = mMinSendRequestConcurrency; } - if (mSendRequestConcurrency > 80) { - mSendRequestConcurrency = 80; + if (mSendRequestConcurrency > mMaxSendRequestConcurrency) { + mSendRequestConcurrency = mMaxSendRequestConcurrency; } - mSendRequestGlobalConcurrency = mSendRequestConcurrency * 1.5; + mSendRequestGlobalConcurrency = mSendRequestConcurrency * (1 + mGlobalConcurrencyFreePercentageForOneRegion); } bool AppConfig::CheckAndResetProxyEnv() { diff --git a/core/app_config/AppConfig.h b/core/app_config/AppConfig.h index 73e201b3cf..18bf7ea11c 100644 --- a/core/app_config/AppConfig.h +++ b/core/app_config/AppConfig.h @@ -209,6 +209,11 @@ class AppConfig { std::string mBindInterface; + // 全局并发度对单地域占比保留的余量 + const double mGlobalConcurrencyFreePercentageForOneRegion = 0.5; + const int32_t mMinSendRequestConcurrency = 15; + const int32_t mMaxSendRequestConcurrency = 80; + // /** // * @brief Load ConfigServer, DataServer and network interface // * @@ -441,6 +446,8 @@ class AppConfig { // 全局并发度 int32_t GetSendRequestGlobalConcurrency() const { return mSendRequestGlobalConcurrency; } + double GetGlobalConcurrencyFreePercentageForOneRegion() const { return mGlobalConcurrencyFreePercentageForOneRegion; } + int32_t GetProcessThreadCount() const { return mProcessThreadCount; } // const std::string& GetMappingConfigPath() const { return mMappingConfigPath; } diff --git a/core/pipeline/limiter/ConcurrencyLimiter.cpp b/core/pipeline/limiter/ConcurrencyLimiter.cpp index 49be4ca7c1..3adb5c124f 100644 --- a/core/pipeline/limiter/ConcurrencyLimiter.cpp +++ b/core/pipeline/limiter/ConcurrencyLimiter.cpp @@ -69,8 +69,6 @@ void ConcurrencyLimiter::OnFail(std::chrono::system_clock::time_point currentTim AdjustConcurrency(false, currentTime); } - - void ConcurrencyLimiter::Increase() { lock_guard lock(mLimiterMux); if (mCurrenctConcurrency != mMaxConcurrency) { diff --git a/core/plugin/flusher/sls/FlusherSLS.cpp b/core/plugin/flusher/sls/FlusherSLS.cpp index ea4551ad1b..965e7f1772 100644 --- a/core/plugin/flusher/sls/FlusherSLS.cpp +++ b/core/plugin/flusher/sls/FlusherSLS.cpp @@ -155,12 +155,12 @@ shared_ptr FlusherSLS::GetRegionConcurrencyLimiter(const str lock_guard lock(sMux); auto iter = sRegionConcurrencyLimiterMap.find(region); if (iter == sRegionConcurrencyLimiterMap.end()) { - auto limiter = make_shared(sName + "#network#region#" + region, AppConfig::GetInstance()->GetSendRequestConcurrency(), AppConfig::GetInstance()->GetSendRequestConcurrency()*0.5); + auto limiter = make_shared(sName + "#network#region#" + region, AppConfig::GetInstance()->GetSendRequestConcurrency(), AppConfig::GetInstance()->GetSendRequestConcurrency()*AppConfig::GetInstance()->GetGlobalConcurrencyFreePercentageForOneRegion()); sRegionConcurrencyLimiterMap.try_emplace(region, limiter); return limiter; } if (iter->second.expired()) { - auto limiter = make_shared(sName + "#network#region#" + region, AppConfig::GetInstance()->GetSendRequestConcurrency(), AppConfig::GetInstance()->GetSendRequestConcurrency()*0.5); + auto limiter = make_shared(sName + "#network#region#" + region, AppConfig::GetInstance()->GetSendRequestConcurrency(), AppConfig::GetInstance()->GetSendRequestConcurrency()*AppConfig::GetInstance()->GetGlobalConcurrencyFreePercentageForOneRegion()); iter->second = limiter; return limiter; }