-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
LoadBalancer: Skip EdfScheduler creation in LoadBalancerBase if all host weights are equal. #7877
Merged
mattklein123
merged 14 commits into
envoyproxy:master
from
antoniovicente:no_edf_if_weights_equal
Aug 15, 2019
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7b1d1a6
Only create EdfScheduler for round-robing and least-request load bala…
antoniovicente f963f5d
Add note about use of p2c for host selection in least-requests load b…
antoniovicente 6fb643a
Merge remote-tracking branch 'upstream/master' into no_edf_if_weights…
antoniovicente 14d7aed
Fix typo in version_history.rst
antoniovicente 59350fc
Kick CI
antoniovicente 18b45fe
Kick CI
antoniovicente a19621f
Kick CI
antoniovicente 7ee1471
Kick CI
antoniovicente f026ad5
Adjust stats_integration_test assertions now that EDFScheduler is opt…
antoniovicente be4e05d
Merge branch 'master' into no_edf_if_weights_equal
antoniovicente eae4a6f
Address review comments and fix memory assertion in stats_integration…
antoniovicente 01139e1
Merge remote-tracking branch 'upstream/master' into no_edf_if_weights…
antoniovicente a5af45f
Merge branch 'no_edf_if_weights_equal' of github.com:antoniovicente/e…
antoniovicente 90a615f
Limit load_balancer_benchmark changes to basic round-robin LB benchmark.
antoniovicente File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to use
absl::optional
here instead? It seems to be a slightly better fit semanticallyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can, but I want to get your opinion about something first:
When using std::unique_ptr, memory usage reported by stats_integration_test.cc is 42838 bytes. With absl::optional, memory usage goes up to 43126.
Relevant diffs:
diff --git a/source/common/upstream/load_balancer_impl.cc b/source/common/upstream/load_balancer_impl.cc
index 79bf87b79..a1dcd8167 100644
--- a/source/common/upstream/load_balancer_impl.cc
+++ b/source/common/upstream/load_balancer_impl.cc
@@ -651,7 +651,7 @@ void EdfLoadBalancerBase::refresh(uint32_t priority) {
return;
}
// Populate scheduler with host list.
// TODO(mattklein123): We must build the EDF schedule even if all of the hosts are currently
@@ -710,7 +710,7 @@ HostConstSharedPtr EdfLoadBalancerBase::chooseHostOnce(LoadBalancerContext* cont
// BaseDynamicClusterImpl::updateDynamicHostList, we must do a runtime pivot here to determine
// whether to use EDF or do unweighted (fast) selection. EDF is non-null iff the original weights
// of 2 or more hosts differ.
auto host = scheduler.edf_->pick();
if (host != nullptr) {
scheduler.edf_->add(hostWeight(*host), host);
diff --git a/source/common/upstream/load_balancer_impl.h b/source/common/upstream/load_balancer_impl.h
index 98fd0c75d..5dfd91888 100644
--- a/source/common/upstream/load_balancer_impl.h
+++ b/source/common/upstream/load_balancer_impl.h
@@ -349,7 +349,7 @@ protected:
// EdfScheduler for weighted LB. The edf_ is only created when the original
// host weights of 2 or more hosts differ. When not present, the
// implementation of chooseHostOnce falls back to unweightedHostPick.
};
void initialize();
diff --git a/test/integration/stats_integration_test.cc b/test/integration/stats_integration_test.cc
index ceadf07ba..e8f958373 100644
--- a/test/integration/stats_integration_test.cc
+++ b/test/integration/stats_integration_test.cc
@@ -212,7 +212,7 @@ TEST_P(ClusterMemoryTestRunner, MemoryLargeClusterSizeWithStats) {
// 2019/07/06 7477 42742 43000 fork gauge representation to drop pending_increment_
// 2019/07/15 7555 42806 43000 static link libstdc++ in tests
// 2019/07/24 7503 43030 44000 add upstream filters to clusters
// Note: when adjusting this value: EXPECT_MEMORY_EQ is active only in CI
// 'release' builds, where we control the platform and tool-chain. So you
@@ -222,7 +222,7 @@ TEST_P(ClusterMemoryTestRunner, MemoryLargeClusterSizeWithStats) {
// On a local clang8/libstdc++/linux flow, the memory usage was observed in
// June 2019 to be 64 bytes higher than it is in CI/release. Your mileage may
// vary.
EXPECT_MEMORY_LE(m_per_cluster, 44000);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the memory savings makes using a unique_ptr here makes more sense