Channels, Concurrency, and Cores: A new Concurrent ML implementation
What kinds of communication facilities should a programming environment support in highly concurrent systems? In the last decade or so, systems inspired by Communicating Sequential Processes (CSP) have gained a lot of mindshare from Go to Clojure’s core.async and beyond. But most these CSP-inspired systems miss some of the defining characteristics of CSP, notably the notion of choice around a rendezvous. These languages’ "select" primitive is too low-level to build abstractions around communication; it’s as if you can only communicate via the equivalent of "goto" instead of procedure call. There is a better way. Twenty years ago, Concurrent ML solved this problem comprehensively. Its "event" system has been since ported to many other systems, but has seen limited success when also scaling to multi-core environments. There was a "parallel CML" implemented in Manticore but one rarely hears reports of porting to other systems. This talk presents a port of multicore CML to Guile Scheme’s "Fibers" library, a lightweight threading facility supporting I/O concurrency and multicore parallelism. Guile’s implementation of CML is lockless, enabling near-linear scaling as more cores are made available to the system. Guile’s CML implementation is also built entirely as a library, in terms of delimited rather than undelimited continuations. We present performance numbers and an experience report for this new application of CML in the wild.