Skip to content

Commit

Permalink
Merge #3851
Browse files Browse the repository at this point in the history
3851: workbench:  support new tracing & add a Plutus workload profile r=deepfire a=deepfire

1. workbench: support new tracing & massage it to conform with legacy in terms of configuration
1. locli: support new tracing
1. new tracing: restore some structural compatibility with legacy
1. workbench: forge-stress-plutus profile
1. add `@mgmeier` to benchmarking things
1. Makefile tweaks for better automation
1. new tracing: add node state log messages
1. workbench: further improve derived calculations in profiles
1. a bunch of small workbench improvements here and there

Co-authored-by: Kosyrev Serge <serge.kosyrev@iohk.io>
  • Loading branch information
iohk-bors[bot] and deepfire authored May 19, 2022
2 parents 1ae1ed0 + 0c97e4d commit 0446c02
Show file tree
Hide file tree
Showing 68 changed files with 1,792 additions and 824 deletions.
11 changes: 5 additions & 6 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ doc @docs-access
README.* @docs-access

bench/tx-generator @deepfire @MarcFontaine
bench @deepfire @denisshevchenko @jutaro @MarcFontaine @cleverca22
bench @deepfire @denisshevchenko @jutaro @MarcFontaine @mgmeier @cleverca22
cardano-tracer @deepfire @denisshevchenko
nix/workbench @deepfire @denisshevchenko @jutaro @MarcFontaine
nix/supervisord-cluster @deepfire @denisshevchenko @jutaro @MarcFontaine
trace-dispatcher @deepfire @denisshevchenko @jutaro
trace-forward @deepfire @denisshevchenko @jutaro
trace-resources @deepfire @denisshevchenko @jutaro
nix/workbench @deepfire @denisshevchenko @jutaro @MarcFontaine @mgmeier
trace-dispatcher @deepfire @denisshevchenko @jutaro @mgmeier
trace-forward @deepfire @denisshevchenko @jutaro @mgmeier
trace-resources @deepfire @denisshevchenko @jutaro @mgmeier
Makefile @deepfire

.buildkite @devops
Expand Down
144 changes: 50 additions & 94 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,128 +1,84 @@
help: ## Print documentation
@{ grep -hE '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST); echo -e '$(EXTRA_HELP)'; } | sed 's/^ //' | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

include lib.mk
include nix.mk
include legacy.mk

PROJECT_NAME = cardano-node
NUM_PROC = $(nproc --all)

## One of: shey alra mary alzo
ERA ?= alzo
ERA ?= alzo

CLUSTER_PROFILE ?= default-${ERA}
ifneq "${CLUSTER_PROFILE}" "default-${ERA}"
$(warning DEPRECATED: CLUSTER_PROFILE is deprecated, please use PROFILE)
endif

PROFILE ?= ${CLUSTER_PROFILE}
PROFILE ?= default-${ERA}
REV ?= master
ARGS ?=
CMD ?=


help: ## Print documentation
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
lint hlint:
hlint .

stylish-haskell: ## Apply stylish-haskell on all *.hs files
@find . -type f -name "*.hs" -not -path '.git' -not -path '*.stack-work*' -print0 | xargs -0 stylish-haskell -i
@find . -type f -name "*.hs" -not -path '.git' -print0 | xargs -0 stylish-haskell -i

cabal-hashes:
nix run .#checkCabalProject

ghci: ## Run repl
@stack ghci $(PROJECT_NAME):lib --haddock-deps --ghci-options=-fobject-code --nix

ghcid: ## Run ghcid
@ghcid --command "stack ghci $(PROJECT_NAME):lib --nix -j12 --ghci-options=-fobject-code"

run-test: ## Build & run test
@stack build --fast --nix && \
stack test --fast --nix

test-ghci: ## Run repl on test suites
@stack ghci $(PROJECT_NAME):lib $(PROJECT_NAME):test:$(PROJECT_NAME)-test --ghci-options=-fobject-code --nix

test-ghcid: ## Run ghcid on test suites
@ghcid --command "stack ghci --nix $(PROJECT_NAME):lib $(PROJECT_NAME):test:$(PROJECT_NAME)-test --ghci-options=-fobject-code"

test-ghcid-nix: ## Run ghcid on test suites with Nix
@ghcid --command="stack ghci --test --main-is $(PROJECT_NAME):test:$(PROJECT_NAME)-test --nix -j$(NUM_PROC)"

bench-chainsync: PROFILE=chainsync-${ERA}
bench-chainsync: cluster-shell-dev ## Enter Nix shell and start the chainsync benchmark

## TODO: migrate to `nix develop`
cluster-shell: ## Enter Nix shell and start the workbench cluster
nix-shell --max-jobs 8 --cores 0 --show-trace --argstr profileName ${PROFILE} --arg 'autoStartCluster' true

shell-dev: ARGS += --arg 'workbenchDevMode' true ## Enter Nix shell, dev mode (workbench run from checkout)
cluster-shell: ARGS += --arg 'autoStartCluster' true ## Enter Nix shell, and start workbench cluster
cluster-shell-dev: ARGS += --arg 'autoStartCluster' true --arg 'workbenchDevMode' true ## Enter Nix shell, dev mode, and start workbench cluster
cluster-shell-trace: ARGS += --arg 'autoStartCluster' true --argstr 'autoStartClusterArgs' '--trace --trace-workbench' ## Enter Nix shell, start workbench cluster, with shell tracing
cluster-shell-dev-trace: ARGS += --arg 'autoStartCluster' true --arg 'workbenchDevMode' true --argstr 'autoStartClusterArgs' '--trace --trace-workbench' ## Enter Nix shell, dev mode, start workbench cluster, with shell tracing
fixed: PROFILE = fixed-${ERA}
fixed: ARGS += --arg 'autoStartCluster' true
forge-stress: PROFILE = forge-stress-${ERA}
forge-stress: ARGS += --arg 'workbenchDevMode' true
quick: PROFILE = quick-${ERA}
quick: ARGS += --arg 'workbenchDevMode' true
shell-dev cluster-shell-dev cluster-shell-trace cluster-shell-dev-trace fixed forge-stress quick: shell

test-smoke: smoke ## Build the 'workbench-smoke-test', same as the Hydra job
smoke:
nix build -f 'default.nix' 'workbench-smoke-test' --out-link result-smoke-run --cores 0
test-analysis: smoke-analysis ## Build the 'workbench-smoke-analysis', same as the Hydra job
smoke-analysis:
nix build -f 'default.nix' 'workbench-smoke-analysis' --out-link result-smoke-analysis --cores 0 --show-trace
ci-analysis:
nix build -f 'default.nix' 'workbench-ci-analysis' --out-link result-ci-analysis --cores 0 --show-trace

list-profiles: ## List workbench profiles
nix build .#workbench.profile-names-json --json | jq '.[0].outputs.out' -r | xargs jq .
show-profile: ## NAME=profile-name
@test -n "${NAME}" || { echo 'HELP: to specify profile to show, add NAME=profle-name' && exit 1; }
nix build .#all-profiles-json --json --option substitute false | jq '.[0].outputs.out' -r | xargs jq ".\"${NAME}\" | if . == null then error(\"\n###\n### Error: unknown profile: ${NAME} Please consult: make list-profiles\n###\") else . end"
ps: list-profiles

bump-cardano-node-workbench: ## Update the cardano-node-workbench flake input
nix flake lock --update-input cardano-node-workbench
bump-node-measured: ## Update the node-measured flake input
nix flake lock --update-input node-measured
bump-cardano-deployment: ## Sync the flake.lock to the CI check
nix run nixpkgs#nixUnstable -- build .#hydraJobs.cardano-deployment
membench-1: ## Membench: one iteration, current commit
nix build .#membench-node-this-1.batch-report --out-link result-batch-1-report
membench-1-at: ## Membench: one iteration, set commit by: make membench-1-at REV=[master]
nix build .#membench-node-measured-1.batch-report --out-link result-batch-1-report --override-input node-measured github:input-output-hk/cardano-node/${REV}
membench-5: ## Membench: 5 iterations, current commit
nix build .#membench-node-this-5.batch-report --out-link result-batch-5-report
membench-5-at: ## Membench: 5 iterations, set commit by: make membench-5-at REV=[master]
nix build .#membench-node-this-5.batch-report --out-link result-batch-5-report --override-input node-measured github:input-output-hk/cardano-node/${REV}

shell: ## Enter Nix shell, CI mode (workbench run from Nix store)
nix-shell --max-jobs 8 --cores 0 --show-trace --argstr profileName ${PROFILE} ${ARGS}

cli node:
cabal --ghc-options="+RTS -qn8 -A32M -RTS" build cardano-$@

trace-documentation:
cabal run -- exe:cardano-node trace-documentation --config 'configuration/cardano/mainnet-config-new-tracing.yaml' --output-file 'doc/new-tracing/tracers_doc_generated.md'

BENCH_REPEATS ?= 3
BENCH_CONFIG ?= both
BENCH_TAG ?= HEAD
BENCH_XARGS ?=
###
### Workbench
###
##
## Base targets:
##
shell: ## Nix shell, CI mode (from Nix store), vars: PROFILE, CMD
nix-shell --max-jobs 8 --cores 0 --show-trace --argstr profileName ${PROFILE} ${ARGS} ${if ${CMD},--run "${CMD}"}
shell-dev: shell
shell-dev: ARGS += --arg 'workbenchDevMode' true ## Nix shell, dev mode (from checkout), vars: PROFILE, CMD

list-profiles: ## List workbench profiles
nix build .#workbench.profile-names-json --json | jq '.[0].outputs.out' -r | xargs jq .
show-profile: ## NAME=profile-name
@test -n "${NAME}" || { echo 'HELP: to specify profile to show, add NAME=profle-name' && exit 1; }
nix build .#all-profiles-json --json --option substitute false | jq '.[0].outputs.out' -r | xargs jq ".\"${NAME}\" | if . == null then error(\"\n###\n### Error: unknown profile: ${NAME} Please consult: make list-profiles\n###\") else . end"
ps: ## Plain-text list of profiles
@nix build .#workbench.profile-names-json --json | jq '.[0].outputs.out' -r | xargs jq '.[]' --raw-output

##
## Profile-based cluster shells (autogenerated targets)
##
SHELL_PROFILES += fixed
SHELL_PROFILES += quick quick-oldtracing

SHELL_PROFILES += forge-stress forge-stress-plutus forge-stress-oldtracing

SHELL_PROFILES += chainsync-early-byron chainsync-early-byron-oldtracing
SHELL_PROFILES += chainsync-early-alonzo chainsync-early-alonzo-oldtracing

## Note: to enable a shell for a profile, just add its name (one of names from 'make ps') to SHELL_PROFILES

profile-chainsync:
scripts/mainnet-via-fetcher.sh ${BENCH_XARGS} --node-config-${BENCH_CONFIG} --repeats ${BENCH_REPEATS} --nix --profile time --tag ${BENCH_TAG}
$(eval $(call define_profile_targets,$(SHELL_PROFILES)))

profile-chainsync-fast: BENCH_XARGS=--skip-prefetch
profile-chainsync-fast: profile-chainsync

###
### Misc
###
clean-profile proclean:
rm -f *.html *.prof *.hp *.stats *.eventlog

clean: clean-profile
rm -rf logs/ socket/ cluster.*

full-clean: clean
rm -rf db dist-newstyle .stack-work $(shell find . -name '*~' -or -name '*.swp')
rm -rf db dist-newstyle $(shell find . -name '*~' -or -name '*.swp')

cls:
echo -en "\ec"

.PHONY: bench-chainsync cabal-hashes clean cli cls cluster-profiles cluster-shell cluster-shell-dev cluster-shell-dev-trace cluster-shell-trace ghci ghcid help node run-test shell shell-dev stylish-haskell test-ghci test-ghcid test-ghcid-nix
.PHONY: cabal-hashes clean cli cls cluster-profiles cluster-shell help node run-test shell shell-dev stylish-haskell
1 change: 1 addition & 0 deletions bench/locli/locli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ library
, bytestring
, cardano-git-rev
, cardano-prelude
, cardano-ledger-core
, iohk-monitoring
, cardano-slotting
, containers
Expand Down
28 changes: 15 additions & 13 deletions bench/locli/src/Cardano/Analysis/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
{-# LANGUAGE DeriveGeneric #-}
{-# OPTIONS_GHC -Wno-name-shadowing #-}
{- HLINT ignore "Use head" -}
module Cardano.Analysis.API (module Cardano.Analysis.API) where
module Cardano.Analysis.API
( module Cardano.Analysis.API
, module Cardano.Util)
where

import Prelude ((!!), error)
import Cardano.Prelude hiding (head)
Expand All @@ -11,8 +14,7 @@ import Data.Aeson (ToJSON(..), FromJSON(..))
import Data.Text qualified as T
import Data.Text.Short (toText)
import Data.Time.Clock (NominalDiffTime)
import Data.Time (UTCTime)
import Text.Printf (PrintfArg, printf)
import Text.Printf (PrintfArg)

import Cardano.Analysis.Chain
import Cardano.Analysis.ChainFilter
Expand All @@ -22,6 +24,7 @@ import Cardano.Analysis.Version
import Cardano.Logging.Resources.Types
import Cardano.Unlog.LogObject hiding (Text)
import Cardano.Unlog.Render
import Cardano.Util

import Data.Distribution

Expand Down Expand Up @@ -60,7 +63,7 @@ data BlockEvents
, beBlockNo :: !BlockNo
, beSlotNo :: !SlotNo
, beEpochNo :: !EpochNo
, beEpochSafeInt :: !EpochSafeInt
, beEpochSafeInt :: !EpochSafeInt
, beForge :: !BlockForge
, beObservations :: [BlockObservation]
, bePropagation :: !(Distribution Float NominalDiffTime)
Expand Down Expand Up @@ -195,12 +198,11 @@ data SlotStats
, slRejectedTx :: !Word64
, slBlockNo :: !Word64
, slBlockless :: !Word64
, slEarliest :: !UTCTime
, slSpanCheck :: !NominalDiffTime
, slSpanLead :: !NominalDiffTime
, slSpanForge :: !NominalDiffTime
, slSpanCheck :: !(StrictMaybe NominalDiffTime)
, slSpanLead :: !(StrictMaybe NominalDiffTime)
, slSpanForge :: !(StrictMaybe NominalDiffTime)
, slMempoolTxs :: !Word64
, slTxsMemSpan :: !(Maybe NominalDiffTime)
, slSpanTxsMem :: !(StrictMaybe NominalDiffTime)
, slTxsCollected :: !Word64
, slTxsAccepted :: !Word64
, slTxsRejected :: !Word64
Expand Down Expand Up @@ -420,10 +422,10 @@ instance RenderTimeline SlotStats where
, Field 3 0 "forges" "For" "ge" $ IWord64 slCountForges
, Field 4 0 "CDBSnap" "CDB" "snap" $ IWord64 slChainDBSnap
, Field 3 0 "rejTxs" "rej" "txs" $ IWord64 slRejectedTx
, Field 7 0 "checkSpan" "check" "span" $ IDeltaT slSpanCheck
, Field 5 0 "leadSpan" "lead" "span" $ IDeltaT slSpanLead
, Field 5 0 "forgeSpan" "forg" "span" $ IDeltaT slSpanForge
, Field 4 0 "mempoolTxSpan" (t 4!!0) "span" $ IText (maybe "" show.slTxsMemSpan)
, Field 7 0 "checkSpan" "check" "span" $ IText (smaybe "" show.slSpanCheck)
, Field 5 0 "leadSpan" "lead" "span" $ IText (smaybe "" show.slSpanLead)
, Field 5 0 "forgeSpan" "forg" "span" $ IText (smaybe "" show.slSpanForge)
, Field 4 0 "mempoolTxSpan" (t 4!!0) "span" $ IText (smaybe "" show.slSpanTxsMem)
, Field 4 0 "txsColl" (t 4!!1) "cold" $ IWord64 slTxsCollected
, Field 4 0 "txsAcc" (t 4!!2) "accd" $ IWord64 slTxsAccepted
, Field 4 0 "txsRej" (t 4!!3) "rejd" $ IWord64 slTxsRejected
Expand Down
7 changes: 7 additions & 0 deletions bench/locli/src/Cardano/Analysis/Chain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ slotStart Genesis{..} =
. fromIntegral
. unSlotNo

impliedSlot :: Genesis -> UTCTime -> SlotNo
impliedSlot Genesis{..} =
SlotNo
. floor
. (/ slotLength)
. (`Time.diffUTCTime` systemStart)

sinceSlot :: UTCTime -> SlotStart -> NominalDiffTime
sinceSlot t (SlotStart start) = Time.diffUTCTime t start

Expand Down
1 change: 0 additions & 1 deletion bench/locli/src/Cardano/Analysis/ChainFilter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
{- HLINT ignore "Use head" -}
module Cardano.Analysis.ChainFilter (module Cardano.Analysis.ChainFilter) where

import Prelude (String)
import Cardano.Prelude hiding (head)

import Data.Aeson
Expand Down
Loading

0 comments on commit 0446c02

Please sign in to comment.