Threading Perl with TBB - a white paper and CPAN module (threads::tbb)

Sam Vilain sam at vilain.net
Mon May 9 16:30:46 UTC 2011


ABSTRACT:

Perl’s history has seen two threading models; one shared-state model now
dis-
continued, and one heap-duplicating model with a very inefficient shared
state ap-
proach. There is also an Erlang-style threading library on CPAN,
threads::lite,
more efficient and scalable but specific in functionality.

A task-oriented parallelisation approach permits parallel operations on
data sets
as well as pipeline-based programming. threads::tbb, the core invention
of the
paper, uses Intel’s Threading Building Blocks (TBB) along with a system
of lazy
cloning for state, and is shown to result in speed-ups for embarassingly
parallel tasks to 8 processor cores or more.

The results are applicable in principle to other languages which are
built around
boxed variables and state machine interpreters, such as PHP/Zend or standard
Python.

The cloning logic duplicates core Perl 5 code in intent, the API for
which could be
cleaned up to avoid some minor API intrusions. Green fields interpreter
approaches would benefit from a const concept to avoid duplication in
the first place, and for safer operation.

Transformations for task-orientation are similar to those required for
event-
oriented programming, with potential to parallelize event frameworks, or
for APIs
which span the two styles.

Full white paper (once it finishes propagating through CPAN):

http://cpansearch.perl.org/src/SAMV/threads-tbb-0.02/doc/threading-perl-with-tbb.pdf

I have cc'd the parrot list as in conversations with parrot developers,
it was indicated that the findings may be of interest to the parrot
community.

Enjoy and comments welcome,
Sam


More information about the parrot-dev mailing list