Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
4a87f308
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4a87f308
编写于
7月 17, 2013
作者:
T
Tatsuo Ishii
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add --progress option to show progress report
Patch contributed by Fabien COELHO, reviewed by KONDO Mitsumasa.
上级
cc1965a9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
94 addition
and
2 deletion
+94
-2
contrib/pgbench/pgbench.c
contrib/pgbench/pgbench.c
+84
-2
doc/src/sgml/pgbench.sgml
doc/src/sgml/pgbench.sgml
+10
-0
未找到文件。
contrib/pgbench/pgbench.c
浏览文件 @
4a87f308
...
...
@@ -74,7 +74,7 @@ static int pthread_join(pthread_t th, void **thread_return);
#include <pthread.h>
#else
/* Use emulation with fork. Rename pthread identifiers to avoid conflicts */
#define PTHREAD_FORK_EMULATION
#include <sys/wait.h>
#define pthread_t pg_pthread_t
...
...
@@ -164,6 +164,8 @@ bool use_log; /* log transaction latencies to a file */
bool
use_quiet
;
/* quiet logging onto stderr */
int
agg_interval
;
/* log aggregates instead of individual
* transactions */
int
progress
=
0
;
/* thread progress report every this seconds */
int
progress_nclients
=
0
;
/* number of clients for progress report */
bool
is_connect
;
/* establish connection for each transaction */
bool
is_latencies
;
/* report per-command latencies */
int
main_pid
;
/* main process id used in log filename */
...
...
@@ -352,6 +354,7 @@ usage(void)
"(default: simple)
\n
"
" -n, --no-vacuum do not run VACUUM before tests
\n
"
" -N, --skip-some-updates skip updates of pgbench_tellers and pgbench_branches
\n
"
" -P, --progress NUM show thread progress report every NUM seconds
\n
"
" -r, --report-latencies report average latency per command
\n
"
" -s, --scale=NUM report this scale factor in output
\n
"
" -S, --select-only perform SELECT-only transactions
\n
"
...
...
@@ -2119,6 +2122,7 @@ main(int argc, char **argv)
{
"log"
,
no_argument
,
NULL
,
'l'
},
{
"no-vacuum"
,
no_argument
,
NULL
,
'n'
},
{
"port"
,
required_argument
,
NULL
,
'p'
},
{
"progress"
,
required_argument
,
NULL
,
'P'
},
{
"protocol"
,
required_argument
,
NULL
,
'M'
},
{
"quiet"
,
no_argument
,
NULL
,
'q'
},
{
"report-latencies"
,
no_argument
,
NULL
,
'r'
},
...
...
@@ -2202,7 +2206,7 @@ main(int argc, char **argv)
state
=
(
CState
*
)
pg_malloc
(
sizeof
(
CState
));
memset
(
state
,
0
,
sizeof
(
CState
));
while
((
c
=
getopt_long
(
argc
,
argv
,
"ih:nvp:dqSNc:j:Crs:t:T:U:lf:D:F:M:"
,
long_options
,
&
optindex
))
!=
-
1
)
while
((
c
=
getopt_long
(
argc
,
argv
,
"ih:nvp:dqSNc:j:Crs:t:T:U:lf:D:F:M:
P:
"
,
long_options
,
&
optindex
))
!=
-
1
)
{
switch
(
c
)
{
...
...
@@ -2357,6 +2361,16 @@ main(int argc, char **argv)
exit
(
1
);
}
break
;
case
'P'
:
progress
=
atoi
(
optarg
);
if
(
progress
<=
0
)
{
fprintf
(
stderr
,
"thread progress delay (-P) must be positive (%s)
\n
"
,
optarg
);
exit
(
1
);
}
break
;
case
0
:
/* This covers long options which take no argument. */
break
;
...
...
@@ -2482,6 +2496,7 @@ main(int argc, char **argv)
* changed after fork.
*/
main_pid
=
(
int
)
getpid
();
progress_nclients
=
nclients
;
if
(
nclients
>
1
)
{
...
...
@@ -2733,6 +2748,11 @@ threadRun(void *arg)
int
nstate
=
thread
->
nstate
;
int
remains
=
nstate
;
/* number of remaining clients */
int
i
;
/* for reporting progress: */
int64
thread_start
=
INSTR_TIME_GET_MICROSEC
(
thread
->
start_time
);
int64
last_report
=
thread_start
;
int64
next_report
=
last_report
+
progress
*
1000000
;
int64
last_count
=
0
;
AggVals
aggs
;
...
...
@@ -2896,6 +2916,68 @@ threadRun(void *arg)
st
->
con
=
NULL
;
}
}
#ifdef PTHREAD_FORK_EMULATION
/* each process reports its own progression */
if
(
progress
)
{
instr_time
now_time
;
int64
now
;
INSTR_TIME_SET_CURRENT
(
now_time
);
now
=
INSTR_TIME_GET_MICROSEC
(
now_time
);
if
(
now
>=
next_report
)
{
/* generate and show report */
int64
count
=
0
;
int64
run
=
now
-
last_report
;
float
tps
,
total_run
,
latency
;
for
(
i
=
0
;
i
<
nstate
;
i
++
)
count
+=
state
[
i
].
cnt
;
total_run
=
(
now
-
thread_start
)
/
1000000
.
0
;
tps
=
1000000
.
0
*
(
count
-
last_count
)
/
run
;
latency
=
1000
.
0
*
nstate
/
tps
;
fprintf
(
stderr
,
"progress %d: %.1f s, %.1f tps, %.3f ms lat
\n
"
,
thread
->
tid
,
total_run
,
tps
,
latency
);
last_count
=
count
;
last_report
=
now
;
next_report
+=
progress
*
1000000
;
}
}
#else
/* progress report by thread 0 for all threads */
if
(
progress
&&
thread
->
tid
==
0
)
{
instr_time
now_time
;
int64
now
;
INSTR_TIME_SET_CURRENT
(
now_time
);
now
=
INSTR_TIME_GET_MICROSEC
(
now_time
);
if
(
now
>=
next_report
)
{
/* generate and show report */
int64
count
=
0
;
int64
run
=
now
-
last_report
;
float
tps
,
total_run
,
latency
;
for
(
i
=
0
;
i
<
progress_nclients
;
i
++
)
count
+=
state
[
i
].
cnt
;
total_run
=
(
now
-
thread_start
)
/
1000000
.
0
;
tps
=
1000000
.
0
*
(
count
-
last_count
)
/
run
;
latency
=
1000
.
0
*
progress_nclients
/
tps
;
fprintf
(
stderr
,
"progress: %.1f s, %.1f tps, %.3f ms lat
\n
"
,
total_run
,
tps
,
latency
);
last_count
=
count
;
last_report
=
now
;
next_report
+=
progress
*
1000000
;
}
}
#endif
/* PTHREAD_FORK_EMULATION */
}
done:
...
...
doc/src/sgml/pgbench.sgml
浏览文件 @
4a87f308
...
...
@@ -407,6 +407,16 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-P</option> <replaceable>sec</></term>
<term><option>--progress</option> <replaceable>sec</></term>
<listitem>
<para>
Show progress report about every <literal>sec</> seconds.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-s</option> <replaceable>scale_factor</></term>
<term><option>--scale=</option><replaceable>scale_factor</></term>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录