Debounce scale-to-zero re-enable on DebouncedController#220
Draft
sjmiller609 wants to merge 1 commit intomainfrom
Draft
Debounce scale-to-zero re-enable on DebouncedController#220sjmiller609 wants to merge 1 commit intomainfrom
sjmiller609 wants to merge 1 commit intomainfrom
Conversation
The existing DebouncedController uses reference counting to coalesce concurrent Disable/Enable calls, but sequential requests each trigger a full Disable→Enable cycle on the control file. Add an optional cooldown duration: when the last active holder releases, the re-enable is delayed by the cooldown period. If a new Disable arrives before the timer fires, the pending re-enable is cancelled. This collapses rapid sequential requests into a single Disable/Enable pair. The cooldown is set to 1 second, which is long enough to collapse back-to-back request patterns while adding negligible delay to the VM's ability to enter standby. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds a configurable cooldown to the scale-to-zero
DebouncedController. When the last active request completes, the re-enable is delayed by the cooldown period instead of firing immediately. If a new request arrives during the cooldown window, the pending re-enable is cancelled and STZ stays disabled.This reduces the rate of control file toggling under rapid sequential request patterns while preserving correctness — STZ is always disabled when there's an active request, and always re-enabled after a quiet period.
The cooldown is set to 1 second. Zero cooldown preserves the original synchronous behavior.
Changes
NewDebouncedControllerWithCooldown(ctrl, cooldown)— new constructor with configurable cooldownDebouncedController.Enable— schedules a timer-based re-enable when cooldown > 0DebouncedController.Disable— cancels any pending re-enable timermain.go— uses 1s cooldownTest plan