Skip to content

Commit

Permalink
Merge #2956
Browse files Browse the repository at this point in the history
2956: workbench:  block propagation analysis improvements r=deepfire a=deepfire

In the workbench / log analysis:

1. Finalise block propagation analysis
2. Improve concurrency
3. Improve timeline rendering
4. Fix issues

Co-authored-by: Kosyrev Serge <serge.kosyrev@iohk.io>
  • Loading branch information
iohk-bors[bot] and deepfire committed Jul 27, 2021
2 parents f69205c + 92dec64 commit 7e999e4
Show file tree
Hide file tree
Showing 19 changed files with 737 additions and 539 deletions.
14 changes: 6 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ CLUSTER_PROFILE ?= default-alzo
CLUSTER_ARGS_EXTRA ?=

cluster-shell:
nix-shell --max-jobs 8 --cores 0 --argstr clusterProfile ${CLUSTER_PROFILE} --arg 'autoStartCluster' true ${CLUSTER_ARGS_EXTRA}

cluster-shell-dev: CLUSTER_ARGS_EXTRA += --arg 'workbenchDevMode' true
cluster-shell-trace: CLUSTER_ARGS_EXTRA += --trace
large-state-cluster-shell-trace: CLUSTER_ARGS_EXTRA += --trace
large-state-cluster-shell: CLUSTER_PROFILE = k2-10ep-2000kU-500kD-nobs-mary
large-state-cluster-shell-trace: CLUSTER_PROFILE = k2-10ep-2000kU-500kD-nobs-mary
cluster-shell-dev cluster-shell-trace large-state-cluster-shell large-state-cluster-shell-trace: cluster-shell
nix-shell --max-jobs 8 --cores 0 --show-trace --argstr clusterProfile ${CLUSTER_PROFILE} --arg 'autoStartCluster' true ${CLUSTER_ARGS_EXTRA}

cluster-shell-dev: CLUSTER_ARGS_EXTRA += --arg 'workbenchDevMode' true
cluster-shell-trace: CLUSTER_ARGS_EXTRA += --argstr 'autoStartClusterArgs' '--trace --trace-workbench'
cluster-shell-dev-trace: CLUSTER_ARGS_EXTRA += --arg 'workbenchDevMode' true --argstr 'autoStartClusterArgs' '--trace --trace-workbench'
cluster-shell-dev cluster-shell-trace cluster-shell-dev-trace: cluster-shell

cli node:
cabal --ghc-options="+RTS -qn8 -A32M -RTS" build cardano-$@
Expand Down
52 changes: 31 additions & 21 deletions nix/supervisord-cluster/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -172,54 +172,64 @@ EOF
export PATH=$PATH:${path}
wb backend assert-is supervisor
wb backend pre-run-hook "${stateDir}"
wb backend assert-stopped
wb_run_allocate_args=(
--cache-dir "${cacheDir}"
--base-port ${toString basePort}
--stagger-ports
--
--port-shift-ekg 100
--port-shift-prometheus 200
--supervisor-conf "${backend.supervisord.mkSupervisorConf profile}"
)
wb run allocate $batch_name ${profile.name} "''${wb_run_allocate_args[@]}"
rm -f "${stateDir}"
ln -sf run/current "${stateDir}"
current_run_path=$(wb run current-path)
${workbench.initialiseProfileRunDirShellScript profile "$current_run_path"}
wb_run_start_args=(
--supervisor-conf "${backend.supervisord.mkSupervisorConf profile}"
)
wb run start "''${run_start_flags[@]}" $(wb run current-tag) "''${wb_run_start_args[@]}"
wb run start "''${run_start_flags[@]}" $(wb run current-tag)
echo 'workbench: cluster started. Run `stop-cluster` to stop'
'';

stop = pkgs.writeScriptBin "stop-cluster" ''
set -euo pipefail
while test $# -gt 0
do case "$1" in
--trace | --debug ) set -x;;
--trace | --debug ) set -x;;
--trace-wb | --trace-workbench ) export WORKBENCH_EXTRA_FLAGS=--trace;;
* ) break;; esac; shift; done
wb run stop $(wb run current-tag)
'';

restart = pkgs.writeScriptBin "restart-cluster" ''
set -euo pipefail
wb_flags=()
wb_run_restart_flags=()
while test $# -gt 0
do case "$1" in
--no-generator | --no-gen ) wb_run_restart_flags+=($1);;
--trace | --debug | --trace-wb | --trace-workbench )
wb_flags+=(--trace);;
--help ) cat <<EOF
${startClusterUsage}
EOF
exit 1;;
* ) break;; esac; shift; done
${pkgs.python3Packages.supervisor}/bin/supervisorctl stop all
if wb backend is-running
then
if test -f "${stateDir}/supervisor/cardano-node.pids"
then kill $(<${stateDir}/supervisor/supervisord.pid) $(<${stateDir}/supervisor/cardano-node.pids)
else pkill supervisord
fi
echo "workbench: cluster terminated"
rm -f ${stateDir}/supervisor/supervisord.pid ${stateDir}/supervisor/cardano-node.pids
else
echo "workbench: cluster is not running"
fi
wb "''${wb_flags[@]}" run restart "''${wb_run_restart_flags[@]}"
echo "workbench: alternate command for this action: wb run restart"
'';

in
{
inherit workbench;
inherit (workbenchProfiles) profilesJSON;
inherit profile stateDir start stop;
inherit profile stateDir start stop restart;
}
25 changes: 13 additions & 12 deletions nix/workbench/analyse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,24 @@ usage_analyse() {
Options of 'analyse' command:
--reanalyse Skip the preparatory steps and launch 'locli' directly
--time Time the 'locli' executable runs
EOF
}

analyse() {
local skip_preparation= time= dump_logobjects=
local skip_preparation= time= dump_logobjects= args=()
while test $# -gt 0
do case "$1" in
--reanalyse | --re ) skip_preparation='true';;
--dump-logobjects ) dump_logobjects='true';;
--time ) time='eval time';;
--reanalyse | --re ) skip_preparation='true'; args+=($1);;
--dump-logobjects ) dump_logobjects='true'; args+=($1);;
* ) break;; esac; shift; done

local op=${1:-$(usage_analyse)}; shift

case "$op" in
block-propagation | bp )
local usage="USAGE: wb analyse $op [RUN-NAME=current]"
local usage="USAGE: wb analyse $op [RUN-NAME=current].."

local name=${1:-current}
local name=${1:-current}; shift
local dir=$(run get "$name")
local adir=$dir/analysis
if test -z "$dir"
Expand Down Expand Up @@ -82,8 +80,11 @@ case "$op" in
if test -n "$dump_logobjects"; then
locli_args+=(--logobjects-json "$adir"/logs-cluster.logobjects.json); fi

${time} locli 'analyse' 'block-propagation' \
"${locli_args[@]}" "$adir"/*.flt.json;;
time locli 'analyse' 'block-propagation' \
"${locli_args[@]}" "$adir"/*.flt.json

## More than one run passed?
test $# -gt 0 && analyse ${args[*]} block-propagation "$@";;

grep-filtered-logs | grep | g )
local usage="USAGE: wb analyse $op BLOCK [MACHSPEC=*] [RUN-NAME=current]"
Expand Down Expand Up @@ -132,7 +133,7 @@ case "$op" in
locli analyse substring-keys | grep -v 'Temporary modify' > "$keyfile"

if test "$mach" = 'all'
then local machs=($(wb run list-hosts $name))
then local machs=($(run list-hosts $name))
else local machs=($mach); fi

for mach in ${machs[*]}
Expand Down Expand Up @@ -164,8 +165,8 @@ case "$op" in
if test -n "$dump_logobjects"; then
locli_args+=(--logobjects-json "$adir"/logs-$mach.logobjects.json); fi

${time} locli 'analyse' 'machine-timeline' \
"${locli_args[@]}" "$consolidated"
time locli 'analyse' 'machine-timeline' \
"${locli_args[@]}" "$consolidated"
) &
done

Expand Down
41 changes: 24 additions & 17 deletions nix/workbench/backend.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
usage_backend() {
usage "backend" "Abstract over cluster backend operations" <<EOF
is-running Test if cluster is running
is-running RUNDIR
Test if the cluster specified by the run directory
is currently running
get-node-socket-path RUNDIR
Given a run directory, print the node socket path
Expand All @@ -10,15 +12,18 @@ usage_backend() {
Extend the environment JSON file with backend-specific
environment config
allocate-run RUNDIR
describe-run RUNDIR
pre-run-hook RUNDIR
lostream-fixup-jqargs RUNDIR
lostream-fixup-jqexpr
start-cluster RUNDIR
Start the cluster nodes
start-generator RUNDIR
Start generator
cleanup-cluster RUNDIR
Wipe cluster state to pristine
stop-cluster RUNDIR
lostream-fixup-jqargs RUNDIR
lostream-fixup-jqexpr
assert-is BACKEND-NAME
Check that the current backend is as expected
Expand All @@ -31,27 +36,29 @@ backend() {
local op=${1:-$(usage_backend)} # No need to shift -- backends will use the op.

case "${op}" in
is-running ) $WORKBENCH_BACKEND "$@";;
get-node-socket-path ) $WORKBENCH_BACKEND "$@";;
record-extended-env-config ) $WORKBENCH_BACKEND "$@";;
describe-run ) $WORKBENCH_BACKEND "$@";;
pre-run-hook ) $WORKBENCH_BACKEND "$@";;
start-cluster ) $WORKBENCH_BACKEND "$@";;
start-generator ) $WORKBENCH_BACKEND "$@";;
lostream-fixup-jqargs ) $WORKBENCH_BACKEND "$@";;
lostream-fixup-jqexpr ) $WORKBENCH_BACKEND "$@";;
is-running ) backend_$WORKBENCH_BACKEND "$@";;
get-node-socket-path ) backend_$WORKBENCH_BACKEND "$@";;
record-extended-env-config ) backend_$WORKBENCH_BACKEND "$@";;
allocate-run ) backend_$WORKBENCH_BACKEND "$@";;
describe-run ) backend_$WORKBENCH_BACKEND "$@";;
start-cluster ) backend_$WORKBENCH_BACKEND "$@";;
start-generator ) backend_$WORKBENCH_BACKEND "$@";;
cleanup-cluster ) backend_$WORKBENCH_BACKEND "$@";;
stop-cluster ) backend_$WORKBENCH_BACKEND "$@";;
lostream-fixup-jqargs ) backend_$WORKBENCH_BACKEND "$@";;
lostream-fixup-jqexpr ) backend_$WORKBENCH_BACKEND "$@";;

## Handle non-generic calls:
passthrough | pass ) $WORKBENCH_BACKEND "$@";;
passthrough | pass ) backend_$WORKBENCH_BACKEND "$@";;

assert-is )
local usage="USAGE: wb run $op BACKEND-NAME"
local name=${2:?$usage}

## Check the backend echoes own name:
local actual_name=$($WORKBENCH_BACKEND name)
local actual_name=$(backend_$WORKBENCH_BACKEND name)
if test "$actual_name" != "$name"
then fatal "Workbench is broken: '$WORKBENCH_BACKEND name' returned: '$actual_name'"; fi
then fatal "Workbench is broken: 'workbench_$WORKBENCH_BACKEND name' returned: '$actual_name'"; fi
;;

assert-stopped )
Expand Down
2 changes: 1 addition & 1 deletion nix/workbench/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ let
else "nix-exes+checkout-wb";

shellHook = ''
export WORKBENCH_BACKEND=${./.}/supervisor.sh
export WORKBENCH_BACKEND=supervisor
${optionalString workbenchDevMode
''
Expand Down
1 change: 0 additions & 1 deletion nix/workbench/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ git_repo_commit_description() {
local commit=$(git -C "$repo" rev-parse 'HEAD' 2>/dev/null || true)

test -n "$commit" && {
git -C "$repo" fetch
git -C "$repo" describe --match '[0-9].*' --tags $commit 2>/dev/null |
cut -d'-' -f1,2 | tr -d '\n'
git -C "$repo" diff --exit-code --quiet || echo '-modified'
Expand Down
5 changes: 4 additions & 1 deletion nix/workbench/locli/locli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ library
Cardano.Analysis.Profile
Cardano.Analysis.TopHandler

Cardano.Analysis.API
Cardano.Analysis.BlockProp
Cardano.Analysis.Driver
Cardano.Analysis.MachTimeline
Expand All @@ -44,6 +45,7 @@ library
, cardano-config
, cardano-prelude
, containers
, deepseq
, directory
, filepath
, file-embed
Expand All @@ -54,6 +56,7 @@ library
, optparse-generic
, ouroboros-network
, process
, quiet
, scientific
, split
, statistics
Expand Down Expand Up @@ -87,7 +90,7 @@ executable locli
ghc-options: -threaded
-Wall
-rtsopts
"-with-rtsopts=-T"
"-with-rtsopts=-T -N4 -A8m"
build-depends: base
, cardano-prelude
, locli
Expand Down
Loading

0 comments on commit 7e999e4

Please sign in to comment.