Quantcast
Channel: PostgreSQL research
Viewing all articles
Browse latest Browse all 253

Greenplum PostgreSQL --enable-profiling 产生gprof性能诊断代码

$
0
0
Greenplum或PostgreSQL的编译配置文件中有一个选项是 --enable-profiling,这个选项会打开GCC的-pg参数。产生可以被gprof用于分析进程的代码。
如下:
less configure
# enable profiling if --enable-profiling
if test "$enable_profiling" = yes && test "$ac_cv_prog_cc_g" = yes; then
  if test "$GCC" = yes; then

$as_echo "#define PROFILE_PID_DIR 1" >>confdefs.h

    CFLAGS="$CFLAGS -pg $PLATFORM_PROFILE_FLAGS"
  else
    as_fn_error $? "--enable-profiling is supported only when using GCC" "$LINENO" 5
  fi
fi

less src/template/linux
# If --enable-profiling is specified, we need -DLINUX_PROFILE
PLATFORM_PROFILE_FLAGS="-DLINUX_PROFILE"

man gcc
       -pg Generate extra code to write profile information suitable for the analysis program gprof.  You must use this option when compiling the source files you want data about, and you must also use it when linking.
诊断代码被放在$PGDATA/gprof目录中,每个进程都会产生一个子目录,里面会有一个gmon.out文件。
查看这个文件的信息:
#gprof -b /home/digoal/gpdb/bin/postgres gmon.out
Flat profile:
Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls  ms/call  ms/call  name    
 80.00      0.04     0.04       91     0.44     0.44  FileRepVerify_ComputeFileHash
 20.00      0.05     0.01        1    10.00    10.00  ChangeTracking_WriteBuffer
  0.00      0.05     0.00   750562     0.00     0.00  ChangeTracking_GetRelationChangeInfoFromXlog
  0.00      0.05     0.00   670756     0.00     0.00  cdbpullup_colIdx
  0.00      0.05     0.00   253200     0.00     0.00  cdbpullup_isExprCoveredByTargetlist
  0.00      0.05     0.00   239413     0.00     0.00  cdbpullup_targetlist
......
有点类似oprofile的输出。
gprof的用法可以参考man gprof。

Flag Counter

Viewing all articles
Browse latest Browse all 253

Trending Articles