Time to reconsider m:n or green threading options?
John.Rose at Sun.COM
Mon Jun 23 14:11:40 PDT 2008
On Jun 21, 2008, at 3:18 AM, Patrick Wright wrote:
> Big drawback appears to have
> been a) blocking I/O could cause the whole VM to wait and b) there's
> only 1 OS thread underneath, meaning no use of multiple processors.
Yep, those are the reasons. The transition away from green threads
occupied a year or two of my early career on the JVM. It was
necessary and most unpleasant; some of the worst bugs I've ever seen.
Both kernel threads and green threads are designed around the idea
that you get a rich virtual processor with all the OS trimmings and
stack space for as many stack frames as you are ever likely to need.
This is inherently expensive to instantiate. You want the JVM to be
able to pass control between unrelated actors without completely
switching out the whole register file, etc.
It would be great if we had really lightweight continuations, with a
JVM scheduler (Scheme calls them engines, I think) which keeps
running the next one. The part I can't see yet is how to make stack-
based and heap-based activation records play together efficiently.
(Maybe you JIT two versions of every method, with inlining to remove
overheads as usual?)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the mlvm-dev