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

Disable fused multiply-subtract optimizations on activator calculations #8341

Merged
merged 1 commit into from Jun 16, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions pkg/autoscaler/scaling/autoscaler.go
Expand Up @@ -254,9 +254,10 @@ func (a *Autoscaler) Scale(ctx context.Context, now time.Time) ScaleResult {
excessBCF = 0
// numAct stays 1, only needed to scale from 0.
case a.deciderSpec.TargetBurstCapacity > 0:
totCap := float64(originalReadyPodsCount) * a.deciderSpec.TotalValue
excessBCF = math.Floor(totCap - observedPanicValue -
a.deciderSpec.TargetBurstCapacity)
// Extra float64 cast disables fused multiply-subtract to force identical behavior on
// all platforms. See floating point section in https://golang.org/ref/spec#Operators.
totCap := float64(float64(originalReadyPodsCount) * a.deciderSpec.TotalValue)
excessBCF = math.Floor(totCap - a.deciderSpec.TargetBurstCapacity - observedPanicValue)
numAct = int32(math.Max(MinActivators,
math.Ceil((totCap+a.deciderSpec.TargetBurstCapacity)/a.deciderSpec.ActivatorCapacity)))
case a.deciderSpec.TargetBurstCapacity == -1:
Expand Down
4 changes: 3 additions & 1 deletion pkg/autoscaler/scaling/autoscaler_test.go
Expand Up @@ -70,7 +70,9 @@ func TestAutoscalerNoDataNoAutoscale(t *testing.T) {
}

func expectedEBC(totCap, targetBC, recordedConcurrency, numPods float64) int32 {
return int32(math.Floor(totCap/targetUtilization*numPods - targetBC - recordedConcurrency))
// Extra float64 cast disables fused multiply-subtract to force identical behavior on
// all platforms. See floating point section in https://golang.org/ref/spec#Operators.
return int32(math.Floor(float64(totCap/targetUtilization*numPods) - targetBC - recordedConcurrency))
}

func expectedNA(a *Autoscaler, numP float64) int32 {
Expand Down