[Haskell-cafe] Killer pickler combinators (was Time leak)

Branimir Maksimovic bmaxa at hotmail.com
Wed Dec 21 09:33:24 EST 2005

>From: Joel Reymont <joelr1 at gmail.com>
>To: Haskell-Cafe Cafe <haskell-cafe at haskell.org>
>Subject: [Haskell-cafe] Killer pickler combinators (was Time leak)
>Date: Wed, 21 Dec 2005 02:39:43 +0000
>The original paper is at http://research.microsoft.com/ ~akenn/fun/ 
>My adaptation is at http://wagerlabs.com/timeleak.tgz. This is a full  
>repro case, data included.
>The issue is that with 1000 threads my serialization is taking a few  
>Inserting a delay or passing in trace (see README and code) gets  
>serialization time down to 0-1s, the way it should be.
>What gives? Try it for yourself and please let me know!

This has easy explanation. I am learning haskell and your programs are great
of that.
In this code:
    do TOD time1 _ <- getClockTime
       (kind, ix1) <- unpickle puCmdType ptr ix
       TOD time2 _ <- getClockTime
       (cmd', _) <- unpickle (puCommand kind) ptr ix1
       TOD time3 _ <- getClockTime
you get time multiple times.
So if you lock whole operation nothing else will be executed
while in this code and therefore you don;t have timeouts.
But, without lock more threads you have, more time have to wait
for operation to finish and therefore timeouts.
Since I see that Haskell executes all this in single thread, lock
just ensures that your operasion will not be interrupted, thereferore
not time outs. But if you measure say 5000 reads cumulative time,
you'll get same problem again.
Let's say you have more then one worker thread and multiple
CPU's. Only then situation will be better. Perhaps you'll get
somewhat better perfromance with OS context switch, but
not to avail, it is humpered with same problem. You need
more CPU-s and worker threads in order to service such large number
of tasks. Just measure how much requests can be serviced
in reasonable time and limit on that. For single cpu lock
will be ok, but for multiple CPU's you have to somehow say Haskell to spawn
multiple workers (more then one). I would be glad to know
how to tell run time to use more then one worker thread.

Greetings, Bane.

>	Thanks, Joel
>Haskell-Cafe mailing list
>Haskell-Cafe at haskell.org

Express yourself instantly with MSN Messenger! Download today it's FREE! 

More information about the Haskell-Cafe mailing list