-
Notifications
You must be signed in to change notification settings - Fork 5.5k
fix: slow start config add min_weight_percent field to avoid too big edf deadline #19712
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
Changes from 11 commits
c9fa80c
7db579d
55fa090
fa05185
6bcae63
c978af2
f5f2e97
730edc0
a4d0305
929bd47
08201dd
430da3a
1c925bf
228879d
226e9cf
8a205ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -783,6 +783,19 @@ EdfLoadBalancerBase::EdfLoadBalancerBase( | |
| recalculateHostsInSlowStart(hosts_added); | ||
| } | ||
| }); | ||
|
|
||
| min_weight_percent_ = 0.1; | ||
| if (slow_start_config.has_value()) { | ||
| if (slow_start_config.value().min_weight_percent() > 0.0 && | ||
| slow_start_config.value().min_weight_percent() < 1.0) { | ||
| min_weight_percent_ = slow_start_config.value().min_weight_percent(); | ||
| } else { | ||
| ENVOY_LOG(warn, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that if PGV rejects the config (due to wrong value), this code will never be reached. |
||
| "Invalid value {} provided for min_weight_percent parameter, must be in range " | ||
| "(0.0, 1.0), so use default value 0.1", | ||
| slow_start_config.value().min_weight_percent()); | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once the field is of type Percent, you can initialize the Something similar to:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for advice. i have change to use |
||
| } | ||
|
|
||
| void EdfLoadBalancerBase::initialize() { | ||
|
|
@@ -967,7 +980,7 @@ double EdfLoadBalancerBase::applySlowStartFactor(double host_weight, const Host& | |
| auto time_factor = static_cast<double>(std::max(std::chrono::milliseconds(1).count(), | ||
| host_create_duration.count())) / | ||
| slow_start_window_.count(); | ||
| return host_weight * applyAggressionFactor(time_factor); | ||
| return host_weight * std::max(applyAggressionFactor(time_factor), min_weight_percent_); | ||
| } else { | ||
| return host_weight; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -459,6 +459,7 @@ class EdfLoadBalancerBase : public ZoneAwareLoadBalancerBase, | |
| const absl::optional<Runtime::Double> aggression_runtime_; | ||
| TimeSource& time_source_; | ||
| MonotonicTime latest_host_added_time_; | ||
| double min_weight_percent_; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's clear what this is for in the context of this PR, but in the load balancer file the name can be confusing. Can you change it to something that makes it clear this is specifically for the slow-start weight modifications? Something like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| }; | ||
|
|
||
| /** | ||
|
|
||
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.
The type should be changed to
Percent(see api style).Also note that this implies that the range should be (0, 100).
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.
Another option is to use a double wrapper (as the default value isn't 0), and then use
PROTOBUF_GET_WRAPPED_OR_DEFAULTto set the value in the c'tor.