"Kilim is a message-passing framwork for Java that provides
ultra-lightweight threads and facilities for fast, safe, zero-copy
messaging between these threads.
It consists of a bytecode postprocessor (a "weaver"), a run time
library with buffered mailboxes (multi-producer, single consumer
queues) and a user-level scheduler and a type system that puts certain
constraints on pointer aliasing within messages to ensure
interference-freedom between threads."
or, to really whet your appetite
"Abstract. This paper demonstrates an architecture for suspending and resuming
methods in Java using a restricted form of continuation passing style (CPS)
transformation. It describes Kilim1, a toolkit to portably weave threads of
control called Fibers, through Java code. The chief contributions of this paper
are the set of design choices made for both space and time efficiency
in getting
one-shot continuations to work on the JVM (in some cases, 60x faster than
competing approaches) and to address some tough issues traditionally passed
over by others, such as handling of local subroutines and constructors. We are
able to support hundreds of thousands of threads of control with switching
times of the order of 3 to 4 μs on a low-powered laptop with Sun's JVM."
In the one paper I've had time to read through, there are comparisons
with JavaFlow, RIFE, PicoThreads, among others.
There's code to download, a couple of papers linked on the page near
the bottom, as well as a link to a talk presented at Google and
available online. The paper I had time to read is very well-written to
boot.
Am bcc'ing the project's mailing list.
Regards
Patrick
I wonder if it isn't time to reconsider an m:n threading model for JVM.
Seems like there's demand for it, and while these hacks are clever they
don't scale across the whole of third-party and core Java libraries a
typical app is going to encounter. Enlisting the JVM in microthreading
directly seems like it would be the best long-term approach.
- Charlie
Well, my thinking here is that what we as JVM language developers would
like to just generate Plain Old JVM Bytecode and not have to think about
the threading of that code at execution time. So if it actually ends up
mapping N JVM threads to 1 kernel thread, so be it.
So what I want is to be able to answer all the Erlang folks with their
tens of thousands of processes by being able to spin up tens of
thousands of threads. Of course I understand the complexity of this,
given that e.g. hotspot wants to be able to inline a bunch of code down
to a single piece of native code...wants to be able to overload the C
stack to avoid allocating its own stack primitives...and so on. So this
isn't something that would happen tomorrow, obviously, but it certainly
deserves some consideration, yeah?
- Charlie