Regulator

kyo.scheduler.regulator.Regulator
abstract class Regulator(loadAvg: DoubleSupplier, timer: InternalTimer, config: Config)

A self-tuning regulator that dynamically adjusts scheduler behavior based on system performance metrics. This base class provides automatic adjustment of scheduler parameters based on real-time performance measurements and statistical analysis of timing variations.

==Measurement Collection==

The regulator collects timing measurements through periodic probes at configured intervals. These measurements are stored in a moving window, which provides an efficient way to maintain recent performance history while automatically discarding old data. This approach enables quick detection of emerging performance trends while smoothing out momentary irregularities.

==Jitter Analysis==

Collected measurements are analyzed using a moving standard deviation calculation to determine system stability. This "jitter" metric reveals performance characteristics such as sudden instability, ongoing systemic issues, and recovery patterns. The analysis focuses on detecting significant deviations that indicate potential performance problems.

==Adjustment Mechanism==

Based on the jitter analysis, the regulator makes incremental adjustments to maintain system stability. When jitter exceeds the upper threshold, the regulator adjusts using negative steps. Conversely, when jitter falls below the lower threshold and load meets the target, it adjusts with positive steps. Step sizes increase exponentially with consecutive adjustments in the same direction but reset when the direction changes, providing both responsiveness and stability.

==Configuration==

The regulator's behavior is controlled through configuration parameters that define the measurement window size, collection and regulation intervals, jitter thresholds, target load, and step escalation rate. These parameters can be tuned to match specific system characteristics and performance requirements.

Value parameters

config

Configuration parameters for the regulator

loadAvg

A supplier that provides the current system load average (0.0 to 1.0)

timer

Timer used for scheduling periodic measurements and adjustments

Attributes

See also

Config for configuration parameters

MovingStdDev for jitter calculation details

Admission for admission control implementation

Concurrency for concurrency control implementation

Note

Implementations must provide probe() and update() methods to define measurement collection and adjustment application respectively.

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Admission
class Concurrency

Members list

Value members

Abstract methods

protected def probe(): Unit

Collect a performance measurement.

Collect a performance measurement.

This method should implement the specific probing mechanism for the regulator. Implementations must call measure() with the collected measurement value.

Attributes

protected def update(diff: Int): Unit

Apply a regulation adjustment.

Apply a regulation adjustment.

Value parameters

diff

The size and direction of adjustment to apply Positive values indicate increase Negative values indicate decrease Magnitude increases with consecutive adjustments

Attributes

Concrete methods

protected def measure(v: Long): Unit

Record a measurement value for regulation.

Record a measurement value for regulation.

Value parameters

v

The measurement value in nanoseconds Measurements are used to:

  • Calculate jitter (standard deviation)
  • Detect performance anomalies
  • Guide adjustment decisions

Attributes

protected def regulatorStatus(): RegulatorStatus
def stop(): Unit

Stop the regulator.

Stop the regulator.

Cancels all scheduled tasks and cleans up resources.

Attributes

Concrete fields

protected val statsScope: Scope