Add dead zone ratio to PID controller for noise suppression#1032
Merged
AbdulRahmanAlHamali merged 4 commits intopid-take-2from Feb 27, 2026
Merged
Add dead zone ratio to PID controller for noise suppression#1032AbdulRahmanAlHamali merged 4 commits intopid-take-2from
AbdulRahmanAlHamali merged 4 commits intopid-take-2from
Conversation
- Introduced `dead_zone_ratio` parameter in the PID controller to suppress noise from small deviations in error rates. - Updated the `calculate_p_value` method to implement dead zone logic, allowing for more stable control responses. - Enhanced tests to validate the behavior of the dead zone in various scenarios, ensuring it does not impede recovery while effectively filtering noise.
lib/semian/pid_controller.rb
Outdated
| delta_error = 0.0 | ||
| else | ||
| # Above dead zone: react to excess only | ||
| delta_error = raw_delta - dead_zone |
Contributor
There was a problem hiding this comment.
I think the delta_error here should be raw_delta - dead_zone. So that the dead zone does not actually affect calculations: it only silences them when we are within the dead zone, but otherwise everything stays the same
- Updated the handling of the dead zone in the PID controller to allow full signal response above the dead zone, improving control accuracy. - Adjusted comments for clarity regarding the purpose of the dead zone in noise suppression.
AbdulRahmanAlHamali
approved these changes
Feb 27, 2026
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.
closes https://github.com/Shopify/resiliency/issues/6664
Summary
ideal_error_rate * dead_zone_ratioof the ideal are treated as zero deviation, preventing unnecessary rejection rate increasesHow it works
The dead zone defines a band around the ideal error rate where the controller ignores noise:
0 < delta <= ideal * ratio): delta suppressed to 0delta > ideal * ratio): controller reacts to the excess (delta - dead_zone)Example: with
initial_error_rate: 0.05anddead_zone_ratio: 0.25, error rates up to 6.25% won't trigger rejection.Files changed
lib/semian/pid_controller.rb— dead zone logic incalculate_p_valuelib/semian/adaptive_circuit_breaker.rb— passesdead_zone_ratioto PID controllerlib/semian.rb— wiresdead_zone_ratio: 0.25default in factory methodtest/pid_controller_test.rb— tests for suppression, reaction above threshold, and unimpeded recovery