Re: [PATCH v5] perf diff: Report noisy for cycles diff

2019-08-20 Thread Jin, Yao




On 8/20/2019 4:34 PM, Jiri Olsa wrote:

On Fri, Aug 16, 2019 at 10:13:43AM +0800, Jin Yao wrote:

SNIP


  static void
  hpp__entry_unpair(struct hist_entry *he, int idx, char *buf, size_t size)
  {
@@ -1662,6 +1794,10 @@ static void data__hpp_register(struct data__file *d, int 
idx)
fmt->color = hpp__color_cycles;
fmt->sort  = hist_entry__cmp_nop;
break;
+   case PERF_HPP_DIFF__CYCLES_HIST:
+   fmt->color = hpp__color_cycles_hist;
+   fmt->sort  = hist_entry__cmp_nop;
+   break;
default:
fmt->sort  = hist_entry__cmp_nop;
break;
@@ -1688,8 +1824,13 @@ static int ui_init(void)
 *   PERF_HPP_DIFF__RATIO
 *   PERF_HPP_DIFF__WEIGHTED_DIFF
 */
-   data__hpp_register(d, i ? compute_2_hpp[compute] :
- PERF_HPP_DIFF__BASELINE);
+   if (cycles_hist && i && (compute == COMPUTE_CYCLES)) {
+   data__hpp_register(d, PERF_HPP_DIFF__CYCLES);
+   data__hpp_register(d, PERF_HPP_DIFF__CYCLES_HIST);
+   } else {
+   data__hpp_register(d, i ? compute_2_hpp[compute] :
+ PERF_HPP_DIFF__BASELINE);
+   }



hum, why can't it be just like we treat other extra columns:

---
@@ -1687,6 +1823,7 @@ static int ui_init(void)
 *   PERF_HPP_DIFF__DELTA
 *   PERF_HPP_DIFF__RATIO
 *   PERF_HPP_DIFF__WEIGHTED_DIFF
+*   PERF_HPP_DIFF__CYCLES
 */
data__hpp_register(d, i ? compute_2_hpp[compute] :
  PERF_HPP_DIFF__BASELINE);
@@ -1704,6 +1841,9 @@ static int ui_init(void)
if (show_period)
data__hpp_register(d, i ? PERF_HPP_DIFF__PERIOD :
  
PERF_HPP_DIFF__PERIOD_BASELINE);
+
+   if (cycles_hist && i)
+   data__hpp_register(d, PERF_HPP_DIFF__CYCLES_HIST);


thanks,
jirka



Hi Jiri,

Yes, thanks, your code is better. Thanks so much!

Thanks
Jin Yao


Re: [PATCH v5] perf diff: Report noisy for cycles diff

2019-08-20 Thread Jiri Olsa
On Fri, Aug 16, 2019 at 10:13:43AM +0800, Jin Yao wrote:

SNIP

>  static void
>  hpp__entry_unpair(struct hist_entry *he, int idx, char *buf, size_t size)
>  {
> @@ -1662,6 +1794,10 @@ static void data__hpp_register(struct data__file *d, 
> int idx)
>   fmt->color = hpp__color_cycles;
>   fmt->sort  = hist_entry__cmp_nop;
>   break;
> + case PERF_HPP_DIFF__CYCLES_HIST:
> + fmt->color = hpp__color_cycles_hist;
> + fmt->sort  = hist_entry__cmp_nop;
> + break;
>   default:
>   fmt->sort  = hist_entry__cmp_nop;
>   break;
> @@ -1688,8 +1824,13 @@ static int ui_init(void)
>*   PERF_HPP_DIFF__RATIO
>*   PERF_HPP_DIFF__WEIGHTED_DIFF
>*/
> - data__hpp_register(d, i ? compute_2_hpp[compute] :
> -   PERF_HPP_DIFF__BASELINE);
> + if (cycles_hist && i && (compute == COMPUTE_CYCLES)) {
> + data__hpp_register(d, PERF_HPP_DIFF__CYCLES);
> + data__hpp_register(d, PERF_HPP_DIFF__CYCLES_HIST);
> + } else {
> + data__hpp_register(d, i ? compute_2_hpp[compute] :
> +   PERF_HPP_DIFF__BASELINE);
> + }


hum, why can't it be just like we treat other extra columns:

---
@@ -1687,6 +1823,7 @@ static int ui_init(void)
 *   PERF_HPP_DIFF__DELTA
 *   PERF_HPP_DIFF__RATIO
 *   PERF_HPP_DIFF__WEIGHTED_DIFF
+*   PERF_HPP_DIFF__CYCLES
 */
data__hpp_register(d, i ? compute_2_hpp[compute] :
  PERF_HPP_DIFF__BASELINE);
@@ -1704,6 +1841,9 @@ static int ui_init(void)
if (show_period)
data__hpp_register(d, i ? PERF_HPP_DIFF__PERIOD :
  
PERF_HPP_DIFF__PERIOD_BASELINE);
+
+   if (cycles_hist && i)
+   data__hpp_register(d, PERF_HPP_DIFF__CYCLES_HIST);


thanks,
jirka


[PATCH v5] perf diff: Report noisy for cycles diff

2019-08-15 Thread Jin Yao
This patch prints the stddev and hist for the cycles diff of
program block. It can help us to understand if the cycles
is noisy or not.

This patch is inspired by Andi Kleen's patch
https://lwn.net/Articles/600471/

We create new option '--cycles-hist'.

Example:

perf record -b ./div
perf record -b ./div
perf diff -c cycles

  # Baseline   [Program Block Range] Cycles 
Diff  Shared Object  Symbol
  #   
..  
.  
  #
  46.72% [div.c:40 -> div.c:40] 
   0  div[.] main
  46.72% [div.c:42 -> div.c:44] 
   0  div[.] main
  46.72% [div.c:42 -> div.c:39] 
   0  div[.] main
  20.54% [random_r.c:357 -> random_r.c:394] 
   1  libc-2.27.so   [.] __random_r
  20.54% [random_r.c:357 -> random_r.c:380] 
   0  libc-2.27.so   [.] __random_r
  20.54% [random_r.c:388 -> random_r.c:388] 
   0  libc-2.27.so   [.] __random_r
  20.54% [random_r.c:388 -> random_r.c:391] 
   0  libc-2.27.so   [.] __random_r
  17.04% [random.c:288 -> random.c:291] 
   0  libc-2.27.so   [.] __random
  17.04% [random.c:291 -> random.c:291] 
   0  libc-2.27.so   [.] __random
  17.04% [random.c:293 -> random.c:293] 
   0  libc-2.27.so   [.] __random
  17.04% [random.c:295 -> random.c:295] 
   0  libc-2.27.so   [.] __random
  17.04% [random.c:295 -> random.c:295] 
   0  libc-2.27.so   [.] __random
  17.04% [random.c:298 -> random.c:298] 
   0  libc-2.27.so   [.] __random
   8.40% [div.c:22 -> div.c:25] 
   0  div[.] compute_flag
   8.40% [div.c:27 -> div.c:28] 
   0  div[.] compute_flag
   5.14%   [rand.c:26 -> rand.c:27] 
   0  libc-2.27.so   [.] rand
   5.14%   [rand.c:28 -> rand.c:28] 
   0  libc-2.27.so   [.] rand
   2.15% [rand@plt+0 -> rand@plt+0] 
   0  div[.] rand@plt
   0.00%
  [kernel.kallsyms]  [k] __x86_indirect_thunk_rax
   0.00%   [do_mmap+714 -> do_mmap+732] 
 -10  [kernel.kallsyms]  [k] do_mmap
   0.00%   [do_mmap+737 -> do_mmap+765] 
   1  [kernel.kallsyms]  [k] do_mmap
   0.00%   [do_mmap+262 -> do_mmap+299] 
   0  [kernel.kallsyms]  [k] do_mmap
   0.00% [__x86_indirect_thunk_r15+0 -> __x86_indirect_thunk_r15+0] 
   7  [kernel.kallsyms]  [k] __x86_indirect_thunk_r15
   0.00%   [native_sched_clock+0 -> native_sched_clock+119] 
  -1  [kernel.kallsyms]  [k] native_sched_clock
   0.00%[native_write_msr+0 -> native_write_msr+16] 
 -13  [kernel.kallsyms]  [k] native_write_msr

When we enable the option '--cycles-hist', the output is

perf diff -c cycles --cycles-hist

  # Baseline   [Program Block Range] Cycles 
Diffstddev/Hist  Shared Object  Symbol
  #   
..  
.  .  
  #
  46.72% [div.c:40 -> div.c:40] 
   0  ± 37.8% ▁█▁▁██▁█   div[.] main
  46.72% [div.c:42 -> div.c:44] 
   0  ± 49.4% ▁▁▂█   div[.] main
  46.72% [div.c:42 -> div.c:39] 
   0  ± 24.1% ▃█▂▄▁▃▂▁   div[.] main
  20.54% [random_r.c:357 -> random_r.c:394] 
   1  ± 33.5% ▅▂▁█▃▁▂▁   libc-2.27.so   [.] __random_r
  20.54% [random_r.c:357 -> random_r.c:380] 
   0  ± 39.4% ▁▁█▁██▅▁   libc-2.27.so   [.] __random_r
  20.54% [random_r.c:388 -> random_r.c:388] 
   0 libc-2.27.so   [.] __random_r
  20.54% [random_r.c:388 -> random_r.c:391] 
   0  ± 41.2% ▁▃▁▂█▄▃▁   libc-2.27.so   [.] __random_r
  17.04%