[Haskell-cafe] Threads with high CPU usage

Don Stewart dons at galois.com
Sun Dec 21 16:47:40 EST 2008


redcom:
> Hi,
> 
> in an application of mine I start a long-running operation in a thread via  
> forkIO so that the UI process doesn't get blocked.
> It just so happens, that the long-running process also takes the CPU to  
> nearly 100% while it runs.
> 
> During that time the run-time system does *not* switch back and forth  
> between the UI-process and the long-running task, it seems that the UI  
> process only gets woken up *after* the high CPU thread finishes completely.
> 
> To the effect of course that it makes no difference at all to the UIs  
> responsiveness whether I use forkIO or not.
> 
> The long running process is pretty atomic, it's a single query to the  
> database which takes up to a minute to complete so I don't see a chance to  
> squeeze a "mainIteration" in there.
> 

How are you compiling this code (-O -threaded ?) and what does the
forkIO'd thread do? Does it allocate?

Would increasing the runtime scheduling ticks help? (Perhaps , if the UI
is mostly sleeping).

-- Don


More information about the Haskell-Cafe mailing list