Use perf to profile the redis daemon
perf record -a -g -p 12345 # After a while, Ctrl + c to interrupt it perf report
The report shows:
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:
perf record -a -g -p 12345 --call-graph dwarf
The report indicates more details in program now:
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