Data-Race Freedom by Construction with OxCaml
OCaml, OxCaml, Parallel Programming, Type Systems
Multicore programming has been a major driver of performance gains, but data races remain a persistent headache: programs fail non-deterministically despite analysis and testing tools. Since OCaml 5 introduced shared-memory parallelism, this concern has also affected OCaml programmers.
OxCaml is a set of OCaml extensions developed by Jane Street for performance-oriented programming. Among its additions is a mode system inspired by Rust's ownership and borrowing model. Part of this mode system is designed to ensure data-race freedom by ruling out data races at compile time.
Workshop plan
- Run your first parallel OCaml programs across multiple domains and intentionally trigger data races.
- Learn about the portability and contention mode axes and use them to rule out data races at compile time.
- Share mutable state safely with atomics and capsules without giving up the data-race-freedom guarantee.
Key takeaways
- Understand what a data race is and why these bugs are so difficult to catch through testing.
- See the compiler catch data races at compile time without runtime analysis tools.
- Discover how mode systems track not only what a value is, but also how it can be used.
Requirements
Familiarity with OCaml syntax is helpful but not required. The exercises are well commented and require only minimal code writing, allowing OCaml beginners to follow most of the workshop. No prior experience with OxCaml or multicore OCaml is necessary.
The environment is provided as a dev container that can run through GitHub Codespaces, which is the recommended setup. Attendees only need a modern browser and a free GitHub account.
The same dev container can be run locally on Linux or macOS, although this requires Docker and either Visual Studio Code with the Dev Containers extension or the devcontainer CLI.
Target audience
Developers interested in safe parallel programming and type-system approaches to data-race freedom. It is useful for anyone interested in OCaml, OxCaml, or how Rust-style ownership ideas can transfer to other languages.