aboutsummaryrefslogtreecommitdiff
path: root/heatmaps/perf-to-inst-page.sh
diff options
context:
space:
mode:
authorTiancong Wang <tcwang@google.com>2019-05-06 15:42:43 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-05-17 18:38:15 -0700
commit3f06bf5fa1c53aa42959d351accc8888eb329343 (patch)
tree86be399d8cf24ff607f30a21f8b31634bffe4e4a /heatmaps/perf-to-inst-page.sh
parentadb9f7a366cb5e8ae5eb5c860da191e0418e8901 (diff)
downloadtoolchain-utils-3f06bf5fa1c53aa42959d351accc8888eb329343.tar.gz
toolchain-utils: Improve heatmap tool.
The overall goal of this patch is to improve heatmap tool in a way that facilitates the tool to be integrated into crosperf. The patch needs to make sure the heat_map.py is not only able to run as a standalone tool, but also is compatible to crosperf. It also adds functionality to the heatmap that when the address range of huge page (offset within the text section) is provided, the heatmap displays symbols within and outside of the region with different colors. This patch adds following improvements: 1. It adds support in heat_map.py that skips copying perf.data into the chroot again, if the provided path to perf.data is within a chroot. 2. It adds support in heatmap_generator.py to take in a range of huge page as (start, end). Update corresponding unit test. 3. It adds extensive unit tests for heat_map.py. The unit test tests both each functions and also makes sure it run as a standalone tool. BUG=chromium:956109 TEST=Tested locally and pass unit tests. Change-Id: I8008da51cceb0ad90df29042faf7a9d91d04f4b1 Reviewed-on: https://chromium-review.googlesource.com/1582523 Commit-Ready: Tiancong Wang <tcwang@google.com> Tested-by: Tiancong Wang <tcwang@google.com> Reviewed-by: Tiancong Wang <tcwang@google.com>
Diffstat (limited to 'heatmaps/perf-to-inst-page.sh')
-rwxr-xr-xheatmaps/perf-to-inst-page.sh68
1 files changed, 68 insertions, 0 deletions
diff --git a/heatmaps/perf-to-inst-page.sh b/heatmaps/perf-to-inst-page.sh
new file mode 100755
index 00000000..d6acd5ed
--- /dev/null
+++ b/heatmaps/perf-to-inst-page.sh
@@ -0,0 +1,68 @@
+#! /bin/bash -u
+# Copyright 2015 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This script takes the out.txt, generated by heatmap_generator.py
+# and sorted into a heatmap data file (inst-histo.txt) and then
+# call gnu plot to draw the heat map and the time map.
+# A heat map shows the overall hotness of instructions being executed
+# while the time map shows the hotness of instruction at different time.
+#
+# Usage:
+# ./perf-to-inst-page.sh HEATMAP_TITLE
+# HEATMAP_TITLE: the title to display on the heatmap
+
+HEAT_PNG="heat_map.png"
+TIMELINE_PNG="timeline.png"
+HEATMAP_TITLE=$1
+ENABLE_HUGEPAGE=$2
+
+heatmap_command="
+set terminal png size 600,450
+set xlabel \"Instruction Virtual Address (MB)\"
+set ylabel \"Sample Occurance\"
+set grid
+
+set output \"${HEAT_PNG}\"
+set title \"${HEATMAP_TITLE}\"
+"
+
+if [[ "${ENABLE_HUGEPAGE}" = "hugepage" ]]; then
+ hugepage_hist="inst-histo-hp.txt"
+ smallpage_hist="inst-histo-sp.txt"
+ cat out.txt | grep hugepage | awk '{print $3}' \
+ | sort -n | uniq -c > "${hugepage_hist}"
+ cat out.txt | grep smallpage | awk '{print $3}' \
+ | sort -n | uniq -c > "${smallpage_hist}"
+ # generate inst heat map
+ heatmap_in_hugepage=("'${hugepage_hist}' using \
+(\$2/1024/1024):1 with impulses notitle lt rgb 'red'")
+ heatmap_outside_hugepage=("'${smallpage_hist}' using \
+(\$2/1024/1024):1 with impulses notitle lt rgb 'blue'")
+ echo "
+ ${heatmap_command}
+ plot ${heatmap_in_hugepage}, ${heatmap_outside_hugepage}
+ " | gnuplot
+else
+ awk '{print $3}' out.txt | sort -n | uniq -c > inst-histo.txt
+ # generate inst heat map
+ echo "
+ ${heatmap_command}
+ plot 'inst-histo.txt' using (\$2/1024/1024):1 with impulses notitle
+ " | gnuplot
+fi
+
+# generate instruction page access timeline
+num=$(awk 'END {print NR+1}' out.txt)
+
+echo "
+set terminal png size 600,450
+set xlabel \"time (sec)\"
+set ylabel \"Instruction Virtual Address (MB)\"
+
+set output \"${TIMELINE_PNG}\"
+set title \"instruction page accessd timeline\"
+
+plot 'out.txt' using (\$0/$num*10):(\$3/1024/1024) with dots notitle
+" | gnuplot