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

private class Tuner.HandlerThreadPriorityParamextends Tuner.BaseParam
Tunes I/O handler thread priority based on dispatch latency and queue backlogs. Higher priority under load helps handler threads抢占 CPU from idle work. Lower priority when idle lets other work run.

Primary signal: transport.sendProcessingTime. Cross-refs: ntcp.readQueueSize, ntcp.sendFinisher.queueSize, jobQueue.jobLag.

  • Constructor Details

    • HandlerThreadPriorityParam

      HandlerThreadPriorityParam()
      Creates the parameter that tunes the I/O thread priority.
  • 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()
      Read the live static, not the config property. applyValue writes the static and Tuner.getHandlerThreadPriority() is what the I/O threads read, so reading the property here reported a value that never moved even after a successful apply, and the param looked stuck while it was tuning fine.
      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)
      Description copied from class: Tuner.BaseParam
      Target tunable value computed from the observed stat.
      Specified by:
      computeTarget in class Tuner.BaseParam
      Parameters:
      observed - current stat value
      Returns:
      target tunable value