Question

My question is about the garbage collector in the Parrot Virtual Machine ( http://www.parrot.org ).

Is it multi-threaded?

Was it helpful?

Solution

Parrot itself is multi-threaded, it even scales linearily up to the available physical CPU cores, and it's GC supports multiple threads properly, i.e. without any locks on data structures (which is BTW a major benefit over the MoarVM or JVM backends which use tradional locks on hashes, PMC's and arrays all over), but the GC itself does not run in seperate threads. The GC only runs in the master thread and is a simple Mark&Sweep (i.e. "stop the world") tri-color generational GC.

The GC threads design overview is described here: http://perl6advent.wordpress.com/2012/12/11/day-11-parrot-threads/ and in detail by the implementor here: http://niner.name/Hybrid_Threads_for_the_Parrot_VM.pdf

But note that parrot only supports threads (i.e. tasks) being created from the master interpreter, not from other tasks (threads), the threadpool is pre-initialized at startup and managed automatically. Only the owner may write data via prioritized scheduled little proxy-writer tasks. Technically you may create tasks from other tasks, but it will cause leaks.

To other threads non-atomic data is visible via read-only proxy objects. The high-level language compiler needs to create these writer tasks for you. See the examples/threads/ directory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top