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

private class Tuner.MaxWindowSizeParamextends Tuner.BaseParam
Tunes the streaming maximum congestion window, scaled to available memory.
  • Field Details

    • _lastLossStamp

      private double _lastLossStamp
      Close time of the loss window this decision was last taken on.
    • _riseShrink

      private int _riseShrink
      Consecutive windows in the shrink direction.
    • _riseClimb

      private int _riseClimb
      Consecutive windows in the climb direction.
  • Constructor Details

    • MaxWindowSizeParam

      MaxWindowSizeParam()
      Creates the parameter that tunes the streaming max window size.
  • 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)
      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
    • decisionReason

      protected String decisionReason()
      Name the gate that decided the ceiling's direction.

      Reads the same three signals computeTarget(double) decides from. Asked only on a cycle that moves the value, so the extra reads cost nothing.

      Overrides:
      decisionReason in class Tuner.BaseParam
      Returns:
      the reason, or null when the param has nothing to report
    • averageDuplicateMessageSize

      private double averageDuplicateMessageSize()
      Mean size in bytes of a retransmitted message, or NaN when unread.

      The discriminator the two loss ratios cannot supply. The event-count ratio counts every resend alike and the byte ratio weights by bytes, so their divergence says the two disagree but not whether the resends are small control-plane messages that a byte-in-flight window can ignore or real payload that it cannot. This is the size of an average resend.

      Both inputs are recorded at the same stream-close event over the same 5-minute window, so the two window means divide into the size. The byte figure cannot be recovered from stream.rtxRatioBytes: that stat records 1000*dupBytes/bytesSent per close, so its mean is a mean of per-stream ratios and dividing it into anything to get a size is invalid.

      Bounded by the streams that closed inside the window, so it is a closure-biased lifetime figure rather than a true traffic-rate one: one long stream closing in the window contributes its whole lifetime.

      Returns:
      bytes per retransmitted message, or NaN when either input is absent
    • trueByteWeightedLossRate

      private double trueByteWeightedLossRate()
      The true byte-weighted retransmission rate: total bytes resent divided by total bytes sent over the window.

      Unlike stream.rtxRatioBytes this is not a mean of per-connection ratios. That stat records 1000*dupBytes/bytesSent once per closed connection, so its window mean is a mean of ratios: a three-message connection that resent everything counts the same as a three-thousand-message connection that resent one record, and on this router it reads 3.47 % while the byte-weighted figure reads 39-58 %. This method divides the window's total resent bytes by its total sent bytes, so a connection that carried most of the bytes in the window carries most of the weight — the quantity a byte-in-flight ceiling actually needs.

      Both inputs are recorded at the same stream-close event over the same 5-minute window, so the two window means divide into a rate.

      Bounded by the streams that closed inside the window, so it is a closure-biased lifetime figure rather than a true traffic-rate one: one long stream closing in the window contributes its whole lifetime.

      Returns:
      the byte-weighted rate 0.0-1.0, or NaN when either input is absent