Welcome to Loom!

Ron Pressler ron.pressler at oracle.com
Wed Jan 17 11:36:49 UTC 2018

Welcome to Project Loom!

The goal of this project is to add lightweight threads — AKA fibers — to the JVM, delimited continuations/coroutines (on top of which fibers would be implemented, and which would probably be exposed as a low-level public API as well), and possibly explicit tail-calls.

Before posting questions or joining discussions, I would kindly ask everyone to first read the project’s proposal, which outlines the project’s scope and introduces the motivation and technical challenges.

For the moment, here are some of the technical options we’ve been discussing:

1. Fibers would be implemented in pure Java on top of coroutines/continuations (the two names — where continuations are a shorthand for delimited continuations — will be used interchangeably despite slight technical differences between them) and ForkJoinPool.

2. Our main technical goal is to make fibers lightweight both in terms of task-switching efficiency and RAM overhead, as we’d like to support hundreds of thousands, and even millions of them in a single JVM instance, and to make the changes to HotSpot as non-disruptive as possible. To that effect, we would need to store VM-managed continuation stacks separately from thread stacks. We’re considering two options: 1/ storing coroutine stacks on the Java heap (in Java arrays) — they would then be called horizontal-stacks, or h-stacks, to distinguish them from ordinary kernel/heavyweight-thread stacks, which would be called vertical stacks or v-stacks. 2/ storing continuation stacks on the C heap in what we’d call stacklets. Option 1 (h-stacks) would probably be more lightweight, but stacklets may (or may not) be easier to implement. Either solution would not require copying continuation stacks back and forth between their storage and the ordinary thread stacks, but a quick proof-of-concept implementation that does employ stack copying is being worked on.

Some further nomenclature: when a continuation is being ‘entered' — run for the first time or ‘continued' after it’s been ‘yielded' — would entail ‘mounting' it on the thread stack (this does not imply copying it). Yielding a coroutine would entail ‘unmounting’ its stack.


More information about the loom-dev mailing list