DTrace(Dynamic Tracing):Solaris 10 的新特性

| 1 TrackBack

Solaris 10 的新特性中和 DBA 关系最大的恐怕就是这个 Dtrace 了。Dtrace(Dynamic Tracing)是“Solaris 操作系统的一种复杂动态跟踪框架”。与其他商用 Unix 提供的性能工具有本质区别,据称“Dtrace 在 Solaris OS 内部构建,其在内核中采用了 25,000 个探测器”(SPARC 和 X86 平台都可用),在应用层和核心层都可发挥作用。这对于 DBA 来说是个绝佳的好工具,便于更快诊断并定位操作系统性能瓶颈。比如主开发者 Bryan Cantrill 提到的利用 Dtrace 的 plockstat provider 来诊断锁(Lock)竞争的问题。

粗略信息可以参考一下这则精彩回放。目前主要的开发者是这三个家伙 Bryan Cantrill,Adam Leventhal,Mike Shapiro,这几个家伙的 BLOG 上有很多有趣的内容。

BigAdmin: DTrace 的页面可以找到很多 DTrace 的文档。DTrace也不是没有弱点:目前对 Java 虚拟机还不能够处理

如果有相应的环境和足够兴趣的话,可以去参加这个 Solaris 10 Challenge Competition ,里面有两项是关于 Dtrace 的,另外两项涉及 Solaris 的另一个非常重要的新特性: Solaris Containers(Solaris Zones ?)。

备忘(入门的参考信息:Demo'ing DTrace):

# dtrace
Usage: dtrace [-32|-64] [-aACeEFGHlqSvVwZ] [-b bufsz] [-c cmd] [-D name[=def]]
        [-I path] [-o output] [-p pid] [-s script] [-U name]
        [-x opt[=val]] [-X a|c|s|t]

        [-P provider [[ predicate ] action ]]
        [-m [ provider: ] module [[ predicate ] action ]]
        [-f [[ provider: ] module: ] func [[ predicate ] action ]]
        [-n [[[ provider: ] module: ] func: ] name [[ predicate ] action ]]
        [-i probe-id [[ predicate ] action ]] [ args ... ]

        predicate -> '/' D-expression '/'
           action -> '{' D-statements '}'

        -32 generate 32-bit D programs and ELF files
        -64 generate 64-bit D programs and ELF files

        -a  claim anonymous tracing state
        -A  generate driver.conf(4) directives for anonymous tracing
        -b  set trace buffer size
        -c  run specified command and exit upon its completion
        -C  run cpp(1) preprocessor on script files
        -D  define symbol when invoking preprocessor
        -e  exit after compiling request but prior to enabling probes
        -E  exit after enabling probes but prior to tracing data
        -f  enable or list probes matching the specified function name
        -F  coalesce trace output by function
        -G  generate an ELF file containing embedded dtrace program
        -H  print included files when invoking preprocessor
        -i  enable or list probes matching the specified probe id
        -I  add include directory to preprocessor search path
        -l  list probes matching specified criteria
        -m  enable or list probes matching the specified module name
        -n  enable or list probes matching the specified probe name
        -o  set output file
        -p  grab specified process-ID and cache its symbol tables
        -P  enable or list probes matching the specified provider name
        -q  set quiet mode (only output explicitly traced data)
        -s  enable or list probes according to the specified D script
        -S  print D compiler intermediate code
        -U  undefine symbol when invoking preprocessor
        -v  set verbose mode (report program stability attributes)
        -V  report DTrace API version
        -w  permit destructive actions
        -x  enable or modify compiler and tracing options
        -X  specify ISO C conformance settings for preprocessor
        -Z  permit probe descriptions that match zero probes

同类产品 AIXTrace,HP-UX glance 等看来都要对 Dtrace 甘拜下风了。

Sun 的 Blog站点上内容真是比较丰富,虽然 BLOG 工具比较烂,惨被 SPAM 注释攻击。

1 TrackBack

Oracle 选择 Open Solaris 10 作为64位首选开发平台.简单分析. Read More