Skip to content

Comments

Add dead zone ratio to PID controller for noise suppression#1032

Open
Abuudiii wants to merge 2 commits intopid-take-2from
abdullah/rejection-mechanism-fix
Open

Add dead zone ratio to PID controller for noise suppression#1032
Abuudiii wants to merge 2 commits intopid-take-2from
abdullah/rejection-mechanism-fix

Conversation

@Abuudiii
Copy link
Contributor

@Abuudiii Abuudiii commented Feb 20, 2026

closes https://github.com/Shopify/resiliency/issues/6664

Summary

  • Adds a configurable dead zone to the PID controller that suppresses reactions to small, noisy error rate fluctuations around the ideal error rate
  • Error rates within ideal_error_rate * dead_zone_ratio of the ideal are treated as zero deviation, preventing unnecessary rejection rate increases
  • Negative deltas (recovery) pass through the dead zone unimpeded, so the dead zone never slows down recovery

How it works

The dead zone defines a band around the ideal error rate where the controller ignores noise:

  • Below ideal: negative delta passes through for fast recovery
  • Within dead zone (0 < delta <= ideal * ratio): delta suppressed to 0
  • Above dead zone (delta > ideal * ratio): controller reacts to the excess (delta - dead_zone)

Example: with initial_error_rate: 0.05 and dead_zone_ratio: 0.25, error rates up to 6.25% won't trigger rejection.

Files changed

  • lib/semian/pid_controller.rb — dead zone logic in calculate_p_value
  • lib/semian/adaptive_circuit_breaker.rb — passes dead_zone_ratio to PID controller
  • lib/semian.rb — wires dead_zone_ratio: 0.25 default in factory method
  • test/pid_controller_test.rb — tests for suppression, reaction above threshold, and unimpeded recovery

- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant