← Back to Pull requests

Fix `bm_fastapi` benchmark failing with `httpx.PoolTimeout` under load #509

Closed
unknown closed this pull request without merging on Nov 24, 2026 17:21 UTC
View on GitHub
unknown unknown commented on Nov 09, 2026 07:12 UTC
Author

Fixes #508

Problem

The fastapi benchmark (bm_fastapi) intermittently fails with
httpx.PoolTimeout when the machine running the benchmark is under heavy load.

The benchmark fires CONCURRENCY = 150 concurrent requests, but the
httpx.AsyncClient uses httpx's default max_connections = 100. The 50 requests
that exceed the pool size wait in the pool's queue for a connection to free up.
httpx's default pool timeout is 5 seconds, so when the in-flight requests take
longer than 5 seconds (which is exactly what happens under load), those 50 queued
requests exceed the pool timeout and the benchmark dies:

httpx.PoolTimeout
RuntimeError: Benchmark died
ERROR: Benchmark fastapi failed: Benchmark died

Fix

Size the connection pool to the benchmark's concurrency so that no request ever
queues:

-        async with httpx.AsyncClient(trust_env=False) as client:
+        limits = httpx.Limits(max_connections=CONCURRENCY)
+        async with httpx.AsyncClient(limits=limits, trust_env=False) as client:

With the pool sized to CONCURRENCY, all 150 requests acquire a connection
immediately, so the pool timeout can never be hit regardless of server latency.

This builds on the trust_env=False change from #505 and keeps it

Testing

Reproduced deterministically by serving the endpoint with an artificial ~6s
per-request delay and firing 150 concurrent requests:

  • Before: default pool (100 connections) → httpx.PoolTimeout after ~5.1s

  • After: max_connections=150 → completes successfully (~7.1s)
  • No behavior change in the common case: the benchmark's concurrency is a fixed
    constant, so the pool is simply sized to match it.

    Diff: 210 lines (+157 / -53) across 2 files Reviewer: savannahostrowski Review duration: 22208m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 210 lines diff across 2 files
    0.36
    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.320
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #509"
    general weight: 0.35
    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: 36.5% (MEDIUM) · Higher = larger blast radius
    36.5%
    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: 14.4% · Safe to merge
    14.4%