Skip to content

v0.5.0

Choose a tag to compare

@ehsanmok ehsanmok released this 28 Apr 00:23
· 1146 commits to main since this release

Operational core

  • Request.peer: SocketAddr + Peer extractor; the kernel's view of the connecting peer threaded onto every parsed request.
  • Sanitised 4xx / 5xx response bodies (parse-error messages logged with request id, never echoed). Local-dev opt-out via ServerConfig.expose_error_messages = True.
  • Cancel token (peer FIN, timeout, drain unified through one cell). CancelHandler trait + WithCancel[H] adapter for handlers that opt into cooperative polling.
  • Per-request deadlines: read_body_timeout_ms enforced end-to-end on the cancel-aware reactor read path; handler_timeout_ms and request_timeout_ms configured + asserted at construction.
  • HttpServer.drain(timeout_ms) -> ShutdownReport on the single-threaded reactor; multi-worker Scheduler.drain returns one ShutdownReport per worker.

Buffer ownership + streaming

  • Router accepts Handler structs (not just def functions).
  • Concrete extractors (PathInt / PathStr / PathFloat / PathBool + Query / Header / Optional variants) — .value is the parsed primitive directly.
  • HeaderMapView[origin] zero-copy header storage on the read path; RFC 7230 § 3.2.4 / § 3.2.6 token + field-value validation at parse time.
  • Pool[T] typed allocator (replaces the _Boxed[H] pad after public size_of[T]()).
  • RequestView[origin] zero-copy request reads on the cancel-aware reactor; ViewHandler trait + HttpServer.serve_view[VH] entry point.
  • Streaming bodies: Body / ChunkSource traits, InlineBody, ChunkedBody[Source], StreamingResponse[B: Body] sibling type, RFC 7230 chunked serializer with lowercase hex chunk-size lines.
  • Cross-thread Cancel.SHUTDOWN flip via worker-self-walks-conns (no shared-state mutex).

Server-side TLS

  • TlsAcceptor + TlsServerConfig + TlsInfo. ALPN selection callback, mTLS opt-in with construction-time validation, cert reload without restart (acceptor.reload()), blocking-poll handshake_fd(fd) entry point.
  • Request.tls_info: Optional[TlsInfo] populated from the live handshake.
  • Server-side OpenSSL FFI surface: nine flare_ssl_* C exports covering SSL_CTX_new_server, SSL_accept, peer-cert / cipher / version / ALPN getters, ctx_reload, set_verify_client_cert.

Blocking-escape hatch

  • block_in_pool[T](work, cancel) raises -> T runs blocking syscalls on a fresh kernel thread (per-call pthread_create + pthread_join). Cancel contract: pre-flight + post-flight checks; user code polls cancel inside work() for mid-flight short-circuit. Crash isolation: a segfault in work() kills its own pthread, not the reactor's.

Bench + soak

  • Bench harness fully on wrk2 (CO-corrected), two-phase (find-peak then sustain at 90 % of peak). Per-run --latency distribution: p50 / p75 / p90 / p99 / p99.9 / p99.99 / p99.999.
  • Five workloads ship: micro-static, mixed_keepalive, uploads, downloads, slow_clients, churn.
  • Soak harness (bench-soak-*): three-tier slow-client / churn / mixed-load. Smoke (60 s/workload), extended (5 min/workload), 24 h release-gate via SOAK_DURATION_SECS=86400. Per-workload gates: zero non-2xx, rss_end <= 2 * rss_start, fd_end <= fd_start + 16.

Numbers (Linux EPYC 7R32, single-worker, plaintext)

  • ~80K req/s, on par with nginx (worker_processes 1), ~1.96× Go net/http (GOMAXPROCS=1).
  • flare_mc 4 pinned workers: 4.38× the single-thread reactor (near-linear SO_REUSEPORT scaling).
  • Tail at sustained 90 %-of-peak load: p50 ~ 1.2 ms, p99 ~ 3.1 ms, p99.99 ~ 3.8 ms.

Compatibility & infra

  • mojo == 0.26.3.0.dev2026042005 pinned across pixi.toml + recipe.yaml.
  • json dep bumped to v0.1.4; OpenSSL pinned at major 3.
  • CI Linux runners pinned to ubuntu-22.04 (Mojo runtime crash inside libKGENCompilerRTShared.so on ubuntu-latest / 24.04 — works around a documented glibc-2.39 ABI break).
  • CI generates the self-signed cert before pixi run tests (TLS test cert paths are repo-relative build/tls-bench-certs/).

Docs

  • README leads with ## Features + ## Numbers (full-library framing, not v0.5-changelog).
  • docs/benchmark.md carries methodology + single-worker / multi-worker discipline (no apples-to-oranges multi-vs-single ratios) + soak harness as ## Soak: long-running operational gates.
  • docs/cookbook.md, docs/architecture.md, docs/security.md updated.
  • Public docs are version-agnostic across the board.

Mojo-blocked, deferred to the v0.5.x patch line (do NOT block this tag)

  • install_drain_on_sigterm / install_sigterm_handler — Mojo "global variables are not supported"; production deployments wire their own signal(2) handler today (see examples/23_drain.mojo).
  • Reactor-state-machine TLS handshake (STATE_TLS_HANDSHAKE advanced via on_readable / on_writable) — gated on parametric trait method specialisation cost in a future Mojo nightly. Blocking-poll handshake_fd ships today.
  • Reactor pull-edge for StreamingResponse[B] — same parametric-trait specialisation block. Streaming serializer + handler-driven chunked body ship today; reactor-driven pull-loop integration is the follow-up.