0.3.0
Multi-worker sync performance — matching uvicorn at 30k req/s, pure Python
Highlights
- Fast HTTP/1.1 parser — Custom
_fast_h1.pyreplaces h11 on the sync worker hot path. Direct bytes parsing (~3 µs/req vs ~22 µs for h11) with full safety: method validation, header size limits, null byte/control character injection rejection, duplicate Content-Length detection, and request smuggling prevention (RFC 7230 §3.3.3). - 30k req/s on pure Python — Sync worker throughput now matches uvicorn through fused parsing, shared request pipeline, and single-pass header scanning.
- Shared request pipeline —
prepare_request(),negotiate_compressor(),log_request(), andis_trusted_peer()are shared between Worker and SyncWorker for feature parity and code deduplication.
Added
_fast_h1.py— Fast HTTP/1.1 parser for sync workers_headers.py— Sharedget_header()consolidates 7 duplicate copies across modules_request_pipeline.py— Shared request pipeline for Worker and SyncWorker- TCP_NODELAY set on accepted connections in
accept_distributor.py
Changed
- Middleware classification cached —
MiddlewareStack.__init__classifies middleware once viainspect.signatureinstead of per-request ConnectionClosed→ConnectionCompleted— Lifecycle event renamed for claritytrusted_hoststype — Changed fromtuple[str, ...]tofrozenset[str]for O(1) lookup with pre-computed wildcard flag- Single-pass header scanning — Response send path detects Content-Length and Transfer-Encoding in one pass
- OpenTelemetry optimizations — Pre-instantiated propagator, filtered to trace headers only
- Static file header extraction — Single pass over request headers
- Shared socket for thread workers —
create_listeners(shared=True)avoids macOS SO_REUSEPORT distribution issues - Server and supervisor simplified — Streamlined lifecycle state machine and worker spawning
Install
uv add "bengal-pounce==0.3.0"