About Haskell Thread Model

Wolfgang Thaller wolfgang.thaller at gmx.net
Mon Oct 13 12:13:56 EDT 2003


William Lee Irwin III wrote:

> On Sat, Oct 11, 2003 at 10:58:04PM +0200, Wolfgang Thaller wrote:
>> You should also note that no Haskell implementation currently supports
>> SMP; even when multiple kernel threads are used, there is a mutual
>> exclusion lock on the Haskell heap, so a multithreaded Haskell program
>> will use only one CPU on an SMP system.
>> I hope my answer was useful...
>
> That's a painful-sounding state of affairs, though not entirely
> unexpected. It would be interesting to hear of "BKL breakup" efforts
> for Haskell runtime systems, though anymore I'm totally ignorant of
> what the devil is going on in userspace except database-only syscalls.

I'm not sure I understand you. I found out that "BKL" refers to the 
"Big Kernel Lock" (in the Linux kernel), but I have no idea what 
"database-only syscalls" are.

The reason why we currently do not take advantage of SMP is that the 
Haskell Heap is a shared data structure which is modified whenever a 
thunk (an unevaluated expression) is evaluated. Using synchronisation 
primitives like pthread_mutex_lock for every evaluation of a thunk 
would be deadly for performance.
There is some old (1999) code in the GHC RTS that attempts this (using 
intel cmpxchg instructions for synchronisation), but it's currently 
"bitrotted" and I don't know how successful it was.

Cheers,

Wolfgang



More information about the Haskell mailing list