← Back to Pull requests

πŸ› [fix]: reduce stack use for batched UDP sends #9

Closed
unknown closed this pull request without merging on Nov 21, 2026 02:11 UTC
View on GitHub
unknown unknown commented on Nov 20, 2026 10:25 UTC
Author

Why

Both UDP send paths reserve a 263-byte SOCKS5 header on the stack for each datagram. They use only the first three bytes because the destination address already has its own iovec. A batch of 64 datagrams therefore uses over 16 KiB of stack space for address storage it never reads.

Changes

  • Keep a three-byte length prefix per datagram for UDP-in-TCP. For UDP ASSOCIATE, all datagrams in the batch share one zero prefix.

  • Reuse the caller's mmsghdr array for UDP segmentation offload (GSO). If the send falls back, rebuild the entries for individual datagrams.
  • Verification and limits

    Tested five loopback scenarios on Linux arm64 with an independent SOCKS5 peer. The peer checked addresses, ports, payloads and order for both transports. A syscall trace confirmed that the batch tests exercised both UDP_SEGMENT and plain sendmmsg.

    The changed file also compiled with warnings treated as errors on macOS arm64 and for all four Android ABIs. Windows was reviewed by inspection only.

    Related

    Downstream core PR #7 carries the corresponding change in our fork.

    <details><summary>ΠžΠ±ΡŠΡ‘ΠΌ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠΉ: +21 βˆ’21 Π² 1 Ρ„Π°ΠΉΠ»Π΅</summary>

    | ΠšΠ°Ρ‚Π΅Π³ΠΎΡ€ΠΈΡ | Π€Π°ΠΉΠ»ΠΎΠ² | + | βˆ’ |
    |---|---:|---:|---:|
    | ΠŸΡ€ΠΎΠ΄-ΠΊΠΎΠ΄ | 1 | 21 | 21 |
    | Π˜Ρ‚ΠΎΠ³ΠΎ | 1 | 21 | 21 |

    </details>

    Diff: 168 lines (+126 / -42) across 2 files Reviewer: heiher Review duration: 946m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.35) Γ— (1 βˆ’ Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 Β· Change Risk (XGBoost)
    Score: 0.35 Β· 168 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%
    60%
    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.307
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #9"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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.1% (MEDIUM) Β· Higher = larger blast radius
    35.1%
    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: 60.5% Β· Lower = rushed or shallow review
    60.5%
    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: 13.9% Β· Safe to merge
    13.9%