Skip to content

Commit

Permalink
Merge pull request #4904 from input-output-hk/bench-master
Browse files Browse the repository at this point in the history
workbench:  updates
  • Loading branch information
deepfire authored Feb 21, 2023
2 parents facefec + e12d9e1 commit c53d94a
Show file tree
Hide file tree
Showing 117 changed files with 3,367 additions and 1,040 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ trace-documentation:
###
### Workbench
###
CI_TARGETS := hlint workbench-ci-test haddock-hoogle
workbench-ci: workbench-ci-test ci-test-auto ci-test-autonix ci-test-autonomad
CI_TARGETS := hlint workbench-ci haddock-hoogle
ci: ci-report ci-targets
ci-report:
@echo -e "\033[34mGoals under test\033[0m: \033[33m$(CI_TARGETS)\033[0m"
ci-targets: $(CI_TARGETS)

workbench-internals-walkthrough:
emn nix/workbench/doc.org

##
## Base targets:
##
Expand All @@ -71,7 +75,7 @@ ps: ## Plain-text list of profiles
##
PROFILES_BASE := default plutus plutus-secp-ecdsa plutus-secp-schnorr oldtracing idle tracer-only
PROFILES_STARTSTOP := startstop startstop-p2p startstop-plutus startstop-notracer startstop-oldtracing
PROFILES_CI_TEST := ci-test ci-test-p2p ci-test-plutus ci-test-notracer ci-test-dense10
PROFILES_CI_TEST := ci-test ci-test-p2p ci-test-plutus ci-test-notracer ci-test-dense10 aws-test
PROFILES_CI_BENCH := ci-bench ci-bench-p2p ci-bench-plutus ci-bench-plutus-secp-ecdsa ci-bench-plutus-secp-schnorr ci-bench-notracer
PROFILES_10 := 10 10-p2p 10-plutus 10-notracer
PROFILES_FORGE_STRESS := forge-stress forge-stress-p2p forge-stress-plutus forge-stress-plutus-singleton forge-stress-notracer
Expand Down
50 changes: 33 additions & 17 deletions bench/cardano-topology/cardano-topology.hs
Original file line number Diff line number Diff line change
Expand Up @@ -170,31 +170,37 @@ intraConnectRing withChords bidirectional specs =

main :: IO ()
main = do
(topoParams, topoJson, topoDot) <- execParser opts
(topoParams, topoJson, topoDot, withExplorer) <- execParser opts

let topoSpec = mkTopology topoParams
topo = mkNode <$> topoSpec
cores = mkNode <$> topoSpec
relays = [ mkExplorer (locationRegion EU) cores
| withExplorer ]

writeTopo topo topoJson
writeTopo cores relays topoJson
maybe (pure ()) (writeDot topoSpec) topoDot
where
opts = info (cliParser <**> helper)
( fullDesc
<> progDesc "Cardano topology generator"
<> header "make-topology - generate Cardano node topologies" )

cliParser :: Parser (TopoParams, FilePath, Maybe FilePath)
cliParser :: Parser (TopoParams, FilePath, Maybe FilePath, Bool)
cliParser =
(,,) <$> subparser topoParamsParser
<*> strOption
( long "topology-output"
<> help "Topology file to write"
<> metavar "OUTFILE" )
<*> optional
(strOption
( long "dot-output"
<> help "Dot file to write"
<> metavar "OUTFILE" ))
(,,,)
<$> subparser topoParamsParser
<*> 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")

topoParamsParser =
command "torus"
Expand Down Expand Up @@ -255,10 +261,10 @@ main = do

--- * To JSON topology
---
writeTopo :: [Node] -> FilePath -> IO ()
writeTopo topo f =
writeTopo :: [Node] -> [Node] -> FilePath -> IO ()
writeTopo cores relays f =
IO.withFile f IO.WriteMode $ \hnd ->
LBS.hPutStrLn hnd . encode $ Topology topo []
LBS.hPutStrLn hnd . encode $ Topology cores relays

mkNode :: Spec -> Node
mkNode Spec{..} = Node{..}
Expand All @@ -271,6 +277,16 @@ mkNode Spec{..} = Node{..}
region = locationRegion loc
producers = idName <$> links

mkExplorer :: String -> [Node] -> Node
mkExplorer region cores = Node{ name = "explorer"
, ..}
where
org = "IOHK"
nodeId = length cores
pools = Nothing
stakePool = False
producers = name <$> cores

data Topology = Topology
{ coreNodes :: [Node]
, relayNodes :: [Node]
Expand Down
15 changes: 15 additions & 0 deletions bench/locli/src/Cardano/Analysis/API/Dictionary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,22 @@ import Data.Map.Strict qualified as M
import Cardano.Analysis.API.Field
import Cardano.Analysis.API.Types
import Cardano.Analysis.API.Metrics ()
import Cardano.Util (showText)


data DictEntry where
DictEntry ::
{ deField :: !Text
, deShortDesc :: !Text
, deDescription :: !Text
, deLogScale :: !Text
, deRange :: !Text
, deUnit :: !Text
} -> DictEntry
deriving (Generic, FromJSON, ToJSON, Show)

data ChartArgs

data Dictionary where
Dictionary ::
{ dBlockProp :: !(Map Text DictEntry)
Expand All @@ -41,4 +47,13 @@ metricDictionary =
{ deField = fId
, deShortDesc = fShortDesc
, deDescription = fDescription
, deLogScale = case fScale of
Log -> "true"
Lin -> "false"
, deRange = case fRange of
Free -> ""
Z0 x -> "0:" <> showText x
Z1 x -> "0:" <> showText x
R01 -> "0:1"
, deUnit = renderUnit fUnit
}
21 changes: 16 additions & 5 deletions bench/locli/src/Cardano/Analysis/API/Field.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ data Unit

renderUnit :: Unit -> Text
renderUnit = \case
Sec -> "sec"
Sec -> "s"
Hz -> "Hz"
B -> "B"
KB -> "KB"
Expand Down Expand Up @@ -115,10 +115,21 @@ data Precision
| P3
deriving (Eq, Enum, Ord, Show)

{-# INLINE width #-}
width :: Width -> Int
width Wno = 80
width x = fromEnum x
{-# INLINE unWidth #-}
unWidth :: Width -> Maybe Int
unWidth Wno = Nothing
unWidth x = Just $ fromEnum x

{-# INLINE unsafeUnWidth #-}
unsafeUnWidth :: String -> Width -> Int
unsafeUnWidth ctx Wno = error $ "Unexpected Wno (indeterminate width): " <> ctx
unsafeUnWidth _ x = fromEnum x

{-# INLINE mapWidth #-}
mapWidth :: a -> (Int -> a) -> Width -> a
mapWidth wNo wSome = \case
Wno -> wNo
x -> wSome (fromEnum x)

-- | Encapsulate all metadata about a metric (a projection) of
-- a certain projectible (a kind of analysis results):
Expand Down
Loading

0 comments on commit c53d94a

Please sign in to comment.