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

Joel Reymont joelr1 at gmail.com
Wed Dec 21 09:51:42 EST 2005

I'm not sure I buy this. Again, this helps:

{-# NOINLINE lock #-}
lock :: MVar ()
lock = unsafePerformIO $ newMVar ()

trace s = withMVar lock $ const $ putStrLn s

and then in read_

        cmd <- read h trace

trace is called _after_ all the timings in read so it should not  
affect the timings.

You could basically say that the lock is at the end of read, after  
all the unpickling has been done. The other interesting thing is that  
replacing trace with

delay _ = threadDelay 1

does not solve the issue.

On Dec 21, 2005, at 2:33 PM, Branimir Maksimovic wrote:

> 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.


More information about the Haskell-Cafe mailing list