[Haskell-cafe] Joels Time Leak

Joel Reymont joelr1 at gmail.com
Thu Dec 29 08:20:41 EST 2005


There's no mistery here.

Threads take a while to unpickle the large server info packet when  
the gang up on it all together. By adding the MVar you are basically  
installing a door in front of the packet and only letting one thread  
come through.

The end result is that you are pushing the timeout somewhere else as  
threads spend a lot of time queued up and waiting to get through the  

It takes a fraction of a second for a thread to unpickle the server  
info packet. It needs to make a FFI call to ZLib's uncompress and  
that's a blocking call since it's marked unsafe. I think that happens  
rather quickly otherwise alerts would be showing here. What takes  
time is unpickling the packet after it's uncompressed.

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.


On Dec 29, 2005, at 1:02 PM, Adrian Hey wrote:

> I can reproduce the problem (ghc/Linux), but can't explain it. It
> seems very strange that friggin about with an otherwise irrelevant
> (AFAICT) MVar fixes the problem.


More information about the Haskell-Cafe mailing list