OCaml 5 Alpha Release
Communications Officer
OCaml 5 is live! This major release introduces domains and effects, delivering unprecedented speed and efficiency to OCaml. Testing shows that OCaml 5 is able to outperform Go and closely match Rust in terms of performance. Keep reading for more details!
Tarides is thrilled that the alpha release of the long-awaited OCaml 5 is live! OCaml 5 is the culmination of over 8 years of research and engineering into concurrency and parallelism support for OCaml, made real thanks to hard work and dedication from all corners of the community. Tarides has been a major contributor to the engineering effort. Our engineers have contributed not only to the core compiler but also to the tools around release readiness, ecosystem compatibility testing, and continuous performance monitoring.
If you are using OCaml in an industrial setting (or if you are interested to do so), we'd like to make sure everything is ready for you to move to OCaml 5 and benefit from the new performance boost. Tell us what you need in this user survey.
What Kind of Performance to Expect?
This update brings unprecedented results in terms of performance, with an HTTP server based on OCaml 5’s Eio
being able to serve 1M+ requests/sec, outperforming Go’s nethttp
, and closely matching Rust’s hyper
performance! This is just a small indication of OCaml 5’s potential in terms of speed and efficiency.
As it’s an alpha version, it’s still subject to some change and fine tuning. This means that we need your help to make OCaml 5 better! Please give plenty of feedback and report any bugs you find.
Under the Hood
The alpha release of OCaml 5 adds support for shared memory parallel execution via domains and a new model for concurrent execution via effect handlers.
Domains enable shared-memory parallel programming that allow OCaml programs to run on multiple cores. With domains, OCaml programs will scale better by exploiting multicore processing. Effect handlers are a mechanism for concurrent programming. With the introduction of effect handlers, simple direct-style OCaml code will be flexible, easy to develop, debug, and maintain. No more monads for concurrency! These features will benefit the entire ecosystem and community, and we expect it to attract many new users to the language.
The Standard Library is gaining several of the parallelism primitives previously only found in the Threads library (Condition, Mutex, and Semaphore). Interestingly, having added domains and effects, we hope and expect that most users will never need to use them directly! Instead, we warmly encourage users to look at adopting domainslib
to parallelise programs and Eio
as a replacement for Lwt/Async monadic-style concurrency.
This work seeks to remain entirely backwards-compatible. Programs written for any version of OCaml 4, even if they use the Thread library, will continue to work with the same semantics, similar performance, and as always for OCaml, without crashes.
Next Steps
Installation
For instructions on how to install OCaml 5 on your machine, Florian Angeletti’s Discuss post goes into great detail on how to do so, depending on what version of OCaml you’re running and what machine you have. KC Sivaramakrishnan has also created a tutorial on OCaml 5 that introduces its new parallelism features, a great resource for anyone looking to make the most of the update.
Other OCaml 5 documentation includes information on parallelism, effect handlers, and the memory model.
Feedback
We want to reiterate that as with any alpha release of OCaml, we’re keen to hear about bugs and performance regressions. The move to parallel OCaml may bring new debugging challenges, but it remains the case that pure OCaml programs which do not use unsafe features should absolutely never crash. We’ll be taking part in the discussion on GitHub, Discuss, and Twitter.
The change in major version number (from 4.n to 5.n) may result in minor breaking changes which affect your packages, particularly if you’ve been allowing some deprecation warnings to slip through in the past! We’ll be following up with more information about the required tweaks that may be required for packages supporting both old and new versions of OCaml, as well as with specifics on the testing infrastructure.
Survey
As discussed above, we’ve created a user survey to help us get a better sense of how people are planning on using OCaml 5. It would be very helpful if you could fill it out for us, which should only take a few minutes.
OCaml 5 Timeline:
- The beta release will take place once these issues have been resolved.
- The final release is expected in September.
- There is no time limit on reporting bugs, so please report them here.
Further Reading
The Multicore monthlies, produced by Shakthi Kannan and Anil Madhavapeddy, provide important context for the work behind OCaml 5 and what’s coming with the release.
Open-Source Development
Tarides champions open-source development. We create and maintain key features of the OCaml language in collaboration with the OCaml community. To learn more about how you can support our open-source work, discover our page on GitHub.
Stay Updated on OCaml and MirageOS!
Subscribe to our mailing list to receive the latest news from Tarides.
By signing up, you agree to receive emails from Tarides. You can unsubscribe at any time.