167
// changed.
168
// Called from backgroundWork only.
170
>
// don't bother calling during cooldown period
171
>
if !sm.nextDecision.IsZero() && sm.timeSource.Now().Before(sm.nextDecision) {
172
return
173
}
174
176
>
shadowMode := settings.ShadowModeLogInterval > 0
177
>
178
>
// Entering shadow mode on top of a previously-applied managed target releases
179
>
// control back to the dynamic-config baseline: zero the managed target once so
180
>
// the write side follows dynamic config again (and tracks future config
181
>
// changes), and cold-start the shadow simulation from the baseline. BacklogState
182
>
// is preserved, so read partitions are not dropped here (reclaiming them is left
183
>
// to the drain path). This is the only state shadow mode writes; it still never
184
>
// applies the scaler's hypothetical decisions.
185
>
if shadowMode && sm.scaleState.GetTarget() != 0 {
186
sm.releaseManagedState(settings)
187
}
188
189
// grab current batch (may be zero)
191
>
192
>
decision := sm.partitionScaler.OnTasks(PartitionScalerInput{
193
>
NumTasks: tasks,
194
>
CurrentTarget: int(sm.scaleState.GetTarget()),
195
>
BacklogCounts: sm.scaleState.GetBacklogCounts(),
196
>
PrivateState: sm.scaleState.GetPrivateScalerState(),
197
>
})
198
>
backlogCapC8 := number.EncodeCompact8(int64(decision.BacklogCap))
199
>
if decision.NoChange ||
200
>
decision.NewTarget == int(sm.scaleState.GetTarget()) &&
201
>
backlogCapC8 == number.Compact8(sm.scaleState.GetBacklogCap()) {
202
return
203
}