FFI: number of worker threads?

Simon Marlow simonmarhaskell at gmail.com
Wed Jun 21 07:37:32 EDT 2006


Li, Peng wrote:

> The paper "Extending the Haskell FFI with Concurrency" mentioned the
> following in Section 6.3:
> 
> "GHC's run-time system employs one OS thread for every bound thread;
> additionally, there is a variable number of so-called "worker" OS
> threads that are used to execute the unbounded (lightweight) threads."
> 
> How does the runtime system determine the number of worker threads?
> Is the number hardcoded in the RTS or dynamically adjustable?  Can a
> programmer specify it as an RTS option or change it using an API?
 >
> I would like to use a large number (say, 2000) of unbounded threads,
> each calling a blocking, safe foreign function via FFI import.  What
> is supposed to happen if all the worker threads are used up?  I tried
> this in the recent GHC 6.5 and got some kind of "runaway worker
> threads?" RTS failure message when more than 32 threads are used. Is
> it a current limitation of the RTS, or should I file a bug report for
> it?

As mentioned by Simon PJ, the number of worker threads grows as needed 
(but doesn't decrease - that would be a useful improvement).

The message you're seeing is due to an arbitrary limit I put on the 
number of workers in order to catch bugs in the runtime before they kill 
the machine.  Perhaps I should remove the limit, or at least make it 
very much larger.

Cheers,
	Simon


More information about the Glasgow-haskell-users mailing list