On Wed, Oct 13, 2010 at 12:46 AM, Tim Bunce <tim.bu...@pobox.com> wrote:
> So I'd like to use this sub-thread to try to identify when lessons we
> can learn from ithreads. My initial thoughts are:
> - Don't clone a live interpreter.
> Start a new thread with a fresh interpreter.
> - Don't try to share mutable data or data structures.
> Use message passing and serialization.
Actually, that sounds *exactly* like what I have been trying to
implementing for perl 5 based on ithreads (threads::lite, it's still
in a fairly early state though). My experience with it so far taught
* Serialization must be cheap for this to scale. For threads::lite
this turns out to be the main performance bottleneck. Erlang gets away
with this because it's purely functional and thus doesn't need to
serialize between local threads, maybe we could do something similar
with immutable objects. Here micro-optimizations are going to pay off.
* Code sharing is actually quite nice. Loading Moose separately in a
hundred threads is not. This is not trivial though, Perl being so
dynamic. I suspect this is not possible without running into the same
issues as ithreads does.
* Creating a thread (/interpreter) should be as cheap as possible,
both in CPU-time as in memory. Creating an ithread is relatively
expensive, specially memorywise. You can't realistically create a very
large number of them the way you can in Erlang.
(well actually I learned a lot more; like about non-deterministic unit
tests and profilers that don't like threads, but that's an entirely