2013-02-03 8 views
27

Secondo perf tutorials, perf stat si suppone che segnali i tentativi di cache utilizzando contatori hardware. Tuttavia, sul mio sistema (aggiornato Linux Arch), non è così:Perché il perf non segnala errori di cache?

[[email protected] goog]$ perf stat ./hash 

Performance counter stats for './hash': 

    869.447863 task-clock    # 0.997 CPUs utilized   
      92 context-switches   # 0.106 K/sec     
      4 cpu-migrations   # 0.005 K/sec     
     1,041 page-faults    # 0.001 M/sec     
2,628,646,296 cycles     # 3.023 GHz      
    819,269,992 stalled-cycles-frontend # 31.17% frontend cycles idle 
    132,355,435 stalled-cycles-backend # 5.04% backend cycles idle 
4,515,152,198 instructions    # 1.72 insns per cycle   
             # 0.18 stalled cycles per insn 
1,060,739,808 branches     # 1220.015 M/sec     
    2,653,157 branch-misses    # 0.25% of all branches   

    0.871766141 seconds time elapsed 

Cosa mi manca? Ho già cercato la pagina man e il web, ma non ho trovato nulla di ovvio.

Modifica: la mia CPU è un Intel i5 2300K, se questo è importante.

+0

Dipende dai contatori hardware. Non ho mai usato 'perf', ma ho usato' PAPI' (http://icl.cs.utk.edu/PAPI/) ed è possibile controllare i contatori hardware disponibili per scoprire cosa si può ottenere da la tua CPU. – SamGamgee

+2

Prova 'perf stat -d' - segnalerà alcuni eventi della cache. Controlla anche il nuovo strumento perf mem' per eventi di memoria record/report - documentati in http://www.linuxtag.org/2013/fileadmin/www.linuxtag.org/slides/Arnaldo_Melo_-_Linux__perf__tools__Overview_and_Current_Developments.e323.pdf slide 10 e http : //man7.org/linux/man-pages/man1/perf-mem.1.html – osgx

+1

osgx, 'perf stat -d' attiverà il multiplexing degli eventi, che a volte potrebbe riportare tariffe errate. È meglio selezionare manualmente non più di 5-7 hw eventi per corsa; e usa perf stat -d solo per ottenere i nomi di tali eventi. Altro modo per Intel: prova toplev.py da https://github.com/andikleen/pmu-tools – osgx

risposta

39

Sul mio sistema, un Intel Xeon X5570 @ 2.93 GHz ero abl e per ottenere perf stat segnalare i riferimenti della cache e manca richiedendo esplicitamente quegli eventi come questo

perf stat -B -e cache-references,cache-misses,cycles,instructions,branches,faults,migrations sleep 5 
Performance counter stats for 'sleep 5': 

     10573 cache-references            
      1949 cache-misses    # 18.434 % of all cache refs  
     1077328 cycles     # 0.000 GHz      
     715248 instructions    # 0.66 insns per cycle   
     151188 branches              
      154 faults              
      0 migrations             

    5.002776842 seconds time elapsed 

il set predefinito di eventi non includere eventi di cache, che corrisponde ai vostri risultati, non so il motivo per cui

perf stat -B sleep 5 

Performance counter stats for 'sleep 5': 

     0.344308 task-clock    # 0.000 CPUs utilized   
      1 context-switches   # 0.003 M/sec     
      0 CPU-migrations   # 0.000 M/sec     
      154 page-faults    # 0.447 M/sec     
     977183 cycles     # 2.838 GHz      
     586878 stalled-cycles-frontend # 60.06% frontend cycles idle 
     430497 stalled-cycles-backend # 44.05% backend cycles idle 
     720815 instructions    # 0.74 insns per cycle   
             # 0.81 stalled cycles per insn 
     152217 branches     # 442.095 M/sec     
      7646 branch-misses    # 5.02% of all branches   

    5.002763199 seconds time elapsed 
+0

Grazie, è stato utile. Immagino che debbano aver cambiato il set predefinito di eventi che vengono catturati. –

+0

Bello, stavo pensando che fosse strano dover sempre registrare le informazioni .. Questo approccio è più veloce :) – SamGamgee

+0

Una domanda all'interno della domanda, qual è il conteggio dei 'fauts' nell'output perf –

3

Ho passato alcuni minuti a cercare di capire perf. Ho scoperto la mancanza di cache prima registrando e poi riportando i dati (entrambi gli strumenti perf).

Per visualizzare un elenco di eventi:

perf list 

Ad esempio, per Chech il carico dell'ultimo livello-cache misses si vuole utilizzare l'evento LLC-loads-misses come questo

perf record -e LLC-loads-misses ./your_program 

poi riferire i risultati

perf report -v 
7

In the latest source code, l'evento predefinito non include cache-misses e cache-references ancora:

struct perf_event_attr default_attrs[] = { 

    { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_TASK_CLOCK  }, 
    { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CONTEXT_SWITCHES }, 
    { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CPU_MIGRATIONS  }, 
    { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_PAGE_FAULTS  }, 

    { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_CPU_CYCLES  }, 
    { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_STALLED_CYCLES_FRONTEND }, 
    { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_STALLED_CYCLES_BACKEND }, 
    { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_INSTRUCTIONS  }, 
    { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_BRANCH_INSTRUCTIONS }, 
    { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_BRANCH_MISSES  }, 

}; 

Quindi la ma n e la maggior parte del web non sono aggiornati fino ad ora.

Problemi correlati