Skip to content

Commit

Permalink
ML colors
Browse files Browse the repository at this point in the history
  • Loading branch information
Silvano Ravotto committed Jun 17, 2021
1 parent a258e78 commit 418e943
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
42 changes: 42 additions & 0 deletions capture.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

label="perf"
iterations=1
sleep=0
dir=/tmp/$$


OPTIND=1
while getopts "l:i:s:d:" opt; do
case "$opt" in
l) label=$OPTARG ;;
i) iterations=$OPTARG ;;
s) sleep=$OPTARG ;;
d) dir=$OPTARG ;;
\?) echo "Usage: ./capture.sh [-d output_dir] [-s sleep] [-i iterations] [-l label]" >&2;
echo "Defaults output_dir=/tmp/[pid] sleep=0 iterations=1 label=perf" >&2;
exit 1 ;;
esac
done
shift $((OPTIND-1))


echo "Running perf $iterations times. Sleeping $sleep seconds after each run"
echo "Output=$dir Label=$label"

mkdir -p $dir
host=`hostname -s`

> $dir/$host.txt
for i in `seq 1 $iterations`
do
date=`date +%Y%m%d_%H%M%S`
perf record -N -F 99 -ag -e cycles:pp --call-graph dwarf,4096 -o $dir/${label}_${host}_${date}.data -- sleep 60
echo $dir/${label}_${host}_${date} >> $dir/$host.txt
sleep $sleep
done

for f in `cat $dir/$host.txt`
do
perf script -f -i $f.data | sed 's/V8 WorkerThread/v8WorkerThread/' | ./stackcollapse-perf.pl | ./flamegraph.pl --colors ml > $f.svg
done
45 changes: 45 additions & 0 deletions flamegraph.pl
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,33 @@ sub color {
}

# multi palettes
if (defined $type and $type eq "ml") {
if ($name =~ /xdmp::/) { # XDMP
$type = "aqua";
} elsif ($name =~ /svc::/) { # SVC
$type = "green"
} elsif ($name =~ m:_\[j\]$:) { # jit annotation
$type = "blue";
} elsif ($name =~ m:_\[i\]$:) { # inline annotation
$type = "orange";
} elsif ($name =~ m:^L?(java|org|com|io|sun)/:) { # Java
$type = "purple";
} elsif ($name =~ /v8::/) { # v8
$type = "yellow"
} elsif ($name =~ /core::/) {
$type = "grey"
} elsif ($name =~ /Microsoft/) {
$type = "brown"
} elsif ($name =~ /CNTK/) {
$type = "brown"
} elsif ($name =~ /_kmp_/) {
$type = "white"
} elsif ($name =~ /MarkLogic/) {
$type = "white"
} else { # system
$type = "red";
}
}
if (defined $type and $type eq "java") {
# Handle both annotations (_[j], _[i], ...; which are
# accurate), as well as input that lacks any annotations, as
Expand Down Expand Up @@ -506,6 +533,24 @@ sub color {
my $g = 90 + int(65 * $v1);
return "rgb($r,$g,0)";
}
if (defined $type and $type eq "grey") {
my $r = 90 + int(65 * $v1);
my $g = 90 + int(65 * $v1);
my $b = 90 + int(65 * $v1);
return "rgb($r,$g,$b)";
}
if (defined $type and $type eq "brown") {
my $r = 120 + int(5 * $v1);
my $g = 100 + int(5 * $v1);
my $b = 80 + int(5 * $v1);
return "rgb($r,$g,$b)";
}
if (defined $type and $type eq "white") {
my $r = 255 - int(25 * $v1);
my $g = 255 - int(25 * $v1);
my $b = 255 - int(25 * $v1);
return "rgb($r,$g,$b)";
}

return "rgb(0,0,0)";
}
Expand Down

0 comments on commit 418e943

Please sign in to comment.