Skip to contentSkip to conversation

perf tools miscellaneous questions

DISCUSSION Francis Moreau 3 participants 3 messages Nov 3, 2010

lore
Share & tools
lore
#0 lore raw

Hello,

I'm trying to use perf-tools and also to learn some internals about them. So I prefer to ask all of them in one email.

The first one is about the list of pre-defined events given by perf-list. I couldn't find any documentations that describes these events so excuse me if the question is stupid.

What's the difference between 'cpu-clock' and 'task-clock' event ?

What's exactly the 'cache-misses' event ? does it include both instructions _and_ data cache misses ? both L1 and L2 caches ?

I was expecting so but the following command makes me wondering:

  $ perf stat -e cache-misses:u,l1d-loads-misses:u true
    Performance counter stats for 'true':
                763  cache-misses            
                874  L1-dcache-load-misses   

        0.000916609  seconds time elapsed

Here cache-misses < L1-dcache-load-misses.

The last question is about the source code annotation done by perf-report. I'm using it to locate the place in my code that generates the most data cache miss events. I can read this during a perf-report session:

[...]

    0.00 :           df215:       c3                      retq
    0.00 :           df216:       66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax,%rax,1)
    0.00 :           df21d:       00 00 00
   10.00 :           df220:       48 8b 75 00             mov    0x0(%rbp),%rsi
   80.00 :           df224:       48 89 df                mov    %rbx,%rdi
    0.00 :           df227:       41 ff d4                callq  *%r12
    0.00 :           df22a:       85 c0                   test   %eax,%eax

[...]

If I read the output correctly, most of the dcache misses are coming from 'mov %rbx, %rdi', and AFAIK this intruction can't generate any dcache miss. What am I missing ?

Thanks.

Signature · 1 line
Francis
#1 lore raw
Quoted 8 lines · Francis Moreau

Hello,

I'm trying to use perf-tools and also to learn some internals about them. So I prefer to ask all of them in one email.

The first one is about the list of pre-defined events given by perf-list. I couldn't find any documentations that describes these events so excuse me if the question is stupid.

Sorry about that. We indeed need to improve a lot the documentation. May be this particular part could come with the future sysfs exposure of the events.

Quoted 2 lines

What's the difference between 'cpu-clock' and 'task-clock' event ?

cpu-clock is based on the total time spent on the cpu. task-clock is based only on the time spent on the profiled task, so that doesn't count time spent on other tasks, it has a per thread granularity.

(I might be somehow wrong in my explanation).

Quoted 9 lines

What's exactly the 'cache-misses' event ? does it include both instructions _and_ data cache misses ? both L1 and L2 caches ?

I was expecting so but the following command makes me wondering:

  $ perf stat -e cache-misses:u,l1d-loads-misses:u true
    Performance counter stats for 'true':
Quoted 6 lines
                763  cache-misses            
                874  L1-dcache-load-misses   

        0.000916609  seconds time elapsed

Here cache-misses < L1-dcache-load-misses.

Dunno, will let others answer.

Quoted 15 lines

The last question is about the source code annotation done by perf-report. I'm using it to locate the place in my code that generates the most data cache miss events. I can read this during a perf-report session:

   [...]
    0.00 :           df215:       c3                      retq
    0.00 :           df216:       66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax,%rax,1)
    0.00 :           df21d:       00 00 00
   10.00 :           df220:       48 8b 75 00             mov    0x0(%rbp),%rsi
   80.00 :           df224:       48 89 df                mov    %rbx,%rdi
    0.00 :           df227:       41 ff d4                callq  *%r12
    0.00 :           df22a:       85 c0                   test   %eax,%eax
   [...]
Quoted 3 lines

If I read the output correctly, most of the dcache misses are coming from 'mov %rbx, %rdi', and AFAIK this intruction can't generate any dcache miss. What am I missing ?

Perhaps you need pebs to get the very precise location on your event.

perf stat -e cache-misses:up,l1d-loads-misses:up true

I think the more you add 'p', the more precise it is. Like:

perf stat -e cache-misses:uppp,l1d-loads-misses:uppp true

Not sure how much it will accept though :)

#2 lore raw
Quoted 11 lines · Frederic Weisbecker
Quoted 11 lines

What's exactly the 'cache-misses' event ? does it include both instructions _and_ data cache misses ? both L1 and L2 caches ?

I was expecting so but the following command makes me wondering:

  $ perf stat -e cache-misses:u,l1d-loads-misses:u true
    Performance counter stats for 'true':

                763  cache-misses
                874  L1-dcache-load-misses

Quoted 7 lines
Quoted 3 lines

        0.000916609  seconds time elapsed

Here cache-misses < L1-dcache-load-misses.

Dunno, will let others answer.

I think it corresponds to last level cache misses, which makes sense here. The difference in the two numbers represents hits to L2 (and L3 if it exists).

Reid