git.iko.soy/distributed-process
on master help sign in
TCP_NODELAY does not seem to improve things
ec9029fEdsko de Vries
benchmarks/Indirection.gnuplot+2
@@ -4,6 +4,7 @@ plot "JustPingWithHeader.data" smooth bezier with lines title "JustPingWithHeade
4 "JustPingThroughChan.data" smooth bezier with lines title "JustPingThroughChan", \
4 "JustPingThroughChan.data" smooth bezier with lines title "JustPingThroughChan", \
5 "JustPingThroughMVar.data" smooth bezier with lines title "JustPingThroughMVar", \
5 "JustPingThroughMVar.data" smooth bezier with lines title "JustPingThroughMVar", \
6 "JustPingTwoSocketPairs.data" smooth bezier with lines title "JustPingTwoSocketPairs", \
6 "JustPingTwoSocketPairs.data" smooth bezier with lines title "JustPingTwoSocketPairs", \
7+ "JustPingTwoSocketPairsND.data" smooth bezier with lines title "JustPingTwoSocketPairs (--NoDelay)", \
7 "JustPingTransport.data" smooth bezier with lines title "JustPingTransport"
8 "JustPingTransport.data" smooth bezier with lines title "JustPingTransport"
8set terminal postscript color
9set terminal postscript color
9set output "Indirection.ps"
10set output "Indirection.ps"
@@ -11,4 +12,5 @@ plot "JustPingWithHeader.data" smooth bezier with lines title "JustPingWithHeade
11 "JustPingThroughChan.data" smooth bezier with lines title "JustPingThroughChan", \
12 "JustPingThroughChan.data" smooth bezier with lines title "JustPingThroughChan", \
12 "JustPingThroughMVar.data" smooth bezier with lines title "JustPingThroughMVar", \
13 "JustPingThroughMVar.data" smooth bezier with lines title "JustPingThroughMVar", \
13 "JustPingTwoSocketPairs.data" smooth bezier with lines title "JustPingTwoSocketPairs", \
14 "JustPingTwoSocketPairs.data" smooth bezier with lines title "JustPingTwoSocketPairs", \
15+ "JustPingTwoSocketPairsND.data" smooth bezier with lines title "JustPingTwoSocketPairs (--NoDelay)", \
14 "JustPingTransport.data" smooth bezier with lines title "JustPingTransport"
16 "JustPingTransport.data" smooth bezier with lines title "JustPingTransport"
benchmarks/JustPingTwoSocketPairs.hs+7−5
@@ -7,7 +7,7 @@ import Control.Monad
7import Data.Int
7import Data.Int
8import Network.Socket
8import Network.Socket
9 ( AddrInfo, AddrInfoFlag (AI_PASSIVE), HostName, ServiceName, Socket
9 ( AddrInfo, AddrInfoFlag (AI_PASSIVE), HostName, ServiceName, Socket
10− , SocketType (Stream), SocketOption (ReuseAddr)
10+ , SocketType (Stream), SocketOption (ReuseAddr, NoDelay)
11 , accept, addrAddress, addrFlags, addrFamily, bindSocket, defaultProtocol
11 , accept, addrAddress, addrFlags, addrFamily, bindSocket, defaultProtocol
12 , defaultHints
12 , defaultHints
13 , getAddrInfo, listen, setSocketOption, socket, sClose, withSocketsDo )
13 , getAddrInfo, listen, setSocketOption, socket, sClose, withSocketsDo )
@@ -36,10 +36,10 @@ passive :: Maybe AddrInfo
36passive = Just (defaultHints { addrFlags = [AI_PASSIVE] })
36passive = Just (defaultHints { addrFlags = [AI_PASSIVE] })
37
37
38main = do
38main = do
39− [pingsStr] <- getArgs
39+ pingsStr:args <- getArgs
40− serverReady <- newEmptyMVar
40+ serverReady <- newEmptyMVar
41− clientReady <- newEmptyMVar
41+ clientReady <- newEmptyMVar
42− clientDone <- newEmptyMVar
42+ clientDone <- newEmptyMVar
43
43
44 -- Start the server
44 -- Start the server
45 forkIO $ do
45 forkIO $ do
@@ -59,6 +59,7 @@ main = do
59 clientAddr:_ <- getAddrInfo Nothing (Just "127.0.0.1") (Just "8081")
59 clientAddr:_ <- getAddrInfo Nothing (Just "127.0.0.1") (Just "8081")
60 pongSock <- socket (addrFamily clientAddr) Stream defaultProtocol
60 pongSock <- socket (addrFamily clientAddr) Stream defaultProtocol
61 N.connect pongSock (addrAddress clientAddr)
61 N.connect pongSock (addrAddress clientAddr)
62+ when ("--NoDelay" `elem` args) $ setSocketOption pongSock NoDelay 1
62 forever $ readChan multiplexChannel >>= send pongSock
63 forever $ readChan multiplexChannel >>= send pongSock
63
64
64 -- Wait for incoming connections (pings from the client)
65 -- Wait for incoming connections (pings from the client)
@@ -83,6 +84,7 @@ main = do
83 serverAddr:_ <- getAddrInfo Nothing (Just "127.0.0.1") (Just "8080")
84 serverAddr:_ <- getAddrInfo Nothing (Just "127.0.0.1") (Just "8080")
84 pingSock <- socket (addrFamily serverAddr) Stream defaultProtocol
85 pingSock <- socket (addrFamily serverAddr) Stream defaultProtocol
85 N.connect pingSock (addrAddress serverAddr)
86 N.connect pingSock (addrAddress serverAddr)
87+ when ("--NoDelay" `elem` args) $ setSocketOption pingSock NoDelay 1
86 ping pingSock multiplexChannel (read pingsStr)
88 ping pingSock multiplexChannel (read pingsStr)
87 putMVar clientDone ()
89 putMVar clientDone ()
88
90
benchmarks/Makefile.JustPing+4
@@ -7,6 +7,7 @@ Indirection.ps: JustPingWithHeader.data \
7 JustPingThroughChan.data \
7 JustPingThroughChan.data \
8 JustPingThroughMVar.data \
8 JustPingThroughMVar.data \
9 JustPingTwoSocketPairs.data \
9 JustPingTwoSocketPairs.data \
10+ JustPingTwoSocketPairsND.data \
10 JustPingTransport.data
11 JustPingTransport.data
11 gnuplot ./Indirection.gnuplot
12 gnuplot ./Indirection.gnuplot
12
13
@@ -24,6 +25,9 @@ JustPingC.exe: JustPingC.c
24JustPingHaskellNT.exe: JustPingHaskell.hs
25JustPingHaskellNT.exe: JustPingHaskell.hs
25 ghc -o JustPingHaskellNT.exe -O2 JustPingHaskell.hs
26 ghc -o JustPingHaskellNT.exe -O2 JustPingHaskell.hs
26
27
28+JustPingTwoSocketPairsND.data: JustPingTwoSocketPairs.exe
29+ time ./$< $(NUMPINGS) --NoDelay 2>$@
30+
27%.data : %.exe
31%.data : %.exe
28 time ./$< $(NUMPINGS) 2>$@
32 time ./$< $(NUMPINGS) 2>$@
29
33