[PATCH v17 11/15] tools/damon/wss: Implement '--thres' option

From: SeongJae Park
Date: Mon Jul 06 2020 - 07:57:38 EST


From: SeongJae Park <sjpark@xxxxxxxxx>

Currently, 'wss' treats every region as working set if accessed at least
once. Someone who want to know performance important working set only
would want to ignore regions having low access frequency. '--thres'
option can be used to set the minimal access frequency of the regions to
be classified as the workingset.

Using this, users can plot the reuse histogram. For example:

$ damo record $(pidof raytrace)
$ for t in {1..20}; do ./tools/damon/damo report wss --thres $t | \
grep avr | awk -v reuse_time=$(( (21 - t) * 5 )) \
'{print reuse_time " " $3}'; done
100 12838416
95 2222623
90 1585480
85 422890
80 67040
75 45218
70 13242
65 12896
60 12136
55 10872
50 9648
45 8136
40 7052
35 6304
30 5736
25 5404
20 5305
15 5187
10 5069
5 4873

Above command shows the reuse histogram of parsec3.raytrace. Remind
that the sampling interval and aggregation interval are 5ms and 100ms
by default and this command used the default values. So, the above
output means that about 12MB of memory region was reused within 100 ms
while only about 2MB of memory region was reused within 95 ms, then
about 1.5MB within 90ms, and so on, in average.

Signed-off-by: SeongJae Park <sjpark@xxxxxxxxx>
---
tools/damon/wss.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/damon/wss.py b/tools/damon/wss.py
index b43065176cfd..d2a1b149e3ea 100644
--- a/tools/damon/wss.py
+++ b/tools/damon/wss.py
@@ -17,6 +17,8 @@ def set_argparser(parser):
parser.add_argument('--range', '-r', type=int, nargs=3,
metavar=('<start>', '<stop>', '<step>'),
help='range of wss percentiles to print')
+ parser.add_argument('--thres', '-t', type=int, metavar='<# accesses>',
+ help='minimal number of accesses for treated as working set')
parser.add_argument('--sortby', '-s', choices=['time', 'size'],
help='the metric to be used for the sort of the working set sizes')
parser.add_argument('--plot', '-p', type=str, metavar='<file>',
@@ -67,7 +69,7 @@ def main(args=None):
wss = 0
for p in snapshot:
# Ignore regions not accessed
- if p[1] <= 0:
+ if p[1] < args.thres:
continue
wss += p[0]
wss_dist.append(wss)
--
2.17.1