Skip to content

bengal-pounce 0.3.0

Choose a tag to compare

@lbliii lbliii released this 17 Mar 18:36
· 95 commits to main since this release
1fa22ef

Highlights

  • Fast HTTP/1.1 parser — Custom _fast_h1.py replaces 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 pipelineprepare_request(), negotiate_compressor(), log_request(), and is_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 — Shared get_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 cachedMiddlewareStack.__init__ classifies middleware once via inspect.signature instead of per-request
  • ConnectionClosedConnectionCompleted — Lifecycle event renamed for clarity
  • trusted_hosts type — Changed from tuple[str, ...] to frozenset[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 workerscreate_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"