{"id":14109614,"url":"https://github.com/ocaml-multicore/awesome-multicore-ocaml","last_synced_at":"2025-07-16T21:15:38.254Z","repository":{"id":42507383,"uuid":"446508932","full_name":"ocaml-multicore/awesome-multicore-ocaml","owner":"ocaml-multicore","description":"A collection of libraries, experiments and ideas relating to OCaml 5 (multicore + effects)","archived":false,"fork":false,"pushed_at":"2023-08-30T05:11:58.000Z","size":53,"stargazers_count":137,"open_issues_count":2,"forks_count":2,"subscribers_count":10,"default_branch":"main","last_synced_at":"2024-05-01T13:41:51.121Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ocaml-multicore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-01-10T16:56:43.000Z","updated_at":"2024-04-20T19:33:56.000Z","dependencies_parsed_at":"2023-01-29T23:35:11.520Z","dependency_job_id":"91c37dc0-b712-4942-bb3d-a38117f2ce20","html_url":"https://github.com/ocaml-multicore/awesome-multicore-ocaml","commit_stats":null,"previous_names":["patricoferris/awesome-multicore-ocaml"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocaml-multicore%2Fawesome-multicore-ocaml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocaml-multicore%2Fawesome-multicore-ocaml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocaml-multicore%2Fawesome-multicore-ocaml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocaml-multicore%2Fawesome-multicore-ocaml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ocaml-multicore","download_url":"https://codeload.github.com/ocaml-multicore/awesome-multicore-ocaml/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239946877,"owners_count":19723014,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-14T10:02:24.527Z","updated_at":"2025-02-22T11:30:59.125Z","avatar_url":"https://github.com/ocaml-multicore.png","language":null,"funding_links":[],"categories":["Other Lists","Parallelism"],"sub_categories":["TeX Lists"],"readme":"# Awesome Multicore OCaml\n\nA collection of libraries, experiments and ideas relating to OCaml 5 (multicore + effects). With the [merging](https://github.com/ocaml/ocaml/pull/10831#issuecomment-1008935795) of the main `multicore-ocaml` branch into OCaml `trunk`, a parallel and effectful world is fast approaching.\n\nThis repository collects useful libraries, ideas and experiments relating to the use of Multicore OCaml features (primarily parallelism with domains and direct-style code with effects).\n\nFor contributing, [see the guide](https://github.com/patricoferris/awesome-multicore-ocaml/blob/main/CONTRIBUTING.md).\n\nIf you are wondering what even is Multicore OCaml, you could start by watching [KC's keynote at ICFP 2022](https://www.youtube.com/watch?v=zJ4G0TKwzVc\u0026t=2s). To know more about how Multicore OCaml evolved over the years, see [this video from 2014 about Multicore OCaml by Stephen Dolan and co.](https://watch.ocaml.org/videos/watch/490b5363-01b6-45d8-9b7e-c883a20026a1), then [one on how to parallelise your OCaml code](https://watch.ocaml.org/videos/watch/ce20839e-4bfc-4d74-925b-485a6b052ddf) and [how we can adapt the existing ecosystem to support Multicore OCaml](https://watch.ocaml.org/videos/watch/629b89a8-bbd5-490d-98b0-d0c740912b02).\n\nFor understanding effects in OCaml 5 you can watch [KC Sivaramakrishnan's Effective Programming in OCaml 5 talk](https://www.youtube.com/watch?v=xKUzN-McZUk) and also Thomas Leonard's talk at the [2021 OCaml Workshop](https://v3.ocaml.org/workshops/ocaml-workshop-2021) on [Experiences with Effects](https://watch.ocaml.org/videos/watch/74ece0a8-380f-4e2a-bef5-c6bb9092be89). Note both videos use a syntax for effects that will not exist in OCaml 5.00 (see also [ppx_effects](#ppx_effects)).\n\nFor more resources like this, check the [Multicore OCaml wiki](#wiki).\n\n*There's a WIP PR to start submoduling repositories so it can be a one-stop shop for taking OCaml 5.00 for a spin, see [the PR](https://github.com/patricoferris/awesome-multicore-ocaml/pull/1)*.\n\n## Table of Contents\n- [Installation](#installation)\n- [Libraries](#libraries)\n  - [Eio](#eio)\n  - [Affect](#affect)\n  - [Domainslib](#domainslib)\n  - [Lockfree](#lockfree)\n  - [Lwt Support](#lwt-support)\n  - [Async Support](#async-support)\n  - [Parany](#parany)\n  - [Processor](#ocaml-processor)\n  - [cohttp-eio](#cohttp-eio)\n  - [mirage-crypto-rng-eio](#mirage-crypto-rng-eio)\n  - [Js_of_ocaml support](#js_of_ocaml)\n  - [ocaml-tls](#ocaml-tls)\n  - [algaeff](#algaeff)\n- [Testing](#testing)\n  - [multicoretests](#multicoretests)\n- [Tooling](#tooling)\n  - [Olly](#olly)\n  - [Eio-console](#eio-console)\n  - [TSan](#tsan)\n- [Experiments](#experiments)\n  - [Dream](#dream)\n  - [Ppx_effects](#ppx_effects)\n  - [Gemini Protocol](#gemini-protocol)\n  - [Multi-shot Continuations](#multi-shot-continuations)\n  - [Mirage network](#mirage-networking-experiments)\n  - [Capnp-rpc](#capnp-rpc)\n  - [gRPC](#grpc)\n- [Ideas](#ideas)\n  - [Non-blocking Codec](#non-blocking-codec)\n- [Resources](#resources)\n    - [Wiki](#wiki)\n    - [Discuss Threads](#discuss-threads)\n    - [Monthlies](#monthlies)\n    - [Benchmarks](#benchmarks)\n\n## Installation\n\nOCaml 5 is out! The compiler can be obtained with the following instructions on Linux and Mac machines.\n\n```\nλ opam update\nλ opam switch create 5.0.0\nλ eval $(opam env)\n```\n\n## Libraries\n\n### Eio\n\nRepository: https://github.com/ocaml-multicore/eio\n\nEio implements an effects-based direct-style IO stack for multicore OCaml. It supports multiple backends including a performant [io-uring](https://unixism.net/loti/what_is_io_uring.html) one and a portable [libuv](http://docs.libuv.org/en/v1.x/) backend. A [0.1 release](https://github.com/ocaml/opam-repository/pull/20695) is now available from opam-repository.\n\n### Affect\n\nRepository: https://erratique.ch/software/affect\n\n\u003e Affect provides composable concurrency primitives for OCaml using the effect handlers available in OCaml 5.0. Affect should be seen as an experiment at that point.\n\n### Domainslib\n\nRepository: https://github.com/ocaml-multicore/domainslib\n\nDomainslib provides data-structures for parallel programming on top of multicore primitives. This includes a work-stealing task pool and channels for inter-domain communication.\n\n### Lockfree\n\nRepository: https://github.com/ocaml-multicore/lockfree\n\nLock-free is collection of [non-blocking](https://en.wikipedia.org/wiki/Non-blocking_algorithm) data structures for multicore OCaml.\n\n### Lwt Support\n\nSome useful and relevant OCaml.5 x Lwt discussions:\n\n - [Is mixing lwt and multicore safe?](https://discuss.ocaml.org/t/is-mixing-lwt-and-multicore-safe/8714)\n - [Multicore, Async and Lwt](https://discuss.ocaml.org/t/multicore-async-and-lwt/2687)\n\n#### Lwt_eio\n\nRepository: https://github.com/talex5/lwt_eio\n\n`Lwt_eio` provides an \"lwt engine\" using [Eio](#eio) making it possible to use both Eio and Lwt in the same codebase. A [0.1 release](https://github.com/ocaml/opam-repository/pull/20701) is now available from opam-repository.\n\n#### Lwt_domain\n\nRepository: https://github.com/ocsigen/lwt\n\nLwt now has a package called [`lwt-domain`](https://github.com/ocsigen/lwt/tree/master/src/domain). This provides useful functions for programming with Lwt and [Domainslib](#domainslib).\n\n### Async Support\n\n#### Async_eio\n\nRepository: https://github.com/talex5/async_eio\n\nAsync_eio allows running Async and Eio code together in a single domain. It allows converting existing code to Eio incrementally.\n\n### Parany\n\nRepository: https://github.com/UnixJunkie/parany/tree/domains\n\nThe Parany git branch called \"domains\" is compatible with multicore-ocaml.\n\n### OCaml Processor\n\nRepository: https://github.com/haesbaert/ocaml-processor\n\nThe library allows you to query the processor topology as well as set the processor affinity for the current process.\n\n### cohttp-eio\n\nRepository: https://github.com/mirage/ocaml-cohttp/tree/master/cohttp-eio\n\n`cohttp-eio` is a HTTP client and server library built using `eio`. It enables monad-less, direct style programming of multi-core capable HTTP web server and client applications. Monads be gone. \n\n### mirage-crypto-rng-eio\n\nRepository: https://github.com/mirage/mirage-crypto/tree/main/rng/eio\n\n`mirage-crypto-rng-eio` allows to use various crypto functions in an `eio` application.\n\n### Js_of_ocaml\n\nRepository: https://github.com/ocsigen/js_of_ocaml\n\n`js_of_ocaml` supports effects through CPS transformations - this means one can start running effects in browsers! Implementation details can be found in [Jérôme Vouillon\n's PR](https://github.com/ocsigen/js_of_ocaml/pull/1340)\n\n### ocaml-tls\n\nRepository: https://github.com/mirleft/ocaml-tls\n\n`tls_eio` supports effectful operations using Eio.\n\n### algaeff\n\nRepository: \u003chttps://github.com/RedPRL/algaeff\u003e\n\n`algaeff` is a collection of well-known reusable effects-based components (states, generators, etc.) packaged as an OPAM library.\n\n## Testing\n\n### Multicoretests\n\nRepository: https://github.com/jmid/multicoretests\n\nExperimental property-based tests of (parts of) the OCaml multicore compiler. The project contains a randomized testsuite of OCaml 5.0 based on QCheck and two reusable testing libraries `Lin` and `STM`.\n\n## Tooling\n\n### Olly\n\nRepository: https://github.com/sadiqj/runtime_events_tools\n\nA collection of observability tools around the runtime events tracing system introduced in OCaml 5.0.\n\n### Eio-console\n\nRepository: https://github.com/patricoferris/eio-console\n\nEio-console provides an application for monitoring running programs. This works in the browser, communicating information over a websocket.\n\n### TSan\n\nRepository: https://github.com/OlivierNicole/ocaml-tsan\n\nThreadSanitizer (TSan) is an effective approach to locate data races in parallel code. This extended version of the OCaml compiler generates instrumented executables that will print error reports if a data race is detected.\n\n## Experiments\n\n### Dream\n\nRepository: https://github.com/talex5/dream/tree/eio\n\nSee also the [draft PR](https://github.com/aantron/dream/pull/194) that uses [Dream](https://github.com/aantron/dream), Eio and [lwt_eio](#lwt-eio) to provide a direct-style interface to Dream.\n\n### Ppx_effects\n\nRepository: https://github.com/CraigFe/ppx_effects\n\nThe effects in OCaml 5 will not support a dedicated syntax, but plans exist for this perhaps once the effects are typed. Until then this ppx provides an approximation to the proposed syntax.\n\n### Gemini Protocol\n\nRepository: https://gitlab.com/talex5/gemini-eio\n\nThe [gemini protocol](https://gemini.circumlunar.space/docs/faq.gmi) implemented in direct-style using [eio](#eio).\n\n### Multi-shot Continuations\n\nRepository: https://github.com/dhil/ocaml-multicont\n\nBuilt on top of the continuations in Multicore OCaml, `ocaml-multicont` provides a library for using continuations that can be applied more than once. See also [this discussion on discuss](https://discuss.ocaml.org/t/multi-shot-continuations-gone-forever/9072).\n\n### Mirage networking experiments\n\nRepository: https://github.com/TheLortex/networking-experiments\n\nGoal is to port Mirage's TCP/IP stack on top of OCaml 5's effects for more manageable async code.\n\n### capnp-rpc\n\nCap'n Proto is a capability-based RPC system with bindings for many languages. The [Eio port](https://github.com/mirage/capnp-rpc/pull/256) switches capnp-rpc from Lwt to Eio.\n\n### gRPC\n\ngRPC is a high performance, open source, general RPC framework that puts mobile and HTTP/2 first. The [Eio port](https://github.com/dialohq/ocaml-grpc/) adds native Eio support for OCaml gRPC.\n\n\n## Ideas\n\nEven less further on than [experiments](#experiments), the *ideas* section contains projects that would benefit from the features of Multicore OCaml.\n\n### Non-blocking Codec\n\nRepository: https://github.com/dbuenzli/nbcodec\n\nMany libraries and tools written in the nbcodec style would benefit from continuations given by effect handlers in Multicore OCaml, including libraries like [jsonm](https://github.com/dbuenzli/jsonm) or [xmlm](https://github.com/dbuenzli/xmlm) perhaps.\n\n## Resources\n\n### Wiki\n\nThe [Multicore OCaml Wiki](https://github.com/ocaml-multicore/ocaml-multicore/wiki) contains a lot of useful information from design decisions to examples. Two notable repositories are: \n\n  - [Effects examples](https://github.com/ocaml-multicore/effects-examples): a collection of great examples with effects including cooperative threading and generators.\n  - [Parallel Programming in Multicore OCaml](https://github.com/ocaml-multicore/parallel-programming-in-multicore-ocaml): a very good introduction to programming parallel programs in Multicore OCaml, including [using Domainslib](https://github.com/ocaml-multicore/parallel-programming-in-multicore-ocaml#domainslib).\n\n### Papers\n\n- [Retrofitting Effect Handlers onto OCaml](https://kcsrk.info/papers/retro-concurrency_pldi_21.pdf), PLDI, June 2021: Describes the design and evaluation of a full-fledged efficient implementation of effect handlers for OCaml.\n- [Parallelising your OCaml code with Multicore OCaml](https://github.com/ocaml-multicore/multicore-talks/blob/master/ocaml2020-workshop-parallel/multicore-ocaml20.pdf), OCaml Workshop, August 2020: A tour on developing parallel programs with Multicore OCaml.\n- [Retrofitting Parallelism onto OCaml](https://kcsrk.info/papers/retro-parallel_icfp_20.pdf), ICFP, August 2020: Deep dive into Multicore GC design. \n- [Multicore OCaml memory model](http://kcsrk.info/papers/pldi18-memory.pdf), PLDI, June 2018: Describes the memory model for multicore OCaml programs. This memory model is much simpler than existing language memory models such as Java or C/C++11 without sacrificing performance. \n- [Concurrent System Programming with Effect Handlers](http://kcsrk.info/papers/system_effects_feb_18.pdf), TFP, February 2018: Using effect handler for writing concurrent programs that interacts with the operating system.\n- [Multicore OCaml](https://ocaml.org/meetings/ocaml/2014/ocaml2014_1.pdf), OCaml workshop, September 2014.\n\n### Talks\n\n* Introduction to Eio, Thomas Leonard, February 2023. ([video](https://watch.ocaml.org/w/1k1T919WGXoT4tjnRZEmMd))\n* [k-CAS for sweat-free concurrent programming](https://gist.github.com/polytypic/3214389ad69b16d28b957ced86e1b1a4#k-cas-for-sweat-free-concurrent-programming), Vesa Karvonen, February 2023. ([video](https://watch.ocaml.org/w/nmtxFx5zDJLbEXRhraf3JU))\n* Retrofitting Concurrency – Lessons from the Engine Room, KC Sivaramakrishnana, September 2022. ([video](https://www.youtube.com/watch?v=zJ4G0TKwzVc\u0026t))\n* [Experiences with Effects in OCaml](https://icfp21.sigplan.org/details/ocaml-2021-papers/16/Experiences-with-Effects), Thomas Leonard, August 2021. ([video](https://watch.ocaml.org/videos/watch/74ece0a8-380f-4e2a-bef5-c6bb9092be89))\n* [Parafuzz: Coverage-guided Property Fuzzing for Multicore OCaml programs](https://icfp21.sigplan.org/details/ocaml-2021-papers/9/Parafuzz-Coverage-guided-Property-Fuzzing-for-Multicore-OCaml-programs), KC Sivaramakrishnan, August 2021. ([video](https://watch.ocaml.org/videos/watch/c0d591e0-91c9-4eaa-a4d7-c4f514de0a57))\n* [Adapting the OCaml Ecosystem for Multicore OCaml](https://icfp21.sigplan.org/details/ocaml-2021-papers/7/Adapting-the-OCaml-ecosystem-for-Multicore-OCaml), Sudha Parimala, August 2021. ([video](https://watch.ocaml.org/videos/watch/629b89a8-bbd5-490d-98b0-d0c740912b02))\n* [Effective Programming in OCaml](https://kcsrk.info/slides/jet_brains_21.pdf), KC Sivaramakrishnan, April 2021. ([video](https://www.youtube.com/watch?v=plFFZcqBOyk))\n* [Multicore OCaml -- what's coming in 2021](https://speakerdeck.com/kayceesrk/multicore-ocaml-whats-coming-in-2021), KC Sivaramakrishnan, December 2020. ([video](https://www.youtube.com/watch?v=mel76DFerL0))\n* [Parallelising your OCaml code with Multicore OCaml](https://github.com/ocaml-multicore/multicore-talks/blob/master/ocaml2020-workshop-parallel/slides-with-speaker-notes.pdf), Sadiq Jaffar August 2020. ([video](https://www.youtube.com/watch?v=Z7YZR1q8wzI))\n* [Retrofitting parallelism onto OCaml](https://speakerdeck.com/kayceesrk/retrofitting-parallelism-onto-ocaml), KC Sivaramakrishnan, August 2020. ([video](https://www.youtube.com/watch?v=9ClMPz7QaIs))\n* [A deep dive into Multicore OCaml GC](https://speakerdeck.com/kayceesrk/multicore-ocaml-gc), KC Sivaramakrishnan, June 2017.\n* [Reagents: Lock-free programming for the masses](https://speakerdeck.com/kayceesrk/reagents-lock-free-programming-for-the-masses), KC Sivaramakrishnan, August 2016. ([video](https://www.youtube.com/watch?v=qRWTws_YPBA)).\n* [Arrows and Reagents](https://speakerdeck.com/kayceesrk/arrows-and-reagents), KC Sivaramakrishnan, March 2016.\n* [Concurrent \u0026 Multicore OCaml: A deep dive](https://speakerdeck.com/kayceesrk/concurrent-and-multicore-ocaml-a-deep-dive), KC Sivaramakrishnan, January 2016.\n* [Effective Concurrency with Algebraic Effects](http://kcsrk.info/slides/OCaml15.pdf), KC Sivaramakrishnan, OCaml Workshop, September 2015.\n* [Multicore OCaml](https://www.cl.cam.ac.uk/~sd601/papers/multicore_slides.pdf), Stephen Dolan, OCaml workshop, September 2014. ([video](https://www.youtube.com/watch?v=FzmQTC_X5R4\u0026list=UUP9g4dLR7xt6KzCYntNqYcw)).\n\n\n### Discuss Threads\n\nRecently, there has been a lot of great discussion on discuss.ocaml.org around OCaml 5, in particular what the ramifications of adding effects to the language will have to the ecosystem:\n\n - The [initial release](https://discuss.ocaml.org/t/eio-0-1-effects-based-direct-style-io-for-ocaml-5/9298) of Eio has a lot of dicussion around what it could mean if the library became the official \"OCaml IO\" library. It also has some useful conversations about the underlying use of effects in Eio and in particular the [set of private effects used](https://v3.ocaml.org/p/eio/0.1/doc/Eio/Private/Effects/index.html).\n   + An excellent write up about [scopes and effect handlers](https://hackmd.io/@yF_ntUhmRvKUt15g7m1uGw/Bk-5NXh15) was added in this [thread](https://discuss.ocaml.org/t/eio-0-1-effects-based-direct-style-io-for-ocaml-5/9298/91).\n - Another thread, [\"How to block in an agnostic way\"](https://discuss.ocaml.org/t/how-to-block-in-an-agnostic-way/9368), is a discussion about blocking code where we are agnostic to the underlying concurrency abstraction (and indeed how to do [interop between libraries](https://discuss.ocaml.org/t/how-to-block-in-an-agnostic-way/9368/4)).\n - Another more Eio-specific thread looks at [cancellation in the presence of concurrency from effects](https://discuss.ocaml.org/t/understanding-cancellation-in-eio/9369).\n - In [How do spawn and join interact with try_with](https://discuss.ocaml.org/t/multicore-how-do-spawn-and-join-interact-with-try-with/9362) there's a great, short discussion about effects in the presence of multiple domains. A \"gotcha\" many (myself included) are likely to hit when getting started with OCaml 5.\n - There is a great discussion about using effects for a [roguelike](https://en.wikipedia.org/wiki/Roguelike) game in [Tutorial: Roguelike with Effect Handlers](https://discuss.ocaml.org/t/tutorial-roguelike-with-effect-handlers/9422) (the full tutorial [is here](https://hackmd.io/@yF_ntUhmRvKUt15g7m1uGw/BJBZ7TMeq)). Related to that is another excellent article about coding [animations with effect handlers](https://gopiandcode.uk/logs/log-bye-bye-monads-algebraic-effects.html).\n\n### Monthlies\n\nThe OCaml monthlies are available on discuss: https://discuss.ocaml.org/tag/multicore-monthly\n\n### Benchmarks\n\n#### Sandmark\n\nRepository: https://github.com/ocaml-bench/sandmark\n\n\u003e Sandmark is a suite of OCaml benchmarks and a collection of tools to configure different compiler variants, run and visualise the results.\n\nSandmark nightly runs the Sandmark benchmarks and visualises results: https://sandmark.tarides.com/?app=Home\n\n#### Http Benchmarks\n\nRepository: https://github.com/ocaml-multicore/retro-httpaf-bench\n\nA collection of HTTP servers including ones in Go, Rust, multiple OCaml implementations and OCaml with effects.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focaml-multicore%2Fawesome-multicore-ocaml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Focaml-multicore%2Fawesome-multicore-ocaml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focaml-multicore%2Fawesome-multicore-ocaml/lists"}