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

Commit74baa1e

Browse files
committed
Avoid assuming that instr_time == struct timeval in pgbench logging.
This code was presuming undue familiarity with the contents of theinstr_time struct. That was already broken on Windows, and it's aboutto get broken on most other platforms as well. The simplest solutionthat preserves the current output definition is to just do our owngettimeofday() call here. Realistically, the extra cost is probablynegligible in comparison to everything else that's going on in apgbench transaction, so it's not worth sweating over.On Windows, the precision delivered by gettimeofday() is lower thanone could wish, but this is still a big improvement over printingzeroes, as the code did before.Discussion:https://postgr.es/m/8837.1483216839@sss.pgh.pa.us
1 parent257d815 commit74baa1e

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

‎src/bin/pgbench/pgbench.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,27 +2483,23 @@ doLog(TState *thread, CState *st, instr_time *now,
24832483
else
24842484
{
24852485
/* no, print raw transactions */
2486-
#ifndefWIN32
2486+
structtimevaltv;
24872487

2488-
/* This is more than we really ought to know about instr_time */
2488+
/*
2489+
* We print the current system timestamp in the log, so that entries
2490+
* can be correlated against other logs. On some platforms this is
2491+
* available in *now, but rather than get entangled with that, we just
2492+
* eat the cost of an extra syscall in all cases.
2493+
*/
2494+
gettimeofday(&tv,NULL);
24892495
if (skipped)
24902496
fprintf(logfile,"%d "INT64_FORMAT" skipped %d %ld %ld",
24912497
st->id,st->cnt,st->use_file,
2492-
(long)now->tv_sec, (long)now->tv_usec);
2498+
(long)tv.tv_sec, (long)tv.tv_usec);
24932499
else
24942500
fprintf(logfile,"%d "INT64_FORMAT" %.0f %d %ld %ld",
24952501
st->id,st->cnt,latency,st->use_file,
2496-
(long)now->tv_sec, (long)now->tv_usec);
2497-
#else
2498-
2499-
/* On Windows, instr_time doesn't provide a timestamp anyway */
2500-
if (skipped)
2501-
fprintf(logfile,"%d "INT64_FORMAT" skipped %d 0 0",
2502-
st->id,st->cnt,st->use_file);
2503-
else
2504-
fprintf(logfile,"%d "INT64_FORMAT" %.0f %d 0 0",
2505-
st->id,st->cnt,latency,st->use_file);
2506-
#endif
2502+
(long)tv.tv_sec, (long)tv.tv_usec);
25072503
if (throttle_delay)
25082504
fprintf(logfile," %.0f",lag);
25092505
fputc('\n',logfile);
@@ -4402,7 +4398,7 @@ threadRun(void *arg)
44024398
if (use_log)
44034399
{
44044400
charlogpath[MAXPGPATH];
4405-
char*prefix=logfile_prefix ?logfile_prefix :"pgbench_log";
4401+
char*prefix=logfile_prefix ?logfile_prefix :"pgbench_log";
44064402

44074403
if (thread->tid==0)
44084404
snprintf(logpath,sizeof(logpath),"%s.%d",prefix,main_pid);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp