Welcome to the June 2020 Multicore OCaml report! As with previous updates, many thanks to @shakthimaan and @kayceesrk for collating the updates for the month of June 2020. This is an incremental update; new readers may find it helpful to flick through the previous posts first.
This month has seen a tremendous surge of activity on the upstream OCaml project to prepare for multicore integration, as @xavierleroy and the core team have driven a number of initiatives to prepare the OCaml project for the full multicore featureset. To reflect this, from next month we will have a status page on the ocaml-multicore wiki with the current status of both our multicore branch and the upstream OCaml project itself.
Why not from this month? Well, there’s good news and bad news. Last month, I observed that we are a PR away from most of the opam ecosystem working with the multicore branch. The good news is that we are still a single PR away from it working, but it’s a different one The retrofitting of the
Threads library has brought up some design complexities, and so rather than putting in a “bandaid” fix, we are integrating a comprehensive solution that will work with system threads, domains and (eventually) fibres. That work has taken some time to get right, and I hope to be able to update you all on an opam-friendly OCaml 4.10.0+multicore in a few weeks.
Aside from this, there have been a number of other improvements going into the multicore branches: mingw Windows support, callstack improvements, fixing the Unix module and so on. The full list is in the detailed report later in this update.
A major milestone in this month has been the upgrade to the latest dune.2.6.0 to build Multicore OCaml 4.10.0 for the Sandmark benchmarking project. A number of new OPAM packages have been added, and the existing packages have been upgraded to their latest versions. The Multicore OCaml code base has seen continuous performance improvements and enhancements which can be observed from the various PRs mentioned in the report.
We would like to thank:
@xavierleroy for working on a number of multicore-prequisite PRs to
make stock OCaml ready for Multicore OCaml.
@camlspotter has reviewed and accepted the camlimages changes
and made a release of camlimages.5.0.3 required for Sandmark.
@dinosaure for updating the decompress test benchmarks for Sandmark
to build and run with dune.2.6.0 for Multicore OCaml 4.10.0.
A chapter on Parallel Programming in Multicore OCaml with topics on task pool, channels section, profiling with code examples is being written. We shall provide an early draft version of the document to the community for your valuable feedback.
Our “Retrofitting Parallism onto OCaml” paper has been officially accepted at ICFP 2020 which will be held virtually between August 23-28, 2020. A preprint of the paper was made available earlier, and will be updated in a few days with the camera-ready version for ICFP. Please do feel free to send on comments and queries even after the paper is published, of course.
Excitingly, another multicore-related paper on Cosmo: A Concurrent Separation Logic for Multicore OCaml will also be presented at the same conference.
The Multicore OCaml updates are first listed in our report, which are followed by improvements to the Sandmark benchmarking project. Finally, the changes made to upstream OCaml which include both the ongoing and completed tasks are mentioned for your reference.
Proposal for domain-local storage
An RFC proposal to implement a domain-local storage in Multicore
OCaml. Kindly review the idea and share your feedback!
Implementing the threads library with Domains
An effort to rebase @jhwoodyatt’s implementation of the Thread
library for Domains.
Implementation of systhreads with pthreads
Exploring the possibilty of implementing systhreads with pthreads,
while still maintaining compatibility with the existing solution.
Dune fails to pick up secondary compiler
ocaml-secondary-compilerfails to install with dune.2.6.0. This
is required as Multicore OCaml cannot build the latest dune without
Update dune to 2.6.0
The dune version in the Multicore OPAM repository is now updated to
use the latest 2.6.0.
Introduce Lazy.try_force and Lazy.try_force_val
An implementation of
functions to implement concurrent lazy abstractions.
Fix Atomic.exchange in concurrent_minor_gc
A patch that introduces
provides the appropriate read barrier for correct exchange
Fix extcall noalloc DWARF
The DWARF information emitted for
extcall noallochad broken
backtraces and this PR fixes the same.
Absolute exception stack
The representation of the exception stack is changed from relative
addressing to absolute addressing and the results are promising. The
Sandmark serial benchmark results after the change is illustrated in
the following graph:
Turn on -Werror by default
configureto treat C
compiler warnings as errors.
Poll for interrupts in cpu_relax without locking
Caml_check_gc_interruptfirst to poll for interrupts without
locking, and then proceeding to handle the interrupt with the lock.
Add Caml_state_field to domain_state.h
Caml_state_fieldmacro definition in domain_state.h is
required for base-v0.14.0 to build for Multicore OCaml 4.10.0 with
One more location to poll for interrupts without lock
Another use of
Caml_check_gc_interruptfirst to poll for
interrupts without lock, similar to
Backup threads for domain
backup threadsto perform GC and handle service
interrupts when the domain is blocked in the kernel.
Fix up bad CFI information in amd64.S
The PR makes
caml_domain_alonean inline function to improve
caml_atomic_cas_fieldand other atomics in
Parallel minor GC inline mask rework
The inline mask rework for the promotion path to the
parallel_minor_gcbranch gives a 3-5% performance improvement for
test_decompresssandmark benchmark, and a decrease in the executed
instructions for all other benchmarks.
Mark stack push work credit
The PR improves the Multicore mark work accounting to be in line
with stock OCaml.
Iloadmut does not clobber rax and rdx when we do not have a read barrier
A code clean-up to free the registers
rdxfor OCaml code
Ability to run compiler variants in Sandmark
A feature to specify configure options when building compiler
variants such as
flambdais useful for development and
testing. This feature is being worked upon.
Add Coq benchmarks
We are continuing to add more benchmarks to Sandmark for Multicore
OCaml and investigating adding the Coq
benchmarks to our repertoire!
User configurable paramwrapper added to Makefile
PARAMWRAPPERenvironment variable can be passed as an argument
by specifying the
--cpu-listto be used for parallel benchmark
Update decompress benchmarks
Thanks to @dinosaure for updating the decompress benchmarks in order
to run them with dune.2.6.0 for Multicore OCaml 4.10.0.
Update dependency packages to use dune.2.6.0 and Multicore OCaml 4.10.0
Sandmark has been running with dune.1.11.4, and we need to move to
the latest dune.2.6.0 for using Multicore OCaml 4.10.0 and beyond,
as mentioned in Promote dune to >
2.0. The PR
updates over 30 dependency packages and successfully builds both
serial and parallel benchmarks!
Use dune-configurator instead of configurator for camlimages
A new release of
camlimages.5.0.3was made by @camlspotter after
accepting the changes to camlimages.opam in order to build with
Task API Port: LU-Decomposition, Floyd Warshall, Mandelbrot, Nbody
The changes to use the
Domainslib.TaskAPI for the listed benchmarks
have been merged.
Mention sudo access for run_all_parallel.sh script
The README.md file has been updated with the necessary
configuration steps to execute the
Add cubicle benchmarks
Szymanski's mutual exclusion algorithmcubicle
benchmarks have been included in Sandmark.
Update ocaml-versions README to reflect 4.10.0+multicore
The README has now been updated to reflect the latest 4.10.0
Multicore OCaml compiler and its variants.
Add target to run parallel benchmarks in the CI
The .drone.yml file used by the CI has been updated to run both the
serial and parallel benchmarks.
Add missing dependencies in multicore-numerical
domainsliblibrary has been added to the dune file for the
Add manual page for the instrumented runtime
The instrumented runtime
has been merged to OCaml 4.11.0. A manual for the same has been
created and is under review.
A self-describing representation for function closures
The PR provides a way to record the position of the environment for
each entry point for function closures.
Marshaling for the new closure representation
output_valuemarshaler has been updated to use the new closure
representation. There is no change required for the
Introduce type Obj.raw_data and functions Obj.raw_field,
Obj.set_raw_field to manipulate out-of-heap pointers
The PR introduces a type
Obj.bits, and functions
Obj.set_field_bitsto read and write bit representation of
block fields to support the no-naked-pointer operation.
Reimplement Obj.reachable_word using a hash table to detect sharing
caml_obj_reachable_wordsnow uses a hash table instead of
modifying the mark bits of block headers to detect sharing. This is
required for compatibility with Multicore OCaml.
Naked pointers and the bytecode interpreter
The bytecode interpreter implementation is updated to support the
no-naked-pointers mode operation as required by Multicore OCaml.
Signal handling in native code without the page table
The patch uses the code fragment table instead of a page table
lookup for signal handlers to know whether the signal came from
globroots.c: adapt to no-naked-pointers mode
The patch considers out-of-heap pointers as major-heap pointers in
no-naked-pointers mode for global roots management.
Generic hashing for the new closure representation
The hashing functions have been updated to use the latest closure
ocaml/ocaml#9619 for the
The end of the page table is near
The PR eliminates some of the use of the page tables in the runtime
system when built with no-naked-pointers mode.
Our thanks to all the OCaml developers and users in the community for
their continued support and contribution to the project. Stay safe!
- API: Application Programming Interface
- CFI: Call Frame Information
- CI: Continuous Integration
- DWARF: Debugging With Attributed Record Formats
- GC: Garbage Collector
- ICFP: International Conference on Functional Programming
- OPAM: OCaml Package Manager
- PR: Pull Request
- RFC: Request for Comments