https://github.com/brendangregg/skid-testing
Processor PMC sample skid testing
https://github.com/brendangregg/skid-testing
Last synced: about 2 months ago
JSON representation
Processor PMC sample skid testing
- Host: GitHub
- URL: https://github.com/brendangregg/skid-testing
- Owner: brendangregg
- Created: 2017-07-28T18:05:08.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-29T02:47:20.000Z (almost 8 years ago)
- Last Synced: 2025-03-25T06:32:20.173Z (2 months ago)
- Language: C
- Size: 121 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Processor PMC event skid testing
Work in progress.
- skidtest.c: in a loop, this calls a memory read followed by a NOP "runway" of thousands of no-operations. The read can then be instrumented with PMCs to capture the instruction pointer, which often falls on the NOP runway (which themselves will not cause a read, other than initially loading into the instruction cache). The offset seen in the NOP runway shows the magnitude of skid.
## Building
```
gcc -O0 -o skidtest skidtest.c
```## Recording
For example, every 1000 LLC-miss on Intel using Linux perf:
```
perf record -vv -e r412e -c 1000 ./skidtest 1000000
```Check the verbose output (-vv) to see if precise_ip (PEBS) was auto-enabled or not (to measure the baseline skid, you want this off).
Choose a size greater than the LLC cache to induce misses.
## Processing
Various ways to post-process the perf capture. Each of these uses -F to customize the perf script output (older versions, -f), however, on newer kernels the perf script output is sufficient by default (has symoff).
### Hits vs skids
```
perf script --header -F comm,pid,tid,time,event,ip,sym,symoff,dso |\
awk '/noprunway/ { skid++ } /memreader/ { hit++ } END { printf "hits %d, skid %d\n", hit, skid }'
```### Skid offset list
```
perf script --header -F comm,pid,tid,time,event,ip,sym,symoff,dso |\
awk '/noprunway/ { sub(/noprunway\+/, "", $6); print $6 }' | perl -ne 'print hex($_) . "\n"' | sort -n
```This can also be saved to a file, and used as input for skid.r plotting. Sample:
That's excluding hits, although in this case it was over 99% skids (hits 131, skid 152565).
### skid offset histogram (as text)
```
perf script --header -F comm,pid,tid,time,event,ip,sym,symoff,dso |\
awk '/noprunway/ { sub(/noprunway\+/, "", $6); print $6 }' | perl -e 'while (<>) { $idx = int(hex($_)/10); @a[$idx]++; $m = $idx if $idx > $m; } for ($i = 0; $i < $m; $i++) { $a[$i] += 0; print $i * 10 . " " . $a[$i] . "\n"; }'
```