Skip to content

Commit 605d60b

Browse files
authored
Merge pull request #6105 from IntersectMBO/bench-simplify
wb | simplify
2 parents c4d1cd9 + 5084c7a commit 605d60b

File tree

231 files changed

+12168
-2682
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

231 files changed

+12168
-2682
lines changed

bench/cardano-profile/data/all-profiles-coay.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34312,7 +34312,9 @@
3431234312
"tracer": true,
3431334313
"tracing_backend": "trace-dispatcher",
3431434314
"utxo_lmdb": false,
34315-
"verbatim": {}
34315+
"verbatim": {
34316+
"EnableP2P": true
34317+
}
3431634318
},
3431734319
"overlay": {},
3431834320
"scenario": "fixed-loaded",

bench/cardano-profile/src/Cardano/Benchmarking/Profile/Builtin/ForgeStress.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ profilesNoEraForgeStress =
7171
-- 3 nodes versions (non-pre)
7272
, fs & P.name "forge-stress" . V.valueLocal . n3 . V.datasetCurrent . durationM . P.traceForwardingOn . P.analysisUnitary
7373
, fs & P.name "forge-stress-notracer" . V.valueLocal . n3 . V.datasetCurrent . durationM . P.traceForwardingOff . P.analysisUnitary
74-
-- TODO: FIXME: "forge-stress-p2p" has no P2P enabled and Plutus TPS!!!!
75-
, fs & P.name "forge-stress-p2p" . V.plutusLoop . n3 . V.datasetCurrent . durationM . P.traceForwardingOn . P.analysisSizeSmall
74+
, fs & P.name "forge-stress-p2p" . P.p2pOn . V.plutusLoop . n3 . V.datasetCurrent . durationM . P.traceForwardingOn . P.analysisSizeSmall
7675
, fs & P.name "forge-stress-plutus" . V.plutusLoop . n3 . V.datasetCurrent . durationM . P.traceForwardingOn . P.analysisSizeSmall
7776
-- -large: voltaire variant, double nodes and double runtime. This needs >64GB RAM.
7877
, fs & P.name "forge-stress-large" . V.valueLocal . v6 . V.datasetCurrent . durationXL . P.traceForwardingOn

bench/cardano-topology/app/cardano-topology.hs

Lines changed: 184 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE OverloadedStrings #-}
12
{-# LANGUAGE LambdaCase #-}
23
{-# LANGUAGE RecordWildCards #-}
34
{-# LANGUAGE TupleSections #-}
@@ -11,32 +12,59 @@
1112
import Prelude hiding (id)
1213

1314
import qualified Data.Aeson as Aeson
14-
import qualified Data.ByteString.Lazy.Char8 as LBS
15+
-- Package: bytestring.
16+
import qualified Data.ByteString.Lazy.Char8 as BSL8
1517
import qualified Data.GraphViz as G
1618
import qualified Data.GraphViz.Attributes.Complete as G
1719
import qualified Data.GraphViz.Printing as G
1820
import qualified Data.Text.Lazy.IO as T
1921
import Options.Applicative
2022

2123
import qualified Cardano.Benchmarking.Topology as Topo
24+
import qualified Cardano.Benchmarking.Topology.Projection as Projection
25+
26+
--------------------------------------------------------------------------------
27+
28+
data Cli =
29+
Make (Topo.CoreNodesParams, FilePath, Maybe FilePath, Bool)
30+
| ProjectionFor FilePath ProjectionFor
31+
32+
data ProjectionFor =
33+
-- Node i, base port, p2p on or off.
34+
BFT Int Int Bool
35+
| Pool Int Int Bool
36+
-- Nodes indices, base port.
37+
| Explorer Int Int
38+
| ChaindbServer
39+
| Proxy
40+
deriving Show
2241

2342
--------------------------------------------------------------------------------
2443

2544
main :: IO ()
2645
main = do
27-
(coreNodesParams, topoJson, topoDot, withExplorer) <- execParser cliOpts
28-
let cores = Topo.mkCoreNodes coreNodesParams
29-
relays = [
30-
Topo.mkExplorer (Topo.AWS Topo.EU_CENTRAL_1) cores
31-
| withExplorer
32-
]
33-
writeTopo cores relays topoJson
34-
maybe (pure ()) (writeDot cores) topoDot
46+
cli <- getOpts
47+
case cli of
48+
Make (coreNodesParams, topoJson, topoDot, withExplorer) -> do
49+
let cores = Topo.mkCoreNodes coreNodesParams
50+
let relays = [
51+
Topo.mkExplorer (Topo.AWS Topo.EU_CENTRAL_1) cores
52+
| withExplorer
53+
]
54+
writeTopo cores relays topoJson
55+
maybe (pure ()) (writeDot cores) topoDot
56+
(ProjectionFor topologyPath projectionFor) -> do
57+
eitherTopology <- Aeson.eitherDecodeFileStrict topologyPath
58+
let topology = case eitherTopology of
59+
(Left errorMsg) ->
60+
error $ "Not a valid topology: " ++ errorMsg
61+
(Right value) -> value
62+
writeProjectionFor topology projectionFor
3563

3664
--------------------------------------------------------------------------------
3765

3866
-- | Locations from the CLI are parsed first using the "legacy mode" for
39-
-- backward compatiblity, in this mode locations have a default AWS region that
67+
-- backward compatibility, in this mode locations have a default AWS region that
4068
-- are the ones cardano-ops is using. The new format is either "loopback" or a
4169
-- supported AWS Region.
4270
cliLocation :: String -> Either String Topo.Location
@@ -49,32 +77,48 @@ cliLocation = \case
4977
-- New format.
5078
str -> Aeson.eitherDecode
5179
-- Make the string JSON valid by enclosing it with quotes.
52-
(LBS.pack $ "\"" ++ str ++ "\"")
53-
54-
55-
cliOpts :: ParserInfo (Topo.CoreNodesParams, FilePath, Maybe FilePath, Bool)
56-
cliOpts = info (cliParser <**> helper)
57-
( fullDesc
58-
<> progDesc "Cardano topology generator"
59-
<> header "make-topology - generate Cardano node topologies" )
60-
where
61-
cliParser :: Parser (Topo.CoreNodesParams, FilePath, Maybe FilePath, Bool)
62-
cliParser =
63-
(,,,)
64-
<$> subparser coreNodesParamsParser
65-
<*> strOption
66-
( long "topology-output"
67-
<> help "Topology file to write"
68-
<> metavar "OUTFILE" )
69-
<*> optional
70-
(strOption
71-
( long "dot-output"
72-
<> help "Dot file to write"
73-
<> metavar "OUTFILE" ))
74-
<*> flag False True
75-
( long "with-explorer"
76-
<> help "Add an explorer to the topology")
80+
(BSL8.pack $ "\"" ++ str ++ "\"")
7781

82+
getOpts :: IO Cli
83+
getOpts = execParser $ info
84+
(
85+
hsubparser
86+
(
87+
command "make"
88+
(info
89+
(Make <$> cliParserMake)
90+
( fullDesc
91+
<> header "make"
92+
<> progDesc "Create a cluster topology"
93+
)
94+
)
95+
<>
96+
command "projection-for"
97+
(info
98+
( ProjectionFor
99+
<$> strOption
100+
( long "topology-input"
101+
<> help "Topology file"
102+
<> metavar "INPUTFILE"
103+
)
104+
<*> cliParserProjection
105+
)
106+
( fullDesc
107+
<> header "projection-for"
108+
<> progDesc "Create an individual topology"
109+
)
110+
)
111+
)
112+
<**> helper
113+
)
114+
( fullDesc
115+
<> progDesc "Cardano topology generation for Performance & Tracing"
116+
<> header "Cardano node topologies tool"
117+
)
118+
119+
cliParserMake :: Parser (Topo.CoreNodesParams, FilePath, Maybe FilePath, Bool)
120+
cliParserMake =
121+
let
78122
coreNodesParamsParser =
79123
command "line"
80124
(info
@@ -141,6 +185,92 @@ cliOpts = info (cliParser <**> helper)
141185
then Nothing -- The BFT node has no pools
142186
else Just 1 -- Dense pools are denoted by any amount >1
143187
_ -> Just 2
188+
in
189+
(,,,)
190+
<$> subparser coreNodesParamsParser
191+
<*> strOption
192+
( long "topology-output"
193+
<> help "Topology file to write"
194+
<> metavar "OUTFILE"
195+
)
196+
<*> optional
197+
(strOption
198+
( long "dot-output"
199+
<> help "Dot file to write"
200+
<> metavar "OUTFILE" ))
201+
<*> flag False True
202+
( long "with-explorer"
203+
<> help "Add an explorer to the topology")
204+
205+
cliParserProjection :: Parser ProjectionFor
206+
cliParserProjection =
207+
let
208+
parseBasePort =
209+
option auto
210+
( long "baseport"
211+
<> metavar "BASEPORT"
212+
<> help "Base port"
213+
)
214+
parseNodeNumber =
215+
option auto
216+
( long "node-number"
217+
<> short 'i'
218+
<> metavar "NODENUMBER"
219+
<> help "Base port"
220+
)
221+
parseEnableP2P =
222+
flag False True
223+
( long "enable-p2p"
224+
<> help "Create a P2P topology"
225+
)
226+
parseSrcIndices =
227+
option auto
228+
( long "nodes"
229+
<> metavar "NODES"
230+
<> help "Create a non-P2P topology with nodes [0..(NODES-1)]"
231+
)
232+
233+
in subparser $
234+
command "bft"
235+
(info
236+
(BFT <$> parseNodeNumber <*> parseBasePort <*> parseEnableP2P)
237+
( progDesc "BFT"
238+
<> fullDesc
239+
<> header "Generate the topology file for a BFT node"
240+
)
241+
)
242+
<> command "pool"
243+
(info
244+
(Pool <$> parseNodeNumber <*> parseBasePort <*> parseEnableP2P)
245+
( progDesc "Pool"
246+
<> fullDesc
247+
<> header "Generate the topology file for a pool node"
248+
)
249+
)
250+
<> command "explorer"
251+
(info
252+
(Explorer <$> parseSrcIndices <*> parseBasePort)
253+
( progDesc "Explorer"
254+
<> fullDesc
255+
<> header "Generate the topology file for an explorer node"
256+
)
257+
)
258+
<> command "chaindb-server"
259+
(info
260+
(pure ChaindbServer)
261+
( progDesc "ChainDB Server"
262+
<> fullDesc
263+
<> header "Generate the topology file for a ChainDB server node"
264+
)
265+
)
266+
<> command "proxy"
267+
(info
268+
(pure Proxy)
269+
( progDesc "Proxy"
270+
<> fullDesc
271+
<> header "Generate the topology file for a proxy node"
272+
)
273+
)
144274

145275
--------------------------------------------------------------------------------
146276

@@ -195,3 +325,22 @@ locationColor = \case
195325
(Topo.AWS Topo.US_EAST_1) -> G.RGB 200 250 200
196326
(Topo.AWS Topo.US_EAST_2) -> G.RGB 200 250 200
197327
Topo.Loopback -> G.RGB 200 200 250
328+
329+
--------------------------------------------------------------------------------
330+
331+
writeProjectionFor :: Topo.Topology -> ProjectionFor -> IO ()
332+
writeProjectionFor topology projectionFor = do
333+
BSL8.putStrLn $ writeProjectionFor' topology projectionFor
334+
335+
writeProjectionFor' :: Topo.Topology -> ProjectionFor -> BSL8.ByteString
336+
writeProjectionFor' topology (BFT i basePort p2pEnabled) = writeProjectionForProducer topology i basePort p2pEnabled
337+
writeProjectionFor' topology (Pool i basePort p2pEnabled) = writeProjectionForProducer topology i basePort p2pEnabled
338+
writeProjectionFor' _ (Explorer srcIndices basePort) = Aeson.encode $ Projection.projectionExplorer srcIndices basePort
339+
writeProjectionFor' topology ChaindbServer = Aeson.encode $ Projection.projectionChainDB topology
340+
writeProjectionFor' _ Proxy = error "Nodes of kind \"proxy\" are not supported, Nix handles this case!"
341+
342+
writeProjectionForProducer :: Topo.Topology -> Int -> Int -> Bool -> BSL8.ByteString
343+
writeProjectionForProducer topology i basePort enableP2P =
344+
if enableP2P
345+
then Aeson.encode $ Projection.projectionP2P topology i basePort
346+
else Aeson.encode $ Projection.projection topology i basePort

bench/cardano-topology/cardano-topology.cabal

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,25 @@ license: Apache-2.0
1313
license-files: LICENSE
1414
NOTICE
1515
build-type: Simple
16-
data-files: data/bench-torus-52.json
17-
data/bench-torus-dense-52.json
18-
data/ci-test-nomadcwqa.json
19-
data/ci-test-nomadperf.json
20-
data/ci-test.json
21-
data/default-nomadcwqa.json
22-
data/default-nomadperf.json
23-
data/default.json
16+
data-files: data/test/10-coay/*.json
17+
data/test/6-dense-coay/*.json
18+
data/test/chainsync-early-alonzo-coay/*.json
19+
data/test/ci-test-coay/*.json
20+
data/test/ci-test-dense10-coay/*.json
21+
data/test/ci-test-nomadperf-coay/*.json
22+
data/test/ci-test-nomadperf-nop2p-coay/*.json
23+
data/test/ci-test-p2p-coay/*.json
24+
data/test/default-coay/*.json
25+
data/test/default-nomadperf-coay/*.json
26+
data/test/default-nomadperf-nop2p-coay/*.json
27+
data/test/default-p2p-coay/*.json
28+
data/test/fast-solo-coay/*.json
29+
data/test/forge-stress-coay/*.json
30+
data/test/forge-stress-p2p-coay/*.json
31+
data/test/model-value-coay/*.json
32+
data/test/trace-bench-coay/*.json
33+
data/test/value-nomadperf-nop2p-coay/*.json
34+
data/test/value-volt-nomadperf-coay/*.json
2435

2536
common project-config
2637
build-depends: base >= 4.14 && < 5
@@ -39,11 +50,15 @@ library
3950
import: project-config
4051
hs-source-dirs: src
4152
exposed-modules: Cardano.Benchmarking.Topology
53+
, Cardano.Benchmarking.Topology.Projection
4254
, Cardano.Benchmarking.Topology.Types
4355
build-depends: base >=4.12 && <5
4456
, aeson
4557
, bytestring
4658
, text
59+
, network
60+
, iproute
61+
, dns
4762

4863
executable cardano-topology
4964
import: project-config
@@ -66,7 +81,8 @@ test-suite cardano-topology-test
6681
hs-source-dirs: test/
6782
main-is: Main.hs
6883
type: exitcode-stdio-1.0
69-
other-modules: Paths_cardano_topology
84+
other-modules: Cardano.Benchmarking.Topology.Projection.Tests
85+
, Paths_cardano_topology
7086
autogen-modules: Paths_cardano_topology
7187
build-depends: base
7288
, aeson
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Producers": [
3+
{
4+
"addr": "127.0.0.1",
5+
"port": 30001,
6+
"valency": 1
7+
}
8+
]
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Producers": [
3+
{
4+
"addr": "127.0.0.1",
5+
"port": 30002,
6+
"valency": 1
7+
}
8+
]
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Producers": [
3+
{
4+
"addr": "127.0.0.1",
5+
"port": 30003,
6+
"valency": 1
7+
}
8+
]
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Producers": [
3+
{
4+
"addr": "127.0.0.1",
5+
"port": 30004,
6+
"valency": 1
7+
}
8+
]
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Producers": [
3+
{
4+
"addr": "127.0.0.1",
5+
"port": 30005,
6+
"valency": 1
7+
}
8+
]
9+
}

0 commit comments

Comments
 (0)