Writing a DSL for high performance parallel programming in OxCaml
A Jane Street intern built a JIT compiler for an SPMD-style DSL in OxCaml so SIMD kernels for options pricing and risk checks can be written once as ordinary-looking OxCaml functions instead of architecture-specific C intrinsics. Kernels describe the computation for a single output index, and the compiler generates the loop, which keeps each iteration writing exactly one output and makes vectorization safe. The front end builds a GADT-typed DAG that tracks uniform vs. varying rates and provides three control-flow forms (select, if_, if_var) with different evaluation semantics. The backend uses OxCaml's runtime metaprogramming (quotes and splices) to emit OxCaml code, partially evaluating runtime-known values such as the chosen distance metric away and relying on the OxCaml compiler for further optimization.
Related posts
- What the interns have wrought, 2025 edition
Jane Street Tech Blog hardMasterJane Street's 2025 intern projects include an index-aware evaluator for JSQL, the company's internal SQL dialect, which over-approximates key ranges from WHERE clauses and specializes execution to Map, Hashtbl or multi-index containers, giving ~700x and ~30x speedups on 3.8M-row benchmarks. A redesigned ocamltorch API uses OxCaml's local mode and refcount scopes to free GPU tensors deterministically instead of forcing Gc.full_major calls. A third project is a shared-memory library that passes pointers between trading processes instead of serializing data, using atomic refcounts and OxCaml visibility modes (read_write, read, local) to enforce race-free, borrow-checker-like access.
- What the interns have wrought, 2021 edition
Jane Street Tech Blog mediumAdeptJane Street's 2021 dev internship (87 interns across New York, London and Hong Kong) is showcased through three projects. One extended the OCaml syntax extension ppx_typed_fields, which uses GADTs to make record fields first-class values. It now supports parameterized and nested records, and a new typed-variants extension does the same for variant types. A second built filterable cross-day time-series exports of historical atop process data for the CLI and web UI. A third added memoization of intermediate computations to Datafetcher, a Haxl-like OCaml DSL for data-fetching jobs that run in production, test or record mode.
- What the interns have wrought, 2023 edition
Jane Street Tech Blog mediumAdeptThree Jane Street intern projects, all in OCaml. The first is an SQL-like temporal query language, parsed with Angstrom and compiled onto a Linear Temporal Logic engine, for finding event sequences in Concord's transaction stream. The second is a pure-OCaml tiktoken-compatible tokenizer with a handcrafted regex automaton and an imperative rewrite; it matched or beat the Rust reference implementations, though GC pauses gave it higher variance. The third adds async support to ppx_tracing by storing correlation IDs in the Async scheduler's execution context, which helped the Iron code review team cut server startup time by about 50%.
- What the interns have wrought, 2024 edition
Jane Street Tech Blog mediumAdeptThree 2024 Jane Street intern projects get a technical walkthrough. Camels is a pure-OCaml, Polars-like dataframe library that separates expression construction from execution so queries can be compiled, and it uses a phantom-typed length parameter to catch missing broadcasts at compile time. A speed-over-size variant of Binprot drops variable-length integer encoding so adjacent non-pointer record fields can be memcpy'd, built on typerep with custom C bindings; it ran 10-20% to 15x faster than Binprot and cut production tail latencies by 30-65%. A time-travel debugger for the Aria-based Limshare risk-limit system adds periodic snapshots so engineers can step backward through the update log when investigating incidents.
- ICFP 2024
Jane Street Tech Blog hardMasterJane Street's OCaml Language team brings nine papers and talks to ICFP 2024 and describes its compiler-branch extensions: modal types (modes like local and unique) for Rust-like control over allocation and data-race-free parallelism, and a kind system for unboxed layouts. Examples include a redesigned Bonsai API that uses a local-mode witness and escape analysis to enforce its two-phase graph-building model, mixed blocks for records combining boxed and unboxed fields, ppx_template for stamping out kind/mode-specialized code until real polymorphism lands, and a zero-overhead or_null option type that uses kinds to forbid nesting. The team also released a bleeding-edge opam repo with the extended compiler and its libraries so outsiders can try the features ahead of any upstreaming.