Threading Perl with TBB - a white paper and CPAN module (threads::tbb)
Peter Lobsinger
plobsing at gmail.com
Mon May 9 20:46:50 UTC 2011
On Mon, May 9, 2011 at 12:30 PM, Sam Vilain <sam at vilain.net> wrote:
> 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
> _______________________________________________
> http://lists.parrot.org/mailman/listinfo/parrot-dev
>
Thanks for this, Sam.
My take is that this shows that a thread-safe interpreter which leaves
user-visible parallelism to external libraries is a viable concept.
Parrot should make solutions like threads::tbb possible in stead of
focusing on providing a hardcoded core concurrency paradigm.
More information about the parrot-dev
mailing list