[Haskell-cafe] Slow mvar when compiled with threaded
branimir.maksimovic at gmail.com
Wed Jan 8 03:27:55 UTC 2014
On 01/08/2014 04:15 AM, Bob Ippolito wrote:
> On Tuesday, January 7, 2014, Branimir Maksimovic wrote:
> On 01/07/2014 09:39 PM, Bob Ippolito wrote:
> Here's a much simpler implementation for that sort of pattern,
> using channels to fan out work to threads. I added a
> dependency on Criterion because getCPUTime is basically
> useless for this kind of measurement on Mac OS X since it
> doesn't include the time that the process spent waiting on IO:
> Great, thank you very much. You gave me material for learning ;)
> However, my version is significantly faster when compiling without
> With -threaded option, your version is much faster than mine, but
> both are significantly slower
> then compile without -threaded.
> Happy to look into it, I didn't have time today to do benchmarks
> (and Mac OS X is the worst platform to do this kind of testing on
> regardless of language, its network stack is inconsistent at best). I
> need to know more:
> How exactly are you compiling?
ghc-7.6.3 --make -O2 client.hs
> Which OS?
Ubuntu 13.10 with 3.13-rc7 kernel.
> What version of GHC and Haskell Platform?
bmaxa at maxa:~$ apt-cache policy haskell-platform
*** 2013.2.0.0 0
500 http://archive.ubuntu.com/ubuntu/ saucy/universe amd64 Packages
> What is the exact command line you execute it with?
time ./client maxa 5055 1000 100000
> What timings do you get?
with your version:
with my version
that is, of course, without -threaded
> What's the code for the server are you connecting to?
import Network (listenOn,PortID(..))
import Network.Socket (accept,close)
import Control.Concurrent (forkIO)
main = do
n <- getArgs
let nn = (read.head) n :: Int
putStrLn $ "Listening on " ++ show nn
sock <- listenOn $ PortNumber $ fromIntegral nn
serve sock = do
(s,_) <- accept sock
forkIO $ process s
process sock = do
buf <- recv sock 1024
sendAll sock buf
> Loopback, local network, or internet?
loopback. Testing is on same computer.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe