git.iko.soy/distributed-process
on master help sign in
Cleanup. Relax upper bound on network.
a307db2Edsko de Vries
distributed-process/benchmarks/Throughput.hs+9−12
@@ -21,7 +21,7 @@ instance Binary a => Binary (SizedList a) where
21
21
22-- Copied from Data.Binary
22-- Copied from Data.Binary
23getMany :: Binary a => Int -> Get [a]
23getMany :: Binary a => Int -> Get [a]
24−getMany n = go [] n
24+getMany = go []
25 where
25 where
26 go xs 0 = return $! reverse xs
26 go xs 0 = return $! reverse xs
27 go xs i = do x <- get
27 go xs i = do x <- get
@@ -38,22 +38,19 @@ counter :: Process ()
38counter = go 0
38counter = go 0
39 where
39 where
40 go :: Int -> Process ()
40 go :: Int -> Process ()
41− go !n = do
41+ go !n =
42− msg <- receiveWait
42+ receiveWait
43− [ match $ \xs -> return . Left . size $ (xs :: SizedList Int)
43+ [ match $ \xs -> go (n + size (xs :: SizedList Int))
44− , match $ \them -> return . Right $ them
44+ , match $ \them -> send them n >> go 0
45 ]
45 ]
46− case msg of
47− Left n' -> go (n + n')
48− Right them -> send them n >> go 0
49
46
50count :: (Int, Int) -> ProcessId -> Process ()
47count :: (Int, Int) -> ProcessId -> Process ()
51−count (packets, size) them = do
48+count (packets, sz) them = do
52 us <- getSelfPid
49 us <- getSelfPid
53− replicateM_ packets $ send them (nats size)
50+ replicateM_ packets $ send them (nats sz)
54 send them us
51 send them us
55 n' <- expect
52 n' <- expect
56− liftIO $ print (packets * size, n' == packets * size)
53+ liftIO $ print (packets * sz, n' == packets * sz)
57
54
58initialProcess :: String -> Process ()
55initialProcess :: String -> Process ()
59initialProcess "SERVER" = do
56initialProcess "SERVER" = do
@@ -61,7 +58,7 @@ initialProcess "SERVER" = do
61 liftIO $ BSL.writeFile "counter.pid" (encode us)
58 liftIO $ BSL.writeFile "counter.pid" (encode us)
62 counter
59 counter
63initialProcess "CLIENT" = do
60initialProcess "CLIENT" = do
64− n <- liftIO $ getLine
61+ n <- liftIO getLine
65 them <- liftIO $ decode <$> BSL.readFile "counter.pid"
62 them <- liftIO $ decode <$> BSL.readFile "counter.pid"
66 count (read n) them
63 count (read n) them
67
64
distributed-process/distributed-process.cabal+2−2
@@ -92,7 +92,7 @@ Test-Suite TestCH
92 network-transport >= 0.3 && < 0.4,
92 network-transport >= 0.3 && < 0.4,
93 network-transport-tcp >= 0.3 && < 0.4,
93 network-transport-tcp >= 0.3 && < 0.4,
94 binary >= 0.5 && < 0.6,
94 binary >= 0.5 && < 0.6,
95− network >= 2.3 && < 2.4
95+ network >= 2.3 && < 2.5
96 Other-modules: TestAuxiliary
96 Other-modules: TestAuxiliary
97 Extensions: CPP,
97 Extensions: CPP,
98 ScopedTypeVariables,
98 ScopedTypeVariables,
@@ -112,7 +112,7 @@ Test-Suite TestClosure
112 network-transport >= 0.3 && < 0.4,
112 network-transport >= 0.3 && < 0.4,
113 network-transport-tcp >= 0.3 && < 0.4,
113 network-transport-tcp >= 0.3 && < 0.4,
114 bytestring >= 0.9 && < 0.11,
114 bytestring >= 0.9 && < 0.11,
115− network >= 2.3 && < 2.4
115+ network >= 2.3 && < 2.5
116 Other-modules: TestAuxiliary
116 Other-modules: TestAuxiliary
117 Extensions: CPP,
117 Extensions: CPP,
118 ScopedTypeVariables
118 ScopedTypeVariables
network-transport-tcp/network-transport-tcp.cabal+2−2
@@ -26,7 +26,7 @@ Library
26 data-accessor >= 0.2 && < 0.3,
26 data-accessor >= 0.2 && < 0.3,
27 containers >= 0.4 && < 0.6,
27 containers >= 0.4 && < 0.6,
28 bytestring >= 0.9 && < 0.11,
28 bytestring >= 0.9 && < 0.11,
29− network >= 2.3 && < 2.4
29+ network >= 2.3 && < 2.5
30 Exposed-modules: Network.Transport.TCP,
30 Exposed-modules: Network.Transport.TCP,
31 Network.Transport.TCP.Internal
31 Network.Transport.TCP.Internal
32 Extensions: CPP
32 Extensions: CPP
@@ -38,7 +38,7 @@ Test-Suite TestTCP
38 Main-Is: TestTCP.hs
38 Main-Is: TestTCP.hs
39 Build-Depends: base >= 4.3 && < 5,
39 Build-Depends: base >= 4.3 && < 5,
40 network-transport-tests >= 0.1 && < 0.2,
40 network-transport-tests >= 0.1 && < 0.2,
41− network >= 2.3 && < 2.4,
41+ network >= 2.3 && < 2.5,
42 network-transport >= 0.3 && < 0.4,
42 network-transport >= 0.3 && < 0.4,
43 network-transport-tcp >= 0.3 && < 0.4
43 network-transport-tcp >= 0.3 && < 0.4
44 ghc-options: -threaded -rtsopts -with-rtsopts=-N
44 ghc-options: -threaded -rtsopts -with-rtsopts=-N