RE: About Haskell Thread Model
On Mon, Oct 13, 2003 at 11:13:56AM +0200, Wolfgang Thaller wrote:
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.
cmpxchg and then taking a blocking lock sounds like the 2-tier locking supported with Linux' new futex system calls. I wonder how they chose to block in the older GHC RTS.
It was a spinlock. There was also an attempt to avoid having to lock every thunk entry and update by partitioning the allocation area per-thread, taking advantage of the fact that most thunk entries and updates are to objects created recently by the current thread. This is about where the experiment stalled - it was interesting, but even if the heap partitioning turned out to be effective, the gains weren't really going to be there without tackling multithreaded GC too (as Jan-Willem already pointed out). Cheers, Simon
participants (1)
-
Simon Marlow