Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve host's leader number bounds when doing leader balance #5670

Merged
merged 3 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ core.*
workspace.*
.metals/
.cproject
.ycm_extra_conf.py

#py
*.egg-info
Expand Down
25 changes: 22 additions & 3 deletions src/meta/processors/job/LeaderBalanceJobExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,28 @@ ErrorOr<nebula::cpp2::ErrorCode, bool> LeaderBalanceJobExecutor::buildLeaderBala

if (dependentOnZone) {
for (auto it = allHostParts.begin(); it != allHostParts.end(); it++) {
auto min = it->second.size() / replicaFactor;
LOG(INFO) << "Host: " << it->first << " Bounds: " << min << " : " << min + 1;
hostBounds_[it->first] = std::make_pair(min, min + 1);
size_t localParts = it->second.size();
size_t localAvg = localParts / replicaFactor;
size_t localMin = localAvg;
size_t localMax = localAvg;
if (localParts % replicaFactor != 0) {
localMax += 1;
}

if (useDeviation) {
size_t localMinTmp = std::ceil(static_cast<double>(localParts) / replicaFactor *
(1 - FLAGS_leader_balance_deviation));
size_t localMaxTmp = std::floor(static_cast<double>(localParts) / replicaFactor *
(1 + FLAGS_leader_balance_deviation));
if (localMinTmp <= localMaxTmp) {
localMin = localMinTmp;
localMax = localMaxTmp;
}
}
LOG(INFO) << "Host:" << it->first << "'s leader balance plan, expected min load: " << localMin
<< ", max load: " << localMax << " avg: " << localAvg;

hostBounds_[it->first] = std::make_pair(localMin, localMax);
}
} else {
size_t activeSize = activeHosts.size();
Expand Down