[Haskell-cafe] Re: Joels Time Leak
Chris Kuklewicz
haskell at list.mightyreason.com
Tue Jan 3 10:40:48 EST 2006
General follow-up questions:
Would adding Control.Concurrent.yield commands cause a context switch
more often than every 0.02 seconds?
Is there any command in GHC to allow a thread to prevent itself from
being rescheduled while computing something?
Another comment: between 1000's of threads and writing a custom
continuation based scheduler, what about using a thread pool? Does
anyone have a library with a "fork-IO-Pool" command?
--
Chris
Simon Marlow wrote:
> Tomasz Zielonka wrote:
>
>> On Thu, Dec 29, 2005 at 01:20:41PM +0000, Joel Reymont wrote:
>>
>>> Why does it take a fraction of a second for 1 thread to unpickle and
>>> several seconds per thread for several threads to do it at the same
>>> time? I think this is where the mistery lies.
>>
>>
>>
>> Have you considered any of this:
>>
>> - too big memory pressure: more memory means more frequent and more
>> expensive GCs, 1000 threads using so much memory means bad cache
>> performance
>> - a deficiency of GHC's thread scheduler - giving too much time one
>> thread steals it from others (Simons, don't get angry at me - I am
>> probably wrong here ;-)
>
>
> I don't think there's anything really strange going on here.
>
> The default context switch interval in GHC is 0.02 seconds, measured in
> CPU time by default. GHC's scheduler is stricly round-robin, so
> therefore with 100 threads in the system it can be 2 seconds between a
> thread being descheduled and scheduled again.
>
> I measured the time taken to unpickle those large 50k packets as 0.3
> seconds on my amd64 box (program compiled *without* optimisation), so
> the thread can get descheduled twice during while unpickling a large
> packet, giving a >4s delay with 100 threads running.
>
> The actual context switch interval seems to often be larger than 0.2
> seconds; I'm not sure exactly why this is, it might be due to delays in
> the OS delivering the signal. This does mean that the timeleak program
> reports alerts for as little as 50 threads, though.
>
> Cheers,
> Simon
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
More information about the Haskell-Cafe
mailing list