Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bench/cardano-profile/data/all-profiles-coay.json
Original file line number Diff line number Diff line change
Expand Up @@ -34312,7 +34312,9 @@
"tracer": true,
"tracing_backend": "trace-dispatcher",
"utxo_lmdb": false,
"verbatim": {}
"verbatim": {
"EnableP2P": true
}
},
"overlay": {},
"scenario": "fixed-loaded",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ profilesNoEraForgeStress =
-- 3 nodes versions (non-pre)
, fs & P.name "forge-stress" . V.valueLocal . n3 . V.datasetCurrent . durationM . P.traceForwardingOn . P.analysisUnitary
, fs & P.name "forge-stress-notracer" . V.valueLocal . n3 . V.datasetCurrent . durationM . P.traceForwardingOff . P.analysisUnitary
-- TODO: FIXME: "forge-stress-p2p" has no P2P enabled and Plutus TPS!!!!
, fs & P.name "forge-stress-p2p" . V.plutusLoop . n3 . V.datasetCurrent . durationM . P.traceForwardingOn . P.analysisSizeSmall
, fs & P.name "forge-stress-p2p" . P.p2pOn . V.plutusLoop . n3 . V.datasetCurrent . durationM . P.traceForwardingOn . P.analysisSizeSmall
, fs & P.name "forge-stress-plutus" . V.plutusLoop . n3 . V.datasetCurrent . durationM . P.traceForwardingOn . P.analysisSizeSmall
-- -large: voltaire variant, double nodes and double runtime. This needs >64GB RAM.
, fs & P.name "forge-stress-large" . V.valueLocal . v6 . V.datasetCurrent . durationXL . P.traceForwardingOn
Expand Down
219 changes: 184 additions & 35 deletions bench/cardano-topology/app/cardano-topology.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TupleSections #-}
Expand All @@ -11,32 +12,59 @@
import Prelude hiding (id)

import qualified Data.Aeson as Aeson
import qualified Data.ByteString.Lazy.Char8 as LBS
-- Package: bytestring.
import qualified Data.ByteString.Lazy.Char8 as BSL8
import qualified Data.GraphViz as G
import qualified Data.GraphViz.Attributes.Complete as G
import qualified Data.GraphViz.Printing as G
import qualified Data.Text.Lazy.IO as T
import Options.Applicative

import qualified Cardano.Benchmarking.Topology as Topo
import qualified Cardano.Benchmarking.Topology.Projection as Projection

--------------------------------------------------------------------------------

data Cli =
Make (Topo.CoreNodesParams, FilePath, Maybe FilePath, Bool)
| ProjectionFor FilePath ProjectionFor

data ProjectionFor =
-- Node i, base port, p2p on or off.
BFT Int Int Bool
| Pool Int Int Bool
-- Nodes indices, base port.
| Explorer Int Int
| ChaindbServer
| Proxy
deriving Show

--------------------------------------------------------------------------------

main :: IO ()
main = do
(coreNodesParams, topoJson, topoDot, withExplorer) <- execParser cliOpts
let cores = Topo.mkCoreNodes coreNodesParams
relays = [
Topo.mkExplorer (Topo.AWS Topo.EU_CENTRAL_1) cores
| withExplorer
]
writeTopo cores relays topoJson
maybe (pure ()) (writeDot cores) topoDot
cli <- getOpts
case cli of
Make (coreNodesParams, topoJson, topoDot, withExplorer) -> do
let cores = Topo.mkCoreNodes coreNodesParams
let relays = [
Topo.mkExplorer (Topo.AWS Topo.EU_CENTRAL_1) cores
| withExplorer
]
writeTopo cores relays topoJson
maybe (pure ()) (writeDot cores) topoDot
(ProjectionFor topologyPath projectionFor) -> do
eitherTopology <- Aeson.eitherDecodeFileStrict topologyPath
let topology = case eitherTopology of
(Left errorMsg) ->
error $ "Not a valid topology: " ++ errorMsg
(Right value) -> value
writeProjectionFor topology projectionFor

--------------------------------------------------------------------------------

-- | Locations from the CLI are parsed first using the "legacy mode" for
-- backward compatiblity, in this mode locations have a default AWS region that
-- backward compatibility, in this mode locations have a default AWS region that
-- are the ones cardano-ops is using. The new format is either "loopback" or a
-- supported AWS Region.
cliLocation :: String -> Either String Topo.Location
Expand All @@ -49,32 +77,48 @@ cliLocation = \case
-- New format.
str -> Aeson.eitherDecode
-- Make the string JSON valid by enclosing it with quotes.
(LBS.pack $ "\"" ++ str ++ "\"")


cliOpts :: ParserInfo (Topo.CoreNodesParams, FilePath, Maybe FilePath, Bool)
cliOpts = info (cliParser <**> helper)
( fullDesc
<> progDesc "Cardano topology generator"
<> header "make-topology - generate Cardano node topologies" )
where
cliParser :: Parser (Topo.CoreNodesParams, FilePath, Maybe FilePath, Bool)
cliParser =
(,,,)
<$> subparser coreNodesParamsParser
<*> strOption
( long "topology-output"
<> help "Topology file to write"
<> metavar "OUTFILE" )
<*> optional
(strOption
( long "dot-output"
<> help "Dot file to write"
<> metavar "OUTFILE" ))
<*> flag False True
( long "with-explorer"
<> help "Add an explorer to the topology")
(BSL8.pack $ "\"" ++ str ++ "\"")

getOpts :: IO Cli
getOpts = execParser $ info
(
hsubparser
(
command "make"
(info
(Make <$> cliParserMake)
( fullDesc
<> header "make"
<> progDesc "Create a cluster topology"
)
)
<>
command "projection-for"
(info
( ProjectionFor
<$> strOption
( long "topology-input"
<> help "Topology file"
<> metavar "INPUTFILE"
)
<*> cliParserProjection
)
( fullDesc
<> header "projection-for"
<> progDesc "Create an individual topology"
)
)
)
<**> helper
)
( fullDesc
<> progDesc "Cardano topology generation for Performance & Tracing"
<> header "Cardano node topologies tool"
)

cliParserMake :: Parser (Topo.CoreNodesParams, FilePath, Maybe FilePath, Bool)
cliParserMake =
let
coreNodesParamsParser =
command "line"
(info
Expand Down Expand Up @@ -141,6 +185,92 @@ cliOpts = info (cliParser <**> helper)
then Nothing -- The BFT node has no pools
else Just 1 -- Dense pools are denoted by any amount >1
_ -> Just 2
in
(,,,)
<$> subparser coreNodesParamsParser
<*> strOption
( long "topology-output"
<> help "Topology file to write"
<> metavar "OUTFILE"
)
<*> optional
(strOption
( long "dot-output"
<> help "Dot file to write"
<> metavar "OUTFILE" ))
<*> flag False True
( long "with-explorer"
<> help "Add an explorer to the topology")

cliParserProjection :: Parser ProjectionFor
cliParserProjection =
let
parseBasePort =
option auto
( long "baseport"
<> metavar "BASEPORT"
<> help "Base port"
)
parseNodeNumber =
option auto
( long "node-number"
<> short 'i'
<> metavar "NODENUMBER"
<> help "Base port"
)
parseEnableP2P =
flag False True
( long "enable-p2p"
<> help "Create a P2P topology"
)
parseSrcIndices =
option auto
( long "nodes"
<> metavar "NODES"
<> help "Create a non-P2P topology with nodes [0..(NODES-1)]"
)

in subparser $
command "bft"
(info
(BFT <$> parseNodeNumber <*> parseBasePort <*> parseEnableP2P)
( progDesc "BFT"
<> fullDesc
<> header "Generate the topology file for a BFT node"
)
)
<> command "pool"
(info
(Pool <$> parseNodeNumber <*> parseBasePort <*> parseEnableP2P)
( progDesc "Pool"
<> fullDesc
<> header "Generate the topology file for a pool node"
)
)
<> command "explorer"
(info
(Explorer <$> parseSrcIndices <*> parseBasePort)
( progDesc "Explorer"
<> fullDesc
<> header "Generate the topology file for an explorer node"
)
)
<> command "chaindb-server"
(info
(pure ChaindbServer)
( progDesc "ChainDB Server"
<> fullDesc
<> header "Generate the topology file for a ChainDB server node"
)
)
<> command "proxy"
(info
(pure Proxy)
( progDesc "Proxy"
<> fullDesc
<> header "Generate the topology file for a proxy node"
)
)

--------------------------------------------------------------------------------

Expand Down Expand Up @@ -195,3 +325,22 @@ locationColor = \case
(Topo.AWS Topo.US_EAST_1) -> G.RGB 200 250 200
(Topo.AWS Topo.US_EAST_2) -> G.RGB 200 250 200
Topo.Loopback -> G.RGB 200 200 250

--------------------------------------------------------------------------------

writeProjectionFor :: Topo.Topology -> ProjectionFor -> IO ()
writeProjectionFor topology projectionFor = do
BSL8.putStrLn $ writeProjectionFor' topology projectionFor

writeProjectionFor' :: Topo.Topology -> ProjectionFor -> BSL8.ByteString
writeProjectionFor' topology (BFT i basePort p2pEnabled) = writeProjectionForProducer topology i basePort p2pEnabled
writeProjectionFor' topology (Pool i basePort p2pEnabled) = writeProjectionForProducer topology i basePort p2pEnabled
writeProjectionFor' _ (Explorer srcIndices basePort) = Aeson.encode $ Projection.projectionExplorer srcIndices basePort
writeProjectionFor' topology ChaindbServer = Aeson.encode $ Projection.projectionChainDB topology
writeProjectionFor' _ Proxy = error "Nodes of kind \"proxy\" are not supported, Nix handles this case!"

writeProjectionForProducer :: Topo.Topology -> Int -> Int -> Bool -> BSL8.ByteString
writeProjectionForProducer topology i basePort enableP2P =
if enableP2P
then Aeson.encode $ Projection.projectionP2P topology i basePort
else Aeson.encode $ Projection.projection topology i basePort
34 changes: 25 additions & 9 deletions bench/cardano-topology/cardano-topology.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,25 @@ license: Apache-2.0
license-files: LICENSE
NOTICE
build-type: Simple
data-files: data/bench-torus-52.json
data/bench-torus-dense-52.json
data/ci-test-nomadcwqa.json
data/ci-test-nomadperf.json
data/ci-test.json
data/default-nomadcwqa.json
data/default-nomadperf.json
data/default.json
data-files: data/test/10-coay/*.json
data/test/6-dense-coay/*.json
data/test/chainsync-early-alonzo-coay/*.json
data/test/ci-test-coay/*.json
data/test/ci-test-dense10-coay/*.json
data/test/ci-test-nomadperf-coay/*.json
data/test/ci-test-nomadperf-nop2p-coay/*.json
data/test/ci-test-p2p-coay/*.json
data/test/default-coay/*.json
data/test/default-nomadperf-coay/*.json
data/test/default-nomadperf-nop2p-coay/*.json
data/test/default-p2p-coay/*.json
data/test/fast-solo-coay/*.json
data/test/forge-stress-coay/*.json
data/test/forge-stress-p2p-coay/*.json
data/test/model-value-coay/*.json
data/test/trace-bench-coay/*.json
data/test/value-nomadperf-nop2p-coay/*.json
data/test/value-volt-nomadperf-coay/*.json

common project-config
build-depends: base >= 4.14 && < 5
Expand All @@ -39,11 +50,15 @@ library
import: project-config
hs-source-dirs: src
exposed-modules: Cardano.Benchmarking.Topology
, Cardano.Benchmarking.Topology.Projection
, Cardano.Benchmarking.Topology.Types
build-depends: base >=4.12 && <5
, aeson
, bytestring
, text
, network
, iproute
, dns

executable cardano-topology
import: project-config
Expand All @@ -66,7 +81,8 @@ test-suite cardano-topology-test
hs-source-dirs: test/
main-is: Main.hs
type: exitcode-stdio-1.0
other-modules: Paths_cardano_topology
other-modules: Cardano.Benchmarking.Topology.Projection.Tests
, Paths_cardano_topology
autogen-modules: Paths_cardano_topology
build-depends: base
, aeson
Expand Down
9 changes: 9 additions & 0 deletions bench/cardano-topology/data/test/10-coay/node-0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Producers": [
{
"addr": "127.0.0.1",
"port": 30001,
"valency": 1
}
]
}
9 changes: 9 additions & 0 deletions bench/cardano-topology/data/test/10-coay/node-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Producers": [
{
"addr": "127.0.0.1",
"port": 30002,
"valency": 1
}
]
}
9 changes: 9 additions & 0 deletions bench/cardano-topology/data/test/10-coay/node-2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Producers": [
{
"addr": "127.0.0.1",
"port": 30003,
"valency": 1
}
]
}
9 changes: 9 additions & 0 deletions bench/cardano-topology/data/test/10-coay/node-3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Producers": [
{
"addr": "127.0.0.1",
"port": 30004,
"valency": 1
}
]
}
9 changes: 9 additions & 0 deletions bench/cardano-topology/data/test/10-coay/node-4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Producers": [
{
"addr": "127.0.0.1",
"port": 30005,
"valency": 1
}
]
}
Loading