Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfeffa0e

Browse files
committed
Fix pgbench's --progress-timestamp option to print Unix-epoch timestamps.
As a consequence of commit1d63f7d, on platforms with CLOCK_MONOTONIC,you got some random timescale or other instead of standard Unix timestampsas expected. I'd attempted to fix pgbench for that change in commits74baa1e and67a8753, but missed this place. Fix in the same way asthose previous commits, ie, just eat the cost of an extra gettimeofday();one extra syscall per progress report isn't worth sweating over. Perreport from Jeff Janes.In passing, use snprintf not sprintf for this purpose. I don't thinkthere's any chance of actual buffer overrun, but it just looks safer.Discussion:https://postgr.es/m/CAMkU=1zrQaPwBN+NcBd3pWCb=vWaiL=mmWfJjDJjh-a7eVr-Og@mail.gmail.com
1 parenta6940bd commitfeffa0e

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

‎src/bin/pgbench/pgbench.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4652,10 +4652,21 @@ threadRun(void *arg)
46524652
(cur.cnt-last.cnt);
46534653

46544654
if (progress_timestamp)
4655-
sprintf(tbuf,"%.03f s",
4656-
INSTR_TIME_GET_MILLISEC(now_time) /1000.0);
4655+
{
4656+
/*
4657+
* On some platforms the current system timestamp is
4658+
* available in now_time, but rather than get entangled
4659+
* with that, we just eat the cost of an extra syscall in
4660+
* all cases.
4661+
*/
4662+
structtimevaltv;
4663+
4664+
gettimeofday(&tv,NULL);
4665+
snprintf(tbuf,sizeof(tbuf),"%ld.%03ld s",
4666+
(long)tv.tv_sec, (long) (tv.tv_usec /1000));
4667+
}
46574668
else
4658-
sprintf(tbuf,"%.1f s",total_run);
4669+
snprintf(tbuf,sizeof(tbuf),"%.1f s",total_run);
46594670

46604671
fprintf(stderr,
46614672
"progress: %s, %.1f tps, lat %.3f ms stddev %.3f",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp