- All Implemented Interfaces:
Tuner.TunableParam
- Enclosing class:
Tuner
i2p.streaming.maxConcurrentStreams (captured at init); this param pushes the override UP as legitimate demand or cap-refusals appear (so bursts on locally hosted services and the HTTP proxy are not dropped), and only steps it DOWN under true router starvation (job-lag + congestion). The effective cap in the streaming jar is min(configured, override), so the Tuner can never exceed a user ceiling. Malicious floods are handled at the refusal layer (SYN-rate gate + 24h auto-ban), not by crippling this cap.Field Summary
Fields inherited from class Tuner.BaseParam
_autotune, _autoTuning, _cpuDriven, _ctx, _defaultMax, _defaultMin, _defaultStep, _defaultValue, _description, _effMax, _factoryDefault, _firstTick, _health, _historyCount, _initialValue, _log, _max, _min, _name, _override, _propPrefix, _statHistory, _statName, _step, _subsystem, _valueHistory, sharedAutotuneModifier and TypeFieldDescriptionprotected final Tuner.AutotuneConfigAutotune profile for this tunable parameter.protected booleanWhether autotuning is active for this parameter.protected booleanWhether this param's value is being driven by CPU load rather than its own stat.protected final RouterContextRouter context.protected final intDefault maximum value from code or config.protected final intDefault minimum value from code or config.protected final intDefault step/increment size for adjustments.protected intFactory default: value before any tuning.protected final StringHuman-readable label for display in the Tuner UI.protected intEffective ceiling = min(_max, memory-derived bound); never exceeds _max.protected final intCode-level default captured at construction time.protected booleanTrue until firstTuner.BaseParam.update()call — applies persisted value from autotune.config.protected Tuner.SystemHealthHealth score and subsystem for autotune decisions.protected intNumber of valid entries in _valueHistory / _statHistory.protected final intLast known value (from persistence or runtime default).protected final LogClass logger.protected intCurrent maximum value (may differ from default after tuning).protected intCurrent minimum value (may differ from default after tuning).protected final StringInternal config property key (e.g.protected intUser-set override value, or Integer.MIN_VALUE if unset.protected final StringConfig key prefix for property lookups.protected final double[]Rolling window of recent stat values for trend analysis.protected final StringRouter stat name for observed value feedback.protected intCurrent step/increment size (may differ from default).protected final StringSubsystem identifier this parameter belongs to.protected final int[]Rolling window of recent tunable values for trend analysis.(package private) static Tuner.AutotuneConfigShared instance — set once in Tuner constructor, used by all BaseParams.Constructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptionprotected voidapplyValue(int value) Apply the tunable value to the streaming override.protected intcomputeTarget(double observed) Compute the elastic, demand-following stream ceiling.protected doubleObserved stat value used for autotuning.protected intRead the current effective override the Tuner believes is in force.Methods inherited from class Tuner.BaseParam
clamp, decisionReason, getAdditionalEventCount, getAdditionalEventCountHourly, getAdditionalStat, getAdditionalStat5Min, getAdditionalStatHourly, getAdditionalStatLong, getBuildSuccessRate, getCoDelDropEventCount, getCurrentValue, getDefaultMax, getDefaultMin, getDefaultStep, getDefaultValue, getDescription, getHeavyTransitThreshold, getMax, getMessageReceiverUtilization, getMin, getName, getObservedRTT, getPacketHandlerUtilization, getPumperUtilization, getReaderUtilization, getSendFinisherUtilization, getShareBps, getStatHistory, getStatPeriodStamp, getStep, getStreamingLossRate, getSubsystem, getSustainedHeavyTransitThreshold, getValueHistory, getWriterUtilization, isAutoTuning, persistValue, reclaimIfIdle, recordHistory, refreshDefault, refreshRanges, setHealth, setOverride, signalIsFresh, snapshot, updateModifier and TypeMethodDescriptionprotected static intclamp(int current, int target, int step) Move from current toward target, but at most one step per cycle.protected StringWhy the current target was chosen, for the change line.protected doublegetAdditionalEventCount(RouterContext ctx, String statName) Fetch the event count for an additional stat using the 60s period.protected doublegetAdditionalEventCountHourly(RouterContext ctx, String statName) Fetch the event count for an additional stat using the 1-hour period.protected doublegetAdditionalStat(RouterContext ctx, String statName) Fetch an additional stat value for cross-reference decisions.protected doublegetAdditionalStat5Min(RouterContext ctx, String statName) Fetch an additional stat value using the 5-minute average.protected doublegetAdditionalStatHourly(RouterContext ctx, String statName) Fetch an additional stat value using the 1-hour average.protected doublegetAdditionalStatLong(RouterContext ctx, String statName) Fetch an additional stat value using the 10-minute average.protected doubleCompute actual tunnel build success rate from event counts.protected doublegetCoDelDropEventCount(RouterContext ctx, String prefix) Fetch the total CoDel drop event count across all priority levels.intThe value in effect right now.protected intEffective default max — override for bandwidth-scaled params.protected intEffective default min — override for bandwidth-scaled params.protected intEffective default step — override for bandwidth-scaled params.intDefault value.Param description.protected static intTransit bandwidth threshold for "heavy" — 80% of configured share bandwidth.intgetMax()Maximum value.protected doubleUDP message receiver pool utilization (0.0-1.0).intgetMin()Minimum value.getName()Param name.protected doublegetObservedRTT(RouterContext ctx, String primaryStat) Fetch observed RTT, falling back toudp.sendConfirmTimewhen the primary stat has no events (lightly loaded router).protected doubleUDP packet handler pool utilization (0.0-1.0).protected doubleTunnel pumper pool utilization (0.0-1.0).protected doubleNTCP reader pool utilization (0.0-1.0).protected doubleNTCP send finisher pool utilization (0.0-1.0).protected static intgetShareBps(RouterContext ctx) Current share bandwidth in bytes per second.double[]Rolling window of recent stat values.protected doublegetStatPeriodStamp(RouterContext ctx, String statName) When the window behind a stat's event count last completed, in ms, or NaN when it cannot be determined.intgetStep()Step size.protected doubleRecent streaming retransmission rate for this tuning cycle.Subsystem name.protected static intTransit bandwidth threshold for "sustained heavy" — 50% of configured share.int[]Rolling window of recent tunable values.protected doubleNTCP writer pool utilization (0.0-1.0).booleanWhether auto-tuning is enabled.protected voidpersistValue(RouterContext ctx, int value) Persist a tuned value to autotune.config.protected static intreclaimIfIdle(double utilization, int current, int min, double idleThreshold) Reclaim parked threads from a thread pool that is massively under-utilized.protected voidrecordHistory(double observed) Record history.voidRe-read the default value from autotune.config for live updates.voidRe-read min/max/step from autotune.config — live update, no restart.(package private) voidsetHealth(Tuner.SystemHealth health) The current system health score for this update cycle.voidsetOverride(int value) A manual override value.(package private) static booleansignalIsFresh(double periodStamp, double lastStamp) Whether a signal reading is from a window that closed since the stored stamp.snapshot()Capture snapshot of current tunable state for display.voidupdate()Main tuning loop for this param.
Constructor Details
MaxStreamsParam
MaxStreamsParam()Creates the parameter that caps concurrent streams.
Method Details
applyValue
protected void applyValue(int value) Apply the tunable value to the streaming override.- Specified by:
applyValuein classTuner.BaseParam- Parameters:
value- the tunable value to apply to router configuration
getRuntimeValue
protected int getRuntimeValue()Read the current effective override the Tuner believes is in force.An override of 0 means the Tuner has never armed (the user's configured per-host maxConcurrent ceiling governs). The framework derives the persisted default from this value and force-applies it on the first tick, so reporting 0 here would clamp the default to
_min(16) and silently cripple a healthy tracker to 16 concurrent streams. Instead we report the top of the working range (ConnectionOptions#getMaxMaxConcurrentStreams()): first tick then sees initial == runtime == ceiling and the Tuner stays unarmed until real saturation produces a target below the ceiling.- Specified by:
getRuntimeValuein classTuner.BaseParam- Returns:
- the effective cap to autotune against (0 stored override maps to ceiling)
getObservedStat
Description copied from class:Tuner.BaseParamObserved stat value used for autotuning.ctxis always this param's own context:Tunertakes a singleRouterContext, hands the same instance to everyBaseParamconstructor, and both call sites passTuner.BaseParam._ctx. It was previously passed asnull, 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 eitherctxorTuner.BaseParam._ctx; both are the same object.- Specified by:
getObservedStatin classTuner.BaseParam- Parameters:
ctx- router context, never null- Returns:
- observed stat value for autotuning
computeTarget
protected int computeTarget(double observed) Compute the elastic, demand-following stream ceiling.The cap is a headroom knob, not a DoS throttle: abuse is already shed at the refusal layer by the SYN-rate gate and the 24h auto-ban, so the ceiling's job is to keep legitimate streams flowing on locally hosted services and the HTTP proxy while the router stays responsive. Refusals and rising demand therefore push the ceiling UP toward the user's configured
maxConcurrentceiling (the streaming layermin(user, override)never lets us exceed it); only genuine latency/distress pulls it DOWN, and only one step at a time.Signals consumed (all registered live streaming / system stats):
stream.con.throttledHour/stream.con.throttledMinute— streams turned away by the "Dropped for conn limit" guard in the last window (event counts); firing = raise so bursts stop being refused.stream.receiveActive— active-stream demand; the working cap is kept a few steps above it so bursts are absorbed rather than refused.jobQueue.jobLag(ms) — CPU/system starvation; super-high lag is the only trigger for lowering the ceiling.stream.rtxRatioBytes— retransmit overhead (per-mille bytes); raised with jobLag it confirms network/congestion distress.stream.connectFailed— ms spent failing outbound connects; an early-to-middle latency signal that suppresses aggressive raises.
- Specified by:
computeTargetin classTuner.BaseParam- Parameters:
observed- thestream.receiveActivestat (active streams)- Returns:
- the target ceiling for the streaming override