Skip to content

Commit

Permalink
Merge pull request #6041 from IntersectMBO/bench-master
Browse files Browse the repository at this point in the history
bench: improve genesis cache retrieval; maintenance for `locli` and others
  • Loading branch information
mgmeier authored Nov 22, 2024
2 parents 6e969c6 + 186f0e7 commit e37615c
Show file tree
Hide file tree
Showing 19 changed files with 220 additions and 182 deletions.
11 changes: 11 additions & 0 deletions bench/locli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Revision history for locli

## 1.36 -- Nov 2024

* Add `CHANGELOG.md` for `locli`
* Discern Plutus RIPEMD-160 workload in reports
* Remove unused build-depends
* Remove redundant fields from summary report: Perf analysis start/stop spread, Log text lines per host (NB. incompatible for comparison with `summary.org` files created with prior versions)
* Remove unused CLI commands `list-logobject-keys-legacy` and `list-logobject-keys`
* Remove unused `HostLogs` SHA256 checksums
* Disable missing trace detection (temporarily), as raw data isn't properly evaluated to that end at the moment
24 changes: 4 additions & 20 deletions bench/locli/locli.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 3.0

name: locli
version: 1.35
version: 1.36
synopsis: Cardano log analysis CLI
description: Cardano log analysis CLI.
category: Cardano,
Expand All @@ -12,6 +12,7 @@ maintainer: [email protected]
license: Apache-2.0
license-files: LICENSE
NOTICE
extra-doc-files: CHANGELOG.md
build-type: Simple

common project-config
Expand Down Expand Up @@ -95,11 +96,8 @@ library
autogen-modules: Paths_locli

build-depends: aeson
, Histogram
, aeson-pretty
, async
, attoparsec
, attoparsec-iso8601
, bytestring
, cardano-git-rev ^>= 0.2.2
, cardano-ledger-core
Expand All @@ -110,27 +108,16 @@ library
, directory
, ede
, extra
, file-embed
, filepath
, fingertree
, hashable
, gnuplot
, iohk-monitoring
, optparse-applicative-fork
, optparse-generic
, optparse-applicative-fork >= 0.18.1
, ouroboros-consensus
-- for Data.SOP.Strict:
, ouroboros-network ^>= 0.17
, ouroboros-network-api
, process
, quiet
, scientific
, ouroboros-network-api ^>= 0.10
, sop-core
, split
, statistics
, strict-sop-core
, system-filepath
, template-haskell
, text
, text-short
, time
Expand All @@ -139,18 +126,15 @@ library
, transformers-except
, unix
, unordered-containers
, utf8-string
, vector
, witherable
, cardano-strict-containers ^>= 0.1

executable locli
import: project-config

hs-source-dirs: app
main-is: locli.hs
ghc-options: -threaded
-Wall
-rtsopts
"-with-rtsopts=-T -N7 -A2m -qb -H64m"

Expand Down
37 changes: 10 additions & 27 deletions bench/locli/src/Cardano/Analysis/API/Ground.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ module Cardano.Analysis.API.Ground
)
where

import Prelude (show)
import Prelude as P (show)
import Cardano.Prelude hiding (head, toText)
import Unsafe.Coerce qualified as Unsafe

import Data.Aeson
import Data.Aeson.Types (toJSONKeyText)
import Data.Attoparsec.Text qualified as Atto
import Data.Attoparsec.Time qualified as Iso8601
import Data.ByteString.Lazy.Char8 qualified as LBS
import Data.Map.Strict qualified as Map
import Data.Text qualified as T
Expand All @@ -26,7 +24,6 @@ import Data.Text.Short (ShortText, fromText, toText)
import Data.Time.Clock (UTCTime, NominalDiffTime)
import Options.Applicative
import Options.Applicative qualified as Opt
import Quiet (Quiet (..))
import System.FilePath qualified as F

import Cardano.Slotting.Slot (EpochNo(..), SlotNo(..))
Expand All @@ -41,13 +38,17 @@ newtype FieldName = FieldName { unFieldName :: Text }
deriving (Eq, Generic, Ord)
deriving newtype (FromJSON, IsString, ToJSON)
deriving anyclass NFData
deriving Show via Quiet FieldName

instance Show FieldName where
show = ("FieldName " ++) . P.show . unFieldName

newtype TId = TId { unTId :: ShortText }
deriving (Eq, Generic, Ord)
deriving newtype (FromJSON, ToJSON)
deriving anyclass NFData
deriving Show via Quiet TId

instance Show TId where
show = ("TId " ++) . P.show . unTId

newtype Hash = Hash { unHash :: ShortText }
deriving (Eq, Generic, Ord)
Expand Down Expand Up @@ -95,7 +96,9 @@ newtype Host = Host { unHost :: ShortText }
deriving (Eq, Generic, Ord)
deriving newtype (IsString, FromJSON, ToJSON)
deriving anyclass NFData
deriving Show via Quiet Host

instance Show Host where
show = ("Host " ++) . P.show . unHost

newtype EpochSlot = EpochSlot { unEpochSlot :: Word64 }
deriving stock (Eq, Generic, Ord, Show)
Expand Down Expand Up @@ -269,26 +272,6 @@ pSlotNo name desc =
<> Opt.help desc
)

optUTCTime :: String -> String -> Parser UTCTime
optUTCTime optname desc =
Opt.option (readerFromAttoParser Iso8601.utcTime)
$ long optname
<> metavar "ISO8601-TIME"
<> help desc
where
-- Stolen from: cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs
readerFromAttoParser :: Atto.Parser a -> Opt.ReadM a
readerFromAttoParser p =
Opt.eitherReader (Atto.parseOnly (p <* Atto.endOfInput) . T.pack)

optDuration :: String -> String -> NominalDiffTime -> Parser NominalDiffTime
optDuration optname desc def=
Opt.option ((realToFrac :: Double -> NominalDiffTime) <$> Opt.auto)
$ long optname
<> metavar "SEC"
<> help desc
<> value def

optWord :: String -> String -> Word64 -> Parser Word64
optWord optname desc def =
Opt.option auto
Expand Down
20 changes: 3 additions & 17 deletions bench/locli/src/Cardano/Analysis/API/Metrics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ sumFieldsReport =
, "plutusScript"
, "sumHosts", "sumLogObjectsTotal"
, "sumFilters"
, "cdfLogLinesEmitted", "cdfLogObjectsEmitted", "cdfLogObjects"
, "cdfLogObjectsEmitted", "cdfLogObjects"
, "cdfRuntime", "cdfLogLineRate"
, "ddRawCount.sumDomainTime", "ddFilteredCount.sumDomainTime", "dataDomainFilterRatio.sumDomainTime"
, "ddRaw.sumStartSpread", "ddRaw.sumStopSpread"
, "ddFiltered.sumStartSpread", "ddFiltered.sumStopSpread"
, "sumDomainSlots", "sumDomainBlocks", "sumBlocksRejected"]

instance (KnownCDF f) => TimelineFields (Summary f) where
Expand Down Expand Up @@ -95,8 +94,8 @@ instance (KnownCDF f) => TimelineFields (Summary f) where
""

<> fScalar "utxo" W12 Cnt (IWord64 $ utxo.sumGenesisSpec)
"Starting UTxO set size"
"Extra UTxO set size at the beginning of the benchmark"
"Stuffed UTxO size"
"Extra UTxO set entries (from genesis)"

<> fScalar "dreps" W12 Cnt (IWord64 $ dreps.sumGenesisSpec)
"DRep count"
Expand Down Expand Up @@ -136,10 +135,6 @@ instance (KnownCDF f) => TimelineFields (Summary f) where
"Number of filters applied"
""

<> fScalar "cdfLogLinesEmitted" W12 Cnt (IFloat $ cdfAverageVal.cdfLogLinesEmitted)
"Log text lines emitted per host"
""

<> fScalar "cdfLogObjectsEmitted" W12 Cnt (IFloat $ cdfAverageVal.cdfLogObjectsEmitted)
"Log objects emitted per host"
""
Expand Down Expand Up @@ -180,14 +175,6 @@ instance (KnownCDF f) => TimelineFields (Summary f) where
"Node stop spread, s"
""

<> fScalar "ddFiltered.sumStartSpread" W9 Sec (IDeltaT$ maybe 0 (intvDurationSec.fmap (fromRUTCTime . arityProj cdfMedian)).ddFiltered.sumStartSpread)
"Perf analysis start spread, s"
""

<> fScalar "ddFiltered.sumStopSpread" W9 Sec (IDeltaT$ maybe 0 (intvDurationSec.fmap (fromRUTCTime . arityProj cdfMedian)).ddFiltered.sumStopSpread)
"Perf analysis stop spread, s"
""

<> fScalar "sumDomainSlots" W12 Slo (IInt $ floor.arityProj cdfMedian.cdfAverage.ddFilteredCount.sumDomainSlots)
"Slots analysed"
""
Expand All @@ -211,7 +198,6 @@ instance (KnownCDF f) => TimelineFields (Summary f) where
, manifestPackages <&> pkgCommit
]


-- fieldJSONOverlay f = (:[]) . tryOverlayFieldDescription f

propSubsetFn :: PropSubset -> (Field DSelect p a -> Bool)
Expand Down
1 change: 0 additions & 1 deletion bench/locli/src/Cardano/Analysis/API/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ data Summary f where
, sumDomainBlocks :: !(DataDomain f BlockNo)
, sumProfilingData :: !(Maybe (ProfilingData (CDF I)))

, cdfLogLinesEmitted :: !(CDF f Int)
, cdfLogObjectsEmitted :: !(CDF f Int)
, cdfLogObjects :: !(CDF f Int)
, cdfRuntime :: !(CDF f NominalDiffTime)
Expand Down
6 changes: 2 additions & 4 deletions bench/locli/src/Cardano/Analysis/Summary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ summariseMultiSummary sumAnalysisTime centiles xs@(headline:xss) = do
sumMeta <- summariseMetadata $ xs <&> sumMeta
sumFilters <- allEqOrElse (xs <&> sumFilters) SEIncoherentRunFilters

cdfLogLinesEmitted <- sumCDF2 $ xs <&> cdfLogLinesEmitted
cdfLogObjectsEmitted <- sumCDF2 $ xs <&> cdfLogObjectsEmitted
cdfLogObjects <- sumCDF2 $ xs <&> cdfLogObjects
cdfRuntime <- sumCDF2 $ xs <&> cdfRuntime
Expand Down Expand Up @@ -172,7 +171,6 @@ computeSummary sumAnalysisTime
--
, cdfLogObjects = cdf stdCentiles (objLists <&> length)
, cdfLogObjectsEmitted = cdf stdCentiles logObjectsEmitted
, cdfLogLinesEmitted = cdf stdCentiles textLinesEmitted
, cdfRuntime = cdf stdCentiles runtimes
, ..
}
Expand All @@ -183,7 +181,7 @@ computeSummary sumAnalysisTime
rlHostLogs
& Map.elems

(,) logObjectsEmitted textLinesEmitted =
(logObjectsEmitted, textLinesEmitted) =
hostLogs
& fmap (hlRawLogObjects &&& hlRawLines)
& unzip
Expand All @@ -198,7 +196,7 @@ computeSummary sumAnalysisTime
lineRates = zipWith (/) (textLinesEmitted <&> fromIntegral)
(runtimes <&> fromIntegral @Int . truncate)

(,,) sumDomainTime sumStartSpread sumStopSpread =
(sumDomainTime, sumStartSpread, sumStopSpread) =
slotDomains sumGenesis (losFirsts, losLasts) mpDomainSlots

sumChainRejectionStats :: [(ChainFilter, Int)]
Expand Down
34 changes: 7 additions & 27 deletions bench/locli/src/Cardano/Command.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ newtype Command
deriving Show

data ChainCommand
= ListLogobjectKeys TextOutputFile
| ListLogobjectKeysLegacy TextOutputFile

| ReadMetaGenesis (JsonInputFile RunPartial) (JsonInputFile Genesis)
= ReadMetaGenesis (JsonInputFile RunPartial) (JsonInputFile Genesis)
| WriteMetaGenesis TextOutputFile TextOutputFile

| Unlog (JsonInputFile (RunLogs ())) Bool (Maybe [LOAnyType])
Expand Down Expand Up @@ -104,12 +101,6 @@ data ChainCommand
parseChainCommand :: Parser ChainCommand
parseChainCommand =
subparser (mconcat [ commandGroup "Common data: logobject keys, run metafile & genesis"
, op "list-logobject-keys" "List logobject keys that analyses care about"
(ListLogobjectKeys
<$> optTextOutputFile "keys" "Text file to write logobject keys to")
, op "list-logobject-keys-legacy" "List legacy logobject keys that analyses care about"
(ListLogobjectKeysLegacy
<$> optTextOutputFile "keys-legacy" "Text file to write logobject keys to")
, op "read-meta-genesis" "Read the run metadata: meta.json and Shelley genesis"
(ReadMetaGenesis
<$> optJsonInputFile "run-metafile" "The meta.json file from the benchmark run"
Expand Down Expand Up @@ -391,22 +382,9 @@ sAnchor State{sTags=[]} = error "sAnchor with no run or multi-summary."
sAnchor s@State{sTags}
= stateAnchor sTags s

quote :: T.Text -> T.Text
quote = (<> "\"") . ("\"" <>)

runChainCommand :: State -> ChainCommand -> ExceptT CommandError IO State

runChainCommand s
c@(ListLogobjectKeys f) = do
dumpText "logobject-keys" (quote . toText <$> logObjectStreamInterpreterKeys) f
& firstExceptT (CommandError c)
pure s
runChainCommand s
c@(ListLogobjectKeysLegacy f) = do
dumpText "logobject-keys-legacy" (quote . toText <$> logObjectStreamInterpreterKeysLegacy) f
& firstExceptT (CommandError c)
pure s

runChainCommand s
c@(ReadMetaGenesis runMeta shelleyGenesis) = do
progress "run" (Q $ printf "reading run metadata & Shelley genesis")
Expand Down Expand Up @@ -601,7 +579,7 @@ runChainCommand s@State{sRun=Just _run, sSlots=Just slots}
runChainCommand _ c@TimelineSlots{} = missingCommandData c
["run metadata & genesis", "filtered slots"]

runChainCommand s@State{sRun=Just run, sChain=Just chain@Chain{..}, sRunLogs}
runChainCommand s@State{sRun=Just run, sChain=Just chain@Chain{..}}
c@ComputePropagation = do
progress "block-propagation" $ J (cDomBlocks, cDomSlots)
prop <- pure (blockProp run chain)
Expand All @@ -615,9 +593,11 @@ runChainCommand s@State{sRun=Just run, sChain=Just chain@Chain{..}, sRunLogs}
renderBlockPropError e
<> maybe "" ((".\n\n Missing traces in run logs (not all are fatal):\n\n " <>)
. T.intercalate "\n "
. fmap toText
. rlMissingTraces)
sRunLogs
. const []
)
Nothing
-- TODO: reactivate output once there's a proper evaluation of raw data

runChainCommand _ c@ComputePropagation = missingCommandData c
["run metadata & genesis", "chain", "data domains for slots & blocks"]

Expand Down
4 changes: 4 additions & 0 deletions bench/locli/src/Cardano/Report.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ data Workload
| WPlutusLoopCountdown
| WPlutusLoopSECP
| WPlutusLoopBLST
| WPlutusLoopRipemd
| WPlutusUnknown

instance ToJSON Workload where
Expand All @@ -88,13 +89,15 @@ instance ToJSON Workload where
WPlutusLoopCountdown -> "Plutus countdown loop"
WPlutusLoopSECP -> "Plutus SECP loop"
WPlutusLoopBLST -> "Plutus BLST loop"
WPlutusLoopRipemd -> "Plutus RIPEMD-160 loop"
WPlutusUnknown -> "Plutus (other)"

filenameInfix :: Workload -> Text
filenameInfix = \case
WPlutusLoopCountdown -> "plutus"
WPlutusLoopSECP -> "plutus-secp"
WPlutusLoopBLST -> "plutus-blst"
WPlutusLoopRipemd -> "plutus-ripemd"
WValue -> "value-only"
_ -> "unknown"

Expand Down Expand Up @@ -150,6 +153,7 @@ liftTmplRun Summary{sumWorkload=generatorProfile
| script == "EcdsaSecp256k1Loop" -> WPlutusLoopSECP
| script == "SchnorrSecp256k1Loop" -> WPlutusLoopSECP
| script == "HashOntoG2AndAdd" -> WPlutusLoopBLST
| script == "Ripemd160" -> WPlutusLoopRipemd
| otherwise -> WPlutusUnknown
}

Expand Down
5 changes: 0 additions & 5 deletions bench/locli/src/Cardano/Unlog/LogObject.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,8 @@ data HostLogs a
= HostLogs
{ hlRawLogfiles :: [FilePath]
, hlRawLines :: Int
, hlRawSha256 :: Hash
, hlRawTraceFreqs :: Map Text Int
, hlMissingTraces :: [Text]
, hlLogs :: (JsonLogfile, a)
, hlFilteredSha256 :: Hash
, hlProfile :: [ProfileEntry I]
, hlRawFirstAt :: Maybe UTCTime
, hlRawLastAt :: Maybe UTCTime
Expand All @@ -107,8 +104,6 @@ hlRawLogObjects = sum . Map.elems . hlRawTraceFreqs
data RunLogs a
= RunLogs
{ rlHostLogs :: Map.Map Host (HostLogs a)
, rlMissingTraces :: [Text]
, rlFilterKeys :: [Text]
, rlFilterDate :: UTCTime
}
deriving (Generic, FromJSON, ToJSON)
Expand Down
Loading

0 comments on commit e37615c

Please sign in to comment.