背景
AntDB-单机oracle语法兼容版本,高并发下benchmarksql走oracle语法下性能较走pg本身语法下降40%左右。为了诊断软件的性能瓶颈,使用gprof工具在预编译AntDB时打开 –enable-profiling,这个选项会打开gcc的-pg参数,产生可以被gprof用于分析进程的代码。操作数据库后生成的诊断代码默认存放在$PGDATA/gprof目录中,每个进程结束后,都会产生一个子目录,里面会有一个gmon.out文件。
gprof工具简单介绍
gprof是GNU profile工具,可以运行于linux操作系统进行C、C++程序的性能分析,用于程序的性能优化以及程序瓶颈问题的查找和解决。通过分析应用程序运行时产生的“flat profile”,可以得到每个函数的调用次数,每个函数消耗的处理器时间,也可以得到函数的“Call graph 调用关系图”,包括函数调用的层次关系,每个函数调用花费了多少时间。
测试验证
step 1:使用–enable-profiling开关编译AntDB oracle 兼容版本
../adb_sql/configure --prefix=/data/gd/app --with-wal-segsize=64 --with-wal-blocksize=64
--with-perl --with-python --with-openssl --with-pam --with-ldap --with-libxml --with-libxslt --enable-thread-safety
--enable-cassert --enable-debug --enable-depend --disable-cluster --enable-grammar-oracle --enable-profiling CFLAGS=-O0 -ggdb3
&& gmake install-world-contrib-recurse
备注: 1、–enable-profiling 是打开gprof开关,–disable-cluster –enable-grammar-oracle开关表示编译安装的是单机oracle语法兼容版本;
2、编译安装成功后,设置环境变量
step 2:初始化/配置/启动AntDB单机oracle兼容版本
[gd@intel175 ~]$ initdb -D data_oracle
The files belonging to this database system will be owned by user "gd".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory data_ora ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
Success. You can now start the database server using:
pg_ctl -D data_oracle -l logfile start
设置参数后(postgresql.conf),顺带设置下pg_hba.conf 权限后启动AntDB oracle兼容版本,这里就不再细说。
setp3:初始化benchmarksql测试环境
[zgy@intel176 run]$ less runDatabaseBuild.sh
#!/bin/sh
if [ $# -lt 1 ] ; then
echo "usage: $(basename $0) PROPS [OPT VAL [...]]" >&2
exit 2
fi
PROPS="$1"
shift
if [ ! -f "${PROPS}" ] ; then
echo "${PROPS}: no such file or directory" >&2
exit 1
fi
DB="$(grep '^db=' $PROPS | sed -e 's/^db=//')"
BEFORE_LOAD="tableCreates"
AFTER_LOAD="tableCopies indexCreates foreignKeys extraHistID buildFinish"
for step in ${BEFORE_LOAD} ; do
./runSQL.sh "${PROPS}" $step
done
#./runLoader.sh "${PROPS}" $*
for step in