git.iko.soy/distributed-process
on master help sign in
TCP_NODELAY does not seem to improve things
commitec9029f696a7defcafe0025c5ac23e497740525d authorEdsko de Vries <edsko@edsko.net> dateMon 16 Apr 2012, 09:16 (15 years ago) parenta366d5e
3 files changed+13−5
benchmarks/Indirection.gnuplot+2 benchmarks/JustPingTwoSocketPairs.hs+7−5 benchmarks/Makefile.JustPing+4
benchmarks/Indirection.gnuplot+2
@@ -4,6 +4,7 @@ plot "JustPingWithHeader.data" smooth bezier with lines title "JustPingWithHeade
44 "JustPingThroughChan.data" smooth bezier with lines title "JustPingThroughChan", \
55 "JustPingThroughMVar.data" smooth bezier with lines title "JustPingThroughMVar", \
66 "JustPingTwoSocketPairs.data" smooth bezier with lines title "JustPingTwoSocketPairs", \
7+ "JustPingTwoSocketPairsND.data" smooth bezier with lines title "JustPingTwoSocketPairs (--NoDelay)", \
78 "JustPingTransport.data" smooth bezier with lines title "JustPingTransport"
89set terminal postscript color
910set output "Indirection.ps"
@@ -11,4 +12,5 @@ plot "JustPingWithHeader.data" smooth bezier with lines title "JustPingWithHeade
1112 "JustPingThroughChan.data" smooth bezier with lines title "JustPingThroughChan", \
1213 "JustPingThroughMVar.data" smooth bezier with lines title "JustPingThroughMVar", \
1314 "JustPingTwoSocketPairs.data" smooth bezier with lines title "JustPingTwoSocketPairs", \
15+ "JustPingTwoSocketPairsND.data" smooth bezier with lines title "JustPingTwoSocketPairs (--NoDelay)", \
1416 "JustPingTransport.data" smooth bezier with lines title "JustPingTransport"
benchmarks/JustPingTwoSocketPairs.hs+7−5
@@ -7,7 +7,7 @@ import Control.Monad
77import Data.Int
88import Network.Socket
99 ( AddrInfo, AddrInfoFlag (AI_PASSIVE), HostName, ServiceName, Socket
10− , SocketType (Stream), SocketOption (ReuseAddr)
10+ , SocketType (Stream), SocketOption (ReuseAddr, NoDelay)
1111 , accept, addrAddress, addrFlags, addrFamily, bindSocket, defaultProtocol
1212 , defaultHints
1313 , getAddrInfo, listen, setSocketOption, socket, sClose, withSocketsDo )
@@ -36,10 +36,10 @@ passive :: Maybe AddrInfo
3636passive = Just (defaultHints { addrFlags = [AI_PASSIVE] })
3737
3838main = do
39− [pingsStr] <- getArgs
40− serverReady <- newEmptyMVar
41− clientReady <- newEmptyMVar
42− clientDone <- newEmptyMVar
39+ pingsStr:args <- getArgs
40+ serverReady <- newEmptyMVar
41+ clientReady <- newEmptyMVar
42+ clientDone <- newEmptyMVar
4343
4444 -- Start the server
4545 forkIO $ do
@@ -59,6 +59,7 @@ main = do
5959 clientAddr:_ <- getAddrInfo Nothing (Just "127.0.0.1") (Just "8081")
6060 pongSock <- socket (addrFamily clientAddr) Stream defaultProtocol
6161 N.connect pongSock (addrAddress clientAddr)
62+ when ("--NoDelay" `elem` args) $ setSocketOption pongSock NoDelay 1
6263 forever $ readChan multiplexChannel >>= send pongSock
6364
6465 -- Wait for incoming connections (pings from the client)
@@ -83,6 +84,7 @@ main = do
8384 serverAddr:_ <- getAddrInfo Nothing (Just "127.0.0.1") (Just "8080")
8485 pingSock <- socket (addrFamily serverAddr) Stream defaultProtocol
8586 N.connect pingSock (addrAddress serverAddr)
87+ when ("--NoDelay" `elem` args) $ setSocketOption pingSock NoDelay 1
8688 ping pingSock multiplexChannel (read pingsStr)
8789 putMVar clientDone ()
8890
benchmarks/Makefile.JustPing+4
@@ -7,6 +7,7 @@ Indirection.ps: JustPingWithHeader.data \
77 JustPingThroughChan.data \
88 JustPingThroughMVar.data \
99 JustPingTwoSocketPairs.data \
10+ JustPingTwoSocketPairsND.data \
1011 JustPingTransport.data
1112 gnuplot ./Indirection.gnuplot
1213
@@ -24,6 +25,9 @@ JustPingC.exe: JustPingC.c
2425JustPingHaskellNT.exe: JustPingHaskell.hs
2526 ghc -o JustPingHaskellNT.exe -O2 JustPingHaskell.hs
2627
28+JustPingTwoSocketPairsND.data: JustPingTwoSocketPairs.exe
29+ time ./$< $(NUMPINGS) --NoDelay 2>$@
30+
2731%.data : %.exe
2832 time ./$< $(NUMPINGS) 2>$@
2933