java.lang.Object
net.i2p.router.Tuner.BaseParam
net.i2p.router.Tuner.RequestModerateLoadLagParam
All Implemented Interfaces:
Tuner.TunableParam
Enclosing class:
Tuner

private class Tuner.RequestModerateLoadLagParamextends Tuner.BaseParam
Tunes the moderate-load job lag threshold in RequestThrottler. Controls when low-share peers start being disconnected.

Independently tunes based on observed jobLag (not derived from RequestThrottler.getHighLoadLagMs()) to avoid lockstep oscillation with Tuner.RequestHighLoadLagParam. Uses a secondary signal (jobQueue.readyJobs) to break coupling when both params share the same primary lag signal.

Hysteresis dead-band: tighten when avg jobLag > 100ms OR readyJobs > 20; loosen when avg jobLag < 30ms AND readyJobs < 5. The asymmetric dead-band (30–100ms primary) plus the queue-depth cross-reference prevents correlated oscillation with the high-load param (which uses a 50–200ms dead-band on the same primary signal).

Ceiling invariant: always stays at least _step below RequestThrottler.getHighLoadLagMs() to maintain the ordering moderate < high.

  • Constructor Details

    • RequestModerateLoadLagParam

      RequestModerateLoadLagParam()
      Creates the parameter that sets the moderate-load job lag threshold in ms.
  • Method Details

    • applyValue

      protected void applyValue(int value)
      Description copied from class: Tuner.BaseParam
      Apply the tunable value to the router configuration.
      Specified by:
      applyValue in class Tuner.BaseParam
      Parameters:
      value - the tunable value to apply to router configuration
    • getRuntimeValue

      protected int getRuntimeValue()
      Description copied from class: Tuner.BaseParam
      Current runtime value read from the router configuration.
      Specified by:
      getRuntimeValue in class Tuner.BaseParam
      Returns:
      current runtime value read from router config
    • getObservedStat

      protected double getObservedStat(RouterContext ctx)
      Description copied from class: Tuner.BaseParam
      Observed stat value used for autotuning.

      ctx is always this param's own context: Tuner takes a single RouterContext, hands the same instance to every BaseParam constructor, and both call sites pass Tuner.BaseParam._ctx. It was previously passed as null, which silently broke any implementation that used the argument instead of the field — a param reading a cross-reference stat then threw on every tuning cycle, was caught by the cycle handler, and never tuned at all, with nothing but a repeated WARN to show for it. Implementations may use either ctx or Tuner.BaseParam._ctx; both are the same object.

      Specified by:
      getObservedStat in class Tuner.BaseParam
      Parameters:
      ctx - router context, never null
      Returns:
      observed stat value for autotuning
    • computeTarget

      protected int computeTarget(double observed)
      Target for the moderate-load lag threshold, decoupled from the high-load param.

      Uses independent thresholds on the primary signal (jobLag) and a secondary signal (readyJobs) to decouple from the high-load param. Tighten when lag > 100ms or queue depth > 20. Loosen only when both are low (lag < 30ms and readyJobs < 5).

      Specified by:
      computeTarget in class Tuner.BaseParam
      Parameters:
      observed - the 60s avg jobLag in ms
      Returns:
      the target moderate-load lag threshold (ms)