Use perf to profile the redis daemon
1 2 3 |
perf record -a -g -p 12345 # After a while, Ctrl + c to interrupt it perf report |
The report shows:
1 2 3 |
Samples: 2K of event 'cycles', Event count (approx.): 795511519 - x.xx% redis-server redis-server [.] ziplistFind ziplistFind |
I could only see that function “ziplistFind” is very hot in redis but I can’t see how the code routine reaches the “ziplistFind”. By searching around I find this article. So I use perf as:
1 |
perf record -a -g -p 12345 --call-graph dwarf |
The report indicates more details in program now:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Samples: 2K of event 'cycles', Event count (approx.): 795511519 - x.xx% redis-server redis-server [.] ziplistFind - ziplistFind - 99.35% hashTypeSet hsetCommand call processCommand processInputBuffer readQueryFromClient aeProcessEvents aeMain main __libc_start_main _start |