Linux Kernel Performance

    Linux kernel 的profiling工具有很多,如oprofile,Redhat上则有systemtap,oracle上有从solaris上移植过来的DTrace,还有function trace,最近几年kernel中又出现了一个perf,综合来看perf的前景最为看好,完全可取代oprofile。

    perf是performance的缩写,代码与kernel source code一同发布(弥补了oprofile的遗憾,用户空间程序和kernel程序的分离),经过几年的发展,perf现在已经相当成熟,几乎所有的performance都能满足了。

 

 

[root@localhost perf]# ./perf

 usage: perf [--version] [--help] COMMAND [ARGS]

 The most commonly used perf commands are:
   annotate        Read perf.data (created by perf record) and display annotated code
   archive         Create archive with object files with build-ids found in perf.data file
   bench           General framework for benchmark suites
   buildid-cache   Manage build-id cache.
   buildid-list    List the buildids in a perf.data file
   diff            Read two perf.data files and display the differential profile
   evlist          List the event names in a perf.data file
   inject          Filter to augment the events stream with additional information
   kmem            Tool to trace/measure kernel memory(slab) properties
   kvm             Tool to trace/measure kvm guest os
   list            List all symbolic event types
   lock            Analyze lock events
   probe           Define new dynamic tracepoints
   record          Run a command and record its profile into perf.data
   report          Read perf.data (created by perf record) and display the profile
   sched           Tool to trace/measure scheduler properties (latencies)
   script          Read perf.data (created by perf record) and display trace output
   stat            Run a command and gather performance counter statistics
   test            Runs sanity tests.
   timechart       Tool to visualize total system behavior during a workload
   top             System profiling tool.

 See 'perf help COMMAND' for more information on a specific command.

 

 比较酷的命令如perf top,用过top命令的都知道

还有perf annotate,把汇编和代码都显示出来,还有timechart/kvm等命令,做的的非常好。probe则可检测各种自定义的tracepoints。

 

    基于perf生成的record可做进一步分析,如下面的Flame Graphs,用perl脚本处理record,生成profing图片

Linux Kernel Performance: Flame Graphs

 

Linux Kernel Performance

 

perf总体来说非常好用(有些命令格式有点复杂),相比oprofile来说,方便不少,起码不用再下载一个用户空间的程序,Linux 3.0以后基本上都把perf编译进去了,但很多production的机器没有把oprofile编进去。

你可能感兴趣的:(kernel)