go-perf: github.com/aclements/go-perf/cmd/branchstats Files

Command branchstats

Command branchstats analyzes branch profiles for branch mispredict rates.

branchstats expects a perf.data collected with

perf record -e branches -j any -c 400009

To collect only branches in user-space code, use

perf record -e branches:u -j any,u -c 400009

The output is a table like

comm     PC                               branches mispredicts
bench    scanner.go:258                  419609441 309206957 (73.7%)
    257 func isLetter(ch rune) bool {
    258         return 'a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' || ch == '_' || ch >= 0x80 && unicode.IsLetter(ch)
    259 }

bench    mgcmark.go:1000                1967244262 236405319 (12.0%)
    999 }
   1000 if bits&bitPointer == 0 {
   1001         continue // not a pointer

Each row shows a branch at a particular location and gives the estimated number of times that branch executed, the estimated number of mispredicts, and the mispredict rate. The table is sorted by the number of mispredicts.

Package Files

main.go

Package main imports 9 packages (graph). Updated 2019-05-14. Refresh now. Tools for package owners.