Skip to content

Commit 2ed43b3

Browse files
committed
wb analyse: fix trace-frequencies for oddly-structured messages & less clutter in logs
1 parent 466fbe2 commit 2ed43b3

File tree

4 files changed

+24
-22
lines changed

4 files changed

+24
-22
lines changed

Diff for: bench/locli/src/Cardano/Analysis/API/Ground.hs

+3-4
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,9 @@ dumpObjects ident xs (JsonOutputFile f) = liftIO $ do
323323
dumpAssociatedObjects :: ToJSON a => String -> [(JsonLogfile, a)] -> ExceptT Text IO ()
324324
dumpAssociatedObjects ident xs = liftIO $
325325
flip mapConcurrently_ xs $
326-
\(JsonLogfile f, x) -> do
327-
progress ident (Q f)
328-
withFile (replaceExtension f $ ident <> ".json") WriteMode $ \hnd ->
329-
LBS.hPutStrLn hnd $ encode x
326+
\(JsonLogfile f, x) ->
327+
withFile (replaceExtension f $ ident <> ".json") WriteMode $ \hnd ->
328+
LBS.hPutStrLn hnd $ encode x
330329

331330
readAssociatedObjects :: forall a.
332331
FromJSON a => String -> [JsonLogfile] -> ExceptT Text IO [(JsonLogfile, a)]

Diff for: nix/workbench/analyse.sh

+7-4
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ case "$op" in
395395
-e 'chain-rejecta.json' \
396396
-e 'chain.json'
397397
))
398-
progress "analyse" "prettifying JSON data: ${analysis_jsons[*]}"
398+
progress "analyse" "prettifying JSON data: ${#analysis_jsons[*]} files"
399399
time json_compact_prettify "${analysis_jsons[@]}"
400400
progress "output" "run: $(white $run) subdir: $(yellow analysis)"
401401
;;
@@ -537,7 +537,7 @@ case "$op" in
537537
--slurpfile freqs "$adir"/logs-$mach.tracefreq.json
538538
done;;
539539

540-
trace-frequencies | trace-freq | freq )
540+
trace-frequencies | trace-freq | freq | tf )
541541
local new_only= sargs=()
542542
while test $# -gt 0
543543
do case "$1" in
@@ -548,7 +548,7 @@ case "$op" in
548548
local logfile=${1:?$usage}; shift
549549

550550

551-
trace_frequencies "$logfile" > "${logfile}.tracefreqs.json"
551+
trace_frequencies_json "$logfile" > "${logfile}.tracefreqs.json"
552552

553553
local src=$(wc -l <"$logfile")
554554
local res=$(cut -d' ' -f1 "${logfile}.trace-freqs" |
@@ -632,7 +632,10 @@ trace_frequencies_json() {
632632
jq 'reduce inputs as $line
633633
( {};
634634
( $line
635-
| (try .ns[0] // .ns) + ":" + (.data.kind //.data.val.kind)
635+
| (try .ns[0] // .ns)
636+
+ ":"
637+
+ (if .data | type != "object" then .data | type
638+
else (.data.kind //.data.val.kind) end)
636639
) as $key
637640
| (.[$key] // 0) as $acc
638641
| . + { "\($key)": ($acc + 1) }

Diff for: nix/workbench/run.sh

+12-12
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ case "$op" in
9393
echo $global_rundir;;
9494

9595
list-runs | runs | lsr )
96-
local usage="USAGE: wb run $op [--on-remote | -or | -r]"
96+
local usage="USAGE: wb run $op [--remote | -r]"
9797
local on_remote=
9898
while test $# -gt 0
9999
do case "$1" in
100-
--on-remote | -or | -r ) on_remote='true';;
100+
--remote | -r ) on_remote='true';;
101101
* ) msg "FATAL: list, unknown flag '$1'"; usage_run;;
102102
esac; shift; done
103103

@@ -109,14 +109,14 @@ case "$op" in
109109
fi;;
110110

111111
list-remote | remote | lsrr ) ## Convenience alias for 'list'
112-
run "${sargs[@]}" list --on-remote;;
112+
run list --remote;;
113113

114114
list-verbose | verb | lsrv )
115-
local usage="USAGE: wb run $op [--on-remote | -or | -r] [--limit [N=10] | -n N]"
115+
local usage="USAGE: wb run $op [--remote | -r] [--limit [N=10] | -n N]"
116116
local on_remote= limit=10
117117
while test $# -gt 0
118118
do case "$1" in
119-
--on-remote | -or | -r ) on_remote='true';;
119+
--remote | -r ) on_remote='true';;
120120
--limit | -n ) limit=$2; shift;;
121121
* ) msg "FATAL: list-verbose, unknown flag '$1'"; usage_run;;
122122
esac; shift; done
@@ -129,14 +129,14 @@ case "$op" in
129129
fi;;
130130

131131
list-verbose-remote | rverb | lsrvr ) ## Convenience alias for 'list-verbose'
132-
run "${sargs[@]}" list-verbose --on-remote;;
132+
run list-verbose --remote;;
133133

134134
list-sets | sets | lss )
135-
local usage="USAGE: wb run $op [--on-remote | -or | -r]"
135+
local usage="USAGE: wb run $op [--remote | -r]"
136136
local on_remote=
137137
while test $# -gt 0
138138
do case "$1" in
139-
--on-remote | -or | -r ) on_remote='true';;
139+
--remote | -r ) on_remote='true';;
140140
* ) msg "FATAL: list-sets, unknown flag '$1'"; usage_run;;
141141
esac; shift; done
142142

@@ -148,7 +148,7 @@ case "$op" in
148148
fi;;
149149

150150
list-sets-remote | rsets | lssr ) ## Convenience alias for 'list-sets'
151-
run "${sargs[@]}" list-sets --on-remote;;
151+
run list-sets --remote;;
152152

153153
set-add | add | sa )
154154
local usage="USAGE: wb run $op NAME [RUN..]"
@@ -163,12 +163,12 @@ case "$op" in
163163
done);;
164164

165165
run-or-set | ros )
166-
local usage="USAGE: wb run $op [--query] [--on-remote | -or | -r] NAME"
166+
local usage="USAGE: wb run $op [--query] [--remote | -r] NAME"
167167
local query= get_args=() on_remote=
168168
while test $# -gt 0
169169
do case "$1" in
170170
--try | --query ) get_args+=($1); query='true';;
171-
--on-remote | -or | -r ) on_remote='true';;
171+
--remote | -r ) on_remote='true';;
172172
--* ) msg "FATAL: run-or-set, unknown flag '$1'"; usage_run;;
173173
* ) break;; esac; shift; done
174174

@@ -619,7 +619,7 @@ EOF
619619
local usage="USAGE: wb run $op RUN.."
620620
local runs=() run
621621
for rs in $*
622-
do runs+=($(run "${sargs[@]}" run-or-set --query --on-remote $rs || echo $rs))
622+
do runs+=($(run "${sargs[@]}" run-or-set --query --remote $rs || echo $rs))
623623
done
624624
if test $# = 0; then runs=(current); fi
625625

Diff for: nix/workbench/wb

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ usage_extra() {
8484
block-propagation blockprop bp
8585
performance perf
8686
performance-host perf-host
87-
trace-frequencies trace-freq freq
87+
trace-frequencies trace-freq freq tf
8888
chain-rejecta-reasons chain-rejecta rejecta
8989
$(color white)
9090
EOF
@@ -308,7 +308,7 @@ main() {
308308
| block-propagation | blockprop | bp \
309309
| performance | perf \
310310
| performance-host | perf-host \
311-
| trace-frequencies | trace-freq | freq \
311+
| trace-frequencies | trace-freq | freq | tf \
312312
| chain-rejecta-reasons | chain-rejecta | rejecta \
313313
) analyse $op "$@";;
314314

0 commit comments

Comments
 (0)