perf mem: Describe overhead calculation in brief
Namhyung Kim
maintainerPATCH 1/3 perf mem: Describe overhead calculation in brief
From: Ravi Bangoria <[email protected]>
Unlike perf-report which uses sample period for overhead calculation, perf-mem overhead is calculated using sample weight. Describe perf-mem overhead calculation method in it's man page.
--- tools/perf/Documentation/perf-mem.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
tools/perf/Documentation/perf-mem.txt +19 -0
@@ -137,6 +137,25 @@ REPORT OPTIONS In addition, for report all perf report options are valid, and for record all perf record options. +OVERHEAD CALCULATION +-------------------- +Unlike linkperf:perf-report[1], which calculates overhead from the actual +sample period, perf-mem overhead is calculated using sample weight. E.g. +there are two samples in perf.data file, both with the same sample period, +but one sample with weight 180 and the other with weight 20: + + $ perf script -F period,data_src,weight,ip,sym + 100000 629080842 |OP LOAD|LVL L3 hit|... 20 7e69b93ca524 strcmp + 100000 1a29081042 |OP LOAD|LVL RAM hit|... 180 ffffffff82429168 memcpy + + $ perf report -F overhead,symbol + 50% [.] strcmp + 50% [k] memcpy + + $ perf mem report -F overhead,symbol + 90% [k] memcpy + 10% [.] strcmp + SEE ALSO -------- linkperf:perf-record[1], linkperf:perf-report[1], linkperf:perf-arm-spe[1]
Signature · 1 line
2.49.0.1151.ga128411c76-goog
Namhyung Kim
maintainerPATCH 2/3 perf mem: Display sort order only if it's available
IOW it's not used when -F option is used alone. Let's make it conditional to skip printing incorrect information.
--- tools/perf/builtin-report.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/builtin-report.c +4 -1
@@ -529,7 +529,10 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct reportif (rep->mem_mode) { ret +=fprintf (fp,"\n# Total weight : %" PRIu64, nr_events); - ret +=fprintf (fp,"\n# Sort order : %s" , sort_order ? : default_mem_sort_order); +if (sort_order || !field_order) { + ret +=fprintf (fp,"\n# Sort order : %s" , + sort_order ? : default_mem_sort_order); + } }else ret +=fprintf (fp,"\n# Event count (approx.): %" PRIu64, nr_events);
Signature · 1 line
2.49.0.1151.ga128411c76-goog
Namhyung Kim
maintainerPATCH 3/3 perf mem: Show absolute percent in mem_stat output
In reply to Namhyung KimCurrently the output sums up to 100% for each entry. But it can be confusing when it's displayed with 'overhead'.
Before:
$ perf mem report -F overhead,sample,cache,comm
...
# -------------- Cache --------------
# Overhead Samples L1 L2 L3 L1-buf Other Command
# ........ ............ ................................... ...............
#
25.38% 517 34.6% 0.0% 15.8% 23.3% 26.2% swapper
9.03% 239 35.4% 0.8% 9.1% 22.1% 32.6% chrome
8.61% 233 45.3% 1.2% 8.9% 22.7% 21.9% Chrome_ChildIOT
7.81% 189 33.6% 0.4% 5.5% 35.9% 24.6% Isolated Web Co
3.73% 103 40.4% 0.3% 2.7% 39.4% 17.2% gnome-shellLet's convert it to use absolute percent value so that it can add up to the overhead for that entry.
After:
# -------------- Cache --------------
# Overhead Samples L1 L2 L3 L1-buf Other Command
# ........ ............ ................................... ...............
#
25.38% 517 8.8% 0.0% 4.0% 5.9% 6.7% swapper
9.03% 239 3.2% 0.1% 0.8% 2.0% 2.9% chrome
8.61% 233 3.9% 0.1% 0.8% 2.0% 1.9% Chrome_ChildIOT
7.81% 189 2.6% 0.0% 0.4% 2.8% 1.9% Isolated Web Co
3.73% 103 1.5% 0.0% 0.1% 1.5% 0.6% gnome-shellThis aligns well with the existing 'mem' sort key.
$ perf mem report -s comm,mem -H
...
#
# Overhead Samples Command / Memory access
# ......................... ..........................................
#
25.38% 517 swapper
8.78% 150 L1 hit
6.66% 72 RAM hit
5.92% 137 LFB/MAB hit
4.02% 157 L3 hit
0.00% 1 L3 miss
9.03% 239 chrome
3.19% 117 L1 hit
2.94% 35 RAM hit
1.99% 48 LFB/MAB hit
0.82% 32 L3 hit
0.08% 5 L2 hit
0.00% 2 L3 missWe can add an option or a config to change the setting later.
--- tools/perf/ui/hist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/ui/hist.c +1 -1
@@ -172,7 +172,7 @@ int hpp__fmt_mem_stat(struct perf_hpp_fmt *fmt __maybe_unused, struct perf_hpp *assert (mem_stat_idx !=-1 );for (int i =0 ; i <MEM_STAT_LEN ; i++) - total += he->mem_stat[mem_stat_idx].entries[i]; + total += hists->mem_stat_total[mem_stat_idx].entries[i];assert (total !=0 );for (int i =0 ; i <MEM_STAT_LEN ; i++) {
Signature · 1 line
2.49.0.1151.ga128411c76-goog
Quoted 8 lines · Namhyung Kim
From: Ravi Bangoria <[email protected]>
Unlike perf-report which uses sample period for overhead calculation, perf-mem overhead is calculated using sample weight. Describe perf-mem overhead calculation method in it's man page.
Signed-off-by Ravi Bangoria <[email protected]>Signed-off-by Namhyung Kim <[email protected]>
For whole series:
Quoted 37 lines
--- tools/perf/Documentation/perf-mem.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)tools/perf/Documentation/perf-mem.txt +19
-0@@ -137,6 +137,25 @@ REPORT OPTIONS In addition, for report all perf report options are valid, and for record all perf record options. +OVERHEAD CALCULATION +-------------------- +Unlike linkperf:perf-report[1], which calculates overhead from the actual +sample period, perf-mem overhead is calculated using sample weight. E.g. +there are two samples in perf.data file, both with the same sample period, +but one sample with weight 180 and the other with weight 20: + + $ perf script -F period,data_src,weight,ip,sym + 100000 629080842 |OP LOAD|LVL L3 hit|... 20 7e69b93ca524 strcmp + 100000 1a29081042 |OP LOAD|LVL RAM hit|... 180 ffffffff82429168 memcpy + + $ perf report -F overhead,symbol + 50% [.] strcmp + 50% [k] memcpy + + $ perf mem report -F overhead,symbol + 90% [k] memcpy + 10% [.] strcmp + SEE ALSO -------- linkperf:perf-record[1], linkperf:perf-report[1], linkperf:perf-arm-spe[1]Signature · 1 line
2.49.0.1151.ga128411c76-goog
Quoted 7 lines · Leo Yan
Quoted 6 lines · Namhyung Kim
From: Ravi Bangoria <[email protected]>
Unlike perf-report which uses sample period for overhead calculation, perf-mem overhead is calculated using sample weight. Describe perf-mem overhead calculation method in it's man page.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Ravi Bangoria <[email protected]>Signed-off-by Namhyung Kim <[email protected]>For whole series:
Reviewed-by Leo Yan <[email protected]>
Thanks, applied to perf-tools-next,
- Arnaldo