← Back to Pull requests

fix(lp2p): derive System.Conns from max_peers in custom limits mode #6074

Closed
unknown closed this pull request without merging on Sep 22, 2026 09:51 UTC
View on GitHub
unknown unknown commented on Sep 19, 2026 23:17 UTC
Author

Problem

In ResourceManagerFromConfig, custom mode:

// 2.1 limit max system connections to (max conns per peer * max peers)
limits.System.Conns = partialDefaults.PeerDefault.Conns * maxPeerStreams

The comment says max peers, the code multiplies by max_peer_streams. max_peers is not used at all for this limit, so the system connection cap scales with a setting that has nothing to do with connections. Concretely, with max_peers = 10: max_peer_streams = 5 → 40 conns, max_peer_streams = 500 → 4000 conns.

This was part of #5957, which went stale; in that thread @swift1337 suggested max_peers × small constant (2–4) as the right shape, since peers normally share one multiplexed QUIC connection. Credit to @JayT106 for the original report.

Change

  • limits.System.Conns = max_peers 4 (constant systemConnsPerPeer; 4 = one active connection plus headroom for a reconnect while the old one drains)

  • nothing else from #5957 is included — only this line

  • TestResourceManager/custom now asserts the system conn limit equals max_peers 4 and does not move when max_peer_streams is multiplied by 10 (on main: expected 40, actual 400)
  • max_peers is already required to be > 0 in custom mode by LibP2PLimits.ValidateBasic, so the limit can't collapse to zero.

    Checklist

  • tests

  • changelog

  • docs (n/a)
  • Diff: 171 lines (+128 / -43) across 2 files Reviewer: swift1337 Review duration: 3514m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.35) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.35 · 171 lines diff across 2 files
    0.35
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.308
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #6074"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 35.2% (MEDIUM) · Higher = larger blast radius
    35.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.2% · Safe to merge
    15.2%