Anil Madhavapeddy, known for work on planetary computing infrastructure, has developed a high-performance HTTP/1.1 parser named httpz, leveraging the specialized capabilities of the OxCaml compiler.
Madhavapeddy cited the performance gains offered by OxCaml's language extensions, which facilitate systems programming while retaining OCaml’s functional core, as the primary motivation for the project.
Unlike alternatives such as Rust, OxCaml maintains a garbage collector for standard code paths, offering a balance between performance optimization and familiar memory management for general application logic.
The core innovation in httpz is its aim for zero major heap allocation for handling HTTP connections, achieved by utilizing OxCaml's unboxed types and local stack allocations.
This approach allows the entire lifetime of an HTTP connection to reside on the call stack, minimizing garbage collector activity during steady-state operation, according to the notes published on anil.recoil.org.
To achieve this, the developer shifted from traditional OCaml structures like cstruct to defining records using OxCaml's unboxed syntax, such as #{ off : int16# ; len : int16# }, for managing buffer offsets and lengths.
Inspection of the compiled lambda intermediate language and subsequent ARM64 assembly code confirms that these unboxed records translate directly into efficient register and stack operations, avoiding heap boxing entirely.
The development of httpz serves as a proof-of-concept for applying advanced compiler features to critical infrastructure components, potentially offering substantial throughput improvements for I/O-bound services.
Future work will likely involve integrating this low-allocation parser into Madhavapeddy’s ongoing research infrastructure managing large-scale geospatial embeddings generated by the TESSERA project.