리눅스 cache miss rate 모니터링을 하고싶습니다.
조회수 3397회
-
(•́ ✖ •̀)
알 수 없는 사용자
1 답변
-
리눅스에 perf 라는 툴이 있습니다.
perf stat -B <명령어 ..>
위와 같이 실행하면 다음과 같이 명령어에 의한 출력 후(즉, 프로그램이 실행되고 종료한 후)에 성능 지표들이 출력됩니다.
<명령어의 화면 출력 결과> Performance counter stats for 'ls': 2.076373 task-clock (msec) # 0.775 CPUs utilized 0 context-switches # 0.000 K/sec 0 cpu-migrations # 0.000 K/sec 262 page-faults # 0.126 M/sec 5,062,230 cycles # 2.438 GHz [64.69%] 3,657,439 stalled-cycles-frontend # 72.25% frontend cycles idle [52.08%] 3,131,202 stalled-cycles-backend # 61.85% backend cycles idle 2,006,362 instructions # 0.40 insns per cycle # 1.82 stalled cycles per insn 495,853 branches # 238.807 M/sec 14,877 branch-misses # 3.00% of all branches 0.002679898 seconds time elapsed
perf 도구는 https://perf.wiki.kernel.org/index.php/Tutorial 를 참고하시면 됩니다.
L2 캐쉬
L2 캐쉬면 LLC-loads 와 LLC-load-misses,LLC-stores,LLC-store-misses,LLC-prefetch-misses 를 보면 되지 않을 까 싶네요. LLC는 Last Level Cache의 약자입니다.
perf로 확인하려면, 다음과 같이 해보세요.
perf record -e LLC-loads,LLC-load-misses <명령어 ....>
위와 같이 실행하면 perf.data 라는 파일이 생기는 데, 이는 다음 명령어를 통해서 기록 내용을 확인할 수 있습니다.
perf report
아마도 컴파일이 가능하다면 -g 옵션을 준 후 사용하면 더 좋은 결과를 얻을 수 있지 않을까 싶네요.
댓글 입력