Trending:
Software Development

OCaml researcher builds zero-allocation HTTP server using Jane Street's OxCaml extensions

Anil Madhavapeddy has implemented a high-performance HTTP/1.1 server that runs almost entirely on the callstack, eliminating garbage collection overhead. The approach uses OxCaml—Jane Street's experimental OCaml extensions—to handle petabyte-scale planetary computing workloads. While technically impressive, production adoption faces tooling complexity and limited ecosystem support.

OCaml researcher builds zero-allocation HTTP server using Jane Street's OxCaml extensions

OCaml researcher builds zero-allocation HTTP server using OxCaml extensions

Anil Madhavapeddy, working on planetary computing infrastructure, has built an HTTP/1.1 parser that operates with minimal heap allocation using OxCaml—Jane Street's experimental extensions to OCaml. The server, called httpz, processes 32KB requests almost entirely on the callstack, avoiding garbage collection activity in steady-state operation.

The Technical Approach

OxCaml enables direct assembly-like operations on the callstack through unboxed types and local allocations. Unlike standard OCaml, which would allocate a four-word record for buffer views (used in libraries like cstruct since 2012), OxCaml's unboxed types eliminate this overhead. Combined with direct-style effects from OCaml 5.x, the code avoids callback complexity while maintaining performance.

The motivation: managing petabytes of TESSERA geospatial embeddings for planetary computing research. Madhavapeddy notes frustration with maintaining large Python scripts and wanting OCaml's type safety and modularity.

The Reality Check

This is experimental work. OxCaml has known limitations—complex memory layouts can trigger value inference errors, and certain patterns (like or_null options) still require heap allocation. The OCaml Platform roadmap targets production-ready features by 2026, but mature frameworks like Dream or Ocsigen remain the safer choice for shipping code.

Tooling remains messy despite Dune improvements. Windows/WSL support needs work, and the setup complexity creates friction. OCaml has production credibility (XenServer, some Jane Street systems), but OxCaml itself is research-grade.

What This Signals

The project demonstrates OCaml's potential for systems programming where Rust typically dominates—but with a GC available for non-critical paths. Whether OxCaml's approach gains broader adoption depends on Jane Street's roadmap and ecosystem maturity.

For now, httpz is interesting engineering that won't replace your production HTTP stack. We'll see if the trade-offs make sense beyond specialized research workloads.