# Concurrent revisions for OCaml

*2013-01-01 — idea*


The biggest challenge when using parallel programming is typically how to keep
track of the side effects of computations that are executed in parallel and
that involve shared mutable state.  Traditional methods for dealing with this
issue often limit concurrency, do not provide sufficient determinism and are
error prone. Ideally, we would like a concept where all conflicts between
parallel tasks are resolved deterministically with minimized effort from the
programmer.
This project aims to design and build a library for OCaml that implements the
concept of [concurrent
revisions](https://www.microsoft.com/en-us/research/project/concurrent-revisions/).


Concurrent revisions as initially proposed highlight these design choices:

1) Declarative data sharing: the user declares what data is to be shared between parallel tasks by the use of isolation types
2) Automatic isolation: each task has its own private stable copy of the data that is taken at the time of the fork
3) Deterministic conflict resolution: the user specifies a merge function that is used to resolve write-write conflicts that might arise when joining parallel tasks. Given that this function is deterministic, the conflict resolution is also deterministic.

In this framework the unit of concurrency are asynchronous tasks called
*revisions*. They provide the typical functionality for asynchronous tasks -
the user can create, fork and join them. This removes the complexity of
synchronization out of the tasks themselves and gathers it into a single place; the `merge` function.

A key outcome is to improve our understanding of the tradeoffs both between the
different paths that can be chosen during the implementation of this library
and the more traditional means of concurrent programming.  We will design an
evaluation of the differences between the API of the original concurrent
revisions limplementation written in C\# and the more functional style of one
built in OCaml.

The project was successfully completed, with the major decision being whether
or not to switch to a monadic API vs a direct-style one with better lower-level
control.

## Related Reading

- [Concurrent Revisions at Microsoft Research](https://www.microsoft.com/en-us/research/project/concurrent-revisions/)
- [Real World OCaml: Functional Programming for the Masses](https://anil.recoil.org/papers/rwo)

## Links

The dissertation [PDF is available](https://github.com/dpp23/ocaml_revisions/)
publically along with the [source code to the prototype
library](https://github.com/dpp23/ocaml_revisions/) which implemented a logging
and chat server to demonstrate the use of concurrent revisions.
Status: Completed
Level: PartII
Year: 2013
Project: OCaml Labs
Supervisors: Anil Madhavapeddy
Students: Dimitar Popov

## Related

- [Real World OCaml: Functional Programming for the Masses](https://anil.recoil.org/papers/rwo) (paper, 2022-10-01)

---
Canonical: https://anil.recoil.org/ideas/concurrent-revisions
Type: idea
Tags: distributed, multicore, fp, ocaml
