Skip to content

Commit

Permalink
workbench: cluster run analysis derivation & workbench-smoke-analysis…
Browse files Browse the repository at this point in the history
… attr
  • Loading branch information
deepfire committed Mar 3, 2022
1 parent bc66d62 commit 0a6f6e4
Show file tree
Hide file tree
Showing 17 changed files with 105 additions and 50 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ shell-dev cluster-shell-dev cluster-shell-trace cluster-shell-dev-trace fixed: s

test-smoke: smoke ## Build the 'workbench-smoke-test', same as the Hydra job
smoke:
nix build -f 'default.nix' 'workbench-smoke-test'
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

shell: ## Enter Nix shell, CI mode (workbench run from Nix store)
nix-shell --max-jobs 8 --cores 0 --show-trace --argstr profileName ${PROFILE} ${ARGS}
Expand Down
2 changes: 1 addition & 1 deletion nix/supervisord-cluster/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ let
ByronGenesisFile = "../genesis/byron/genesis.json";
});

profileOutput =
materialise-profile =
{ profile }:
pkgs.runCommand "workbench-profile-outputs-${profile.name}-supervisord" {}
''
Expand Down
41 changes: 41 additions & 0 deletions nix/workbench/analyse.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{ profile
, workbench
}:

{ pkgs, run, trace ? false }:

let profile = { name = "stub"; }; #__fromJSON (__readFile "${run}/profile.json");
in
pkgs.runCommand "workbench-run-analysis-${profile.name}"
{ requiredSystemFeatures = [ "benchmark" ];
nativeBuildInputs = with pkgs.haskellPackages; with pkgs; [
bash
bech32
coreutils
gnused
jq
moreutils
nixWrapped
psmisc
python3Packages.supervisor
workbench
];
}
''
echo "analysing run: ${run}"
mkdir -p $out
ln -s ${run} $out/run
args=(
${pkgs.lib.optionalString trace "--trace"}
analyse
# --filters size-full
--outdir $out
standard
${run}
)
echo "wb ''${args[*]}" > $out/wb-invocation.sh
wb ''${args[@]}
''
11 changes: 6 additions & 5 deletions nix/workbench/analyse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,26 @@ EOF
}

analyse() {
local dump_logobjects= force_prefilter= prefilter_jq= self_args=() locli_args=() filters=() aws=
local dump_logobjects= force_prefilter= prefilter_jq= self_args=() locli_args=() filters=() aws= outdir=
while test $# -gt 0
do case "$1" in
--dump-logobjects ) dump_logobjects='true'; self_args+=($1);;
--force-prefilter ) force_prefilter='true'; self_args+=($1);;
--prefilter-jq ) prefilter_jq='true'; self_args+=($1);;
--filters ) local filter_names=('base')
filter_names+=($(echo $2 | sed 's_,_ _'))
local filter_paths=(${filter_names[*]/#/"bench/chain-filters/"})
local filter_paths=(${filter_names[*]/#/"$global_basedir/chain-filters/"})
local filter_files=(${filter_paths[*]/%/.json})
for f in ${filter_files[*]}
do test -f "$f" ||
fail "no such filter: $f"; done
locli_args+=(${filter_files[*]/#/--filter })
self_args+=($1 $2); shift;;
--rts ) self_args+=($1 $2); locli_args+=(+RTS $2 -RTS); shift;;
--outdir ) self_args+=($1 "$2"); outdir=$2; shift;;
* ) break;; esac; shift; done

if ! curl http://169.254.169.254/latest/meta-data 2>&1 | grep --quiet 404
if ! curl --connect-timeout=0.5 http://169.254.169.254/latest/meta-data 2>&1 | grep --quiet 404
then aws='true'; fi

## Work around the odd parallelism bug killing performance on AWS:
Expand Down Expand Up @@ -75,7 +76,7 @@ case "$op" in
local dir=$(run get "$name")
test -n "$dir" || fail "malformed run: $name"

local adir=$dir/analysis
local adir=${outdir:-$dir/analysis}
mkdir -p "$adir"

## 0. subset what we care about into the keyfile
Expand Down Expand Up @@ -137,7 +138,7 @@ case "$op" in
local dir=$(run get "$name")
test -n "$dir" || fail "malformed run: $name"

local adir=$dir/analysis
local adir=${outdir:-$dir/analysis}
mkdir -p "$adir"

## 0. subset what we care about into the keyfile
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
47 changes: 8 additions & 39 deletions nix/workbench/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ let

installPhase = ''
mkdir -p $out/bin
cp -a wb profiles *.sh *.jq $out/bin
cp -a wb chain-filters profiles *.sh *.jq $out/bin
'';

dontStrip = true;
Expand Down Expand Up @@ -160,40 +160,7 @@ let
runWorkbenchJqOnly "all-profiles.json" "profiles generate-all";
};

## ## This allows forwarding of Nix-expressed computation results to bash-land.
profileOutput =
{ profile
, backendProfileOutput ## Backend-specific results for forwarding
}:
runCommand "workbench-profile-outputs-${profile.name}"
{ buildInputs = [];
nodeServices =
__toJSON
(flip mapAttrs profile.node-services
(name: svc:
with svc;
{ inherit name;
service-config = serviceConfig.JSON;
start = startupScript;
config = nodeConfig.JSON;
topology = topology.JSON;
}));
generatorService =
with profile.generator-service;
__toJSON
{ name = "generator";
service-config = serviceConfig.JSON;
start = startupScript;
run-script = runScript.JSON;
};
passAsFile = [ "nodeServices" "generatorService" ];
}
''
mkdir $out
cp ${backendProfileOutput}/* $out
cp $nodeServicesPath $out/node-services.json
cp $generatorServicePath $out/generator-service.json
'';
materialise-profile = import ./profile.nix { inherit pkgs lib; };

with-workbench-profile =
{ pkgs, backend, envArgs, profileName }:
Expand All @@ -204,16 +171,18 @@ let
profile = workbenchProfiles.profiles."${profileName}"
or (throw "No such profile: ${profileName}; Known profiles: ${toString (__attrNames workbenchProfiles.profiles)}");

profileOut = profileOutput
profileOut = materialise-profile
{ inherit profile;
backendProfileOutput =
backend.profileOutput { inherit profile; };
backend.materialise-profile { inherit profile; };
};
in { inherit profile profileOut; };

run-analysis = import ./analyse.nix { inherit profile workbench; };
in

{
inherit workbench runWorkbench runJq with-workbench-profile;
inherit workbench runWorkbench runJq with-workbench-profile run-analysis;

inherit generateProfiles profileOutput shellHook;
inherit generateProfiles materialise-profile shellHook;
}
35 changes: 35 additions & 0 deletions nix/workbench/profile.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{ pkgs, lib }:
with lib;

{ profile
, backendProfileOutput ## Backend-specific results for forwarding
}:
pkgs.runCommand "workbench-profile-outputs-${profile.name}"
{ buildInputs = [];
nodeServices =
__toJSON
(flip mapAttrs profile.node-services
(name: svc:
with svc;
{ inherit name;
service-config = serviceConfig.JSON;
start = startupScript;
config = nodeConfig.JSON;
topology = topology.JSON;
}));
generatorService =
with profile.generator-service;
__toJSON
{ name = "generator";
service-config = serviceConfig.JSON;
start = startupScript;
run-script = runScript.JSON;
};
passAsFile = [ "nodeServices" "generatorService" ];
}
''
mkdir $out
cp ${backendProfileOutput}/* $out
cp $nodeServicesPath $out/node-services.json
cp $generatorServicePath $out/generator-service.json
''
4 changes: 4 additions & 0 deletions nix/workbench/profiles/node-services.nix
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ let
minSeverity = "Debug";
TraceMempool = true;
TraceTxInbound = true;
TraceBlockFetchClient = true;
TraceBlockFetchServer = true;
TraceChainSyncHeaderServer = true;
TraceChainSyncClient = true;
options = {
mapBackends = {
"cardano.node.resources" = [ "KatipBK" ];
Expand Down
8 changes: 4 additions & 4 deletions nix/workbench/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ case "$op" in
sort || true);;

compute-path )
echo -n "$global_rundir/$1";;
if test -f "$1/meta.json"
then echo -n "$1"
else echo -n "$global_rundir/$1"
fi;;

fix-legacy-run-structure | fix-legacy )
local usage="USAGE: wb run $op TAG"
Expand Down Expand Up @@ -100,9 +103,6 @@ case "$op" in
local tag=${1:?$usage}
local dir=$(run compute-path "$tag")

test "$(tr -d / <<<$tag)" = "$tag" ||
fatal "run tag has slashes: $tag"

jq_check_json "$dir"/meta.json ||
fatal "run $tag (at $dir) missing a file: meta.json"

Expand Down
2 changes: 2 additions & 0 deletions nix/workbench/wb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

set -euo pipefail

export LANG=C.UTF-8

global_basedir=${global_basedir:-$(realpath "$(dirname "$0")")}
global_mode='unknown'

Expand Down

0 comments on commit 0a6f6e4

Please sign in to comment.