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

private class Tuner.MaxProfilesParamextends Tuner.BaseParam
Max peer profiles in memory.
  • Constructor Details

    • MaxProfilesParam

      MaxProfilesParam()
      Creates the parameter that caps the peer profiles kept in RAM.
  • 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)
      Compute the target value from memory headroom.

      This parameter bounds a memory store, so memory is the only input it needs. It previously took peer.fastPeerCount and an hourly profile-count trend instead, which made it a memory cap governed by peer quality: raising it required more than 30% of the current cap to be fast peers, so a router holding 1594 profiles and 375 fast peers could never raise its own cap. ProfileOrganizer.enforceProfileCap() then pinned the store one profile above the cap and evicted continuously to stay there, shedding roughly 80 profiles a minute against a network database of more than 5000 peers. The cap could not respond to the churn because the churn was the reason the gate never opened.

      Peer count is retained only as a tiebreak on how much headroom to grant, so a growing profile store is not penalised while memory is free and a shrinking one is not expanded while memory is tight.

      Specified by:
      computeTarget in class Tuner.BaseParam
      Parameters:
      observed - current value of the bound stat, peer.activeProfileCount
      Returns:
      the target profile count