Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
linrunqi08 committed Dec 25, 2024
1 parent ef58d8e commit 6e5dd02
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
12 changes: 6 additions & 6 deletions core/app_config/AppConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
7 changes: 7 additions & 0 deletions core/app_config/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
// *
Expand Down Expand Up @@ -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; }
Expand Down
2 changes: 0 additions & 2 deletions core/pipeline/limiter/ConcurrencyLimiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ void ConcurrencyLimiter::OnFail(std::chrono::system_clock::time_point currentTim
AdjustConcurrency(false, currentTime);
}



void ConcurrencyLimiter::Increase() {
lock_guard<mutex> lock(mLimiterMux);
if (mCurrenctConcurrency != mMaxConcurrency) {
Expand Down
4 changes: 2 additions & 2 deletions core/plugin/flusher/sls/FlusherSLS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ shared_ptr<ConcurrencyLimiter> FlusherSLS::GetRegionConcurrencyLimiter(const str
lock_guard<mutex> lock(sMux);
auto iter = sRegionConcurrencyLimiterMap.find(region);
if (iter == sRegionConcurrencyLimiterMap.end()) {
auto limiter = make_shared<ConcurrencyLimiter>(sName + "#network#region#" + region, AppConfig::GetInstance()->GetSendRequestConcurrency(), AppConfig::GetInstance()->GetSendRequestConcurrency()*0.5);
auto limiter = make_shared<ConcurrencyLimiter>(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<ConcurrencyLimiter>(sName + "#network#region#" + region, AppConfig::GetInstance()->GetSendRequestConcurrency(), AppConfig::GetInstance()->GetSendRequestConcurrency()*0.5);
auto limiter = make_shared<ConcurrencyLimiter>(sName + "#network#region#" + region, AppConfig::GetInstance()->GetSendRequestConcurrency(), AppConfig::GetInstance()->GetSendRequestConcurrency()*AppConfig::GetInstance()->GetGlobalConcurrencyFreePercentageForOneRegion());
iter->second = limiter;
return limiter;
}
Expand Down

0 comments on commit 6e5dd02

Please sign in to comment.