Skip to content

Commit 70e9511

Browse files
author
Marina Polyakova
committed
Pgbench Fix One option to report per-command statistics
Now options --report-latencies (-r) and --report-failures are replaced by the option --report-per-command (-r).
1 parent f71f952 commit 70e9511

File tree

1 file changed

+19
-44
lines changed

1 file changed

+19
-44
lines changed

src/bin/pgbench/pgbench.c

Lines changed: 19 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,9 @@ bool progress_timestamp = false; /* progress report with Unix time */
173173
int nclients = 1; /* number of clients */
174174
int nthreads = 1; /* number of threads */
175175
bool is_connect; /* establish connection for each transaction */
176-
bool is_latencies; /* report per-command latencies */
176+
bool report_per_command = false; /* report per-command latencies and
177+
* failures */
177178
int main_pid; /* main process id used in log filename */
178-
bool report_failures = false; /* whether to report serialization and
179-
* deadlock failures per command */
180179

181180
char *pghost = "";
182181
char *pgport = "";
@@ -470,15 +469,14 @@ usage(void)
470469
" protocol for submitting queries (default: simple)\n"
471470
" -n, --no-vacuum do not run VACUUM before tests\n"
472471
" -P, --progress=NUM show thread progress report every NUM seconds\n"
473-
" -r, --report-latencies report average latency per command\n"
472+
" -r, --report-per-command report average latency and failures per command\n"
474473
" -R, --rate=NUM target rate in transactions per second\n"
475474
" -s, --scale=NUM report this scale factor in output\n"
476475
" -t, --transactions=NUM number of transactions each client runs (default: 10)\n"
477476
" -T, --time=NUM duration of benchmark test in seconds\n"
478477
" -v, --vacuum-all vacuum all four standard tables before tests\n"
479478
" --aggregate-interval=NUM aggregate data over NUM seconds\n"
480479
" --progress-timestamp use Unix epoch timestamps for progress\n"
481-
" --report-failures report serialization and deadlock failures per command\n"
482480
" --sampling-rate=NUM fraction of transactions to log (e.g., 0.01 for 1%%)\n"
483481
"\nCommon options:\n"
484482
" -d, --debug print debugging output\n"
@@ -1977,7 +1975,7 @@ doCustom(TState *thread, CState *st, StatsData *agg)
19771975
* accumulate per-command execution times in thread-local data
19781976
* structure, if per-command latencies are requested
19791977
*/
1980-
if (is_latencies && !serialization_failure && !deadlock_failure)
1978+
if (report_per_command && !serialization_failure && !deadlock_failure)
19811979
{
19821980
if (INSTR_TIME_IS_ZERO(now))
19831981
INSTR_TIME_SET_CURRENT(now);
@@ -2134,7 +2132,7 @@ doCustom(TState *thread, CState *st, StatsData *agg)
21342132
}
21352133

21362134
/* Record statement start time if per-command latencies are requested */
2137-
if (is_latencies)
2135+
if (report_per_command)
21382136
INSTR_TIME_SET_CURRENT(st->stmt_begin);
21392137

21402138
if (commands[st->state]->type == SQL_COMMAND)
@@ -3490,7 +3488,7 @@ printResults(TState *threads, StatsData *total, instr_time total_time,
34903488
printf("tps = %f (excluding connections establishing)\n", tps_exclude);
34913489

34923490
/* Report per-script/command statistics */
3493-
if (per_script_stats || latency_limit || is_latencies)
3491+
if (per_script_stats || latency_limit || report_per_command)
34943492
{
34953493
int i;
34963494

@@ -3529,41 +3527,24 @@ printResults(TState *threads, StatsData *total, instr_time total_time,
35293527
printSimpleStats(" - latency", &sql_script[i].stats.latency);
35303528

35313529
/*
3532-
* Report per-command serialization / deadlock failures and
3533-
* latencies */
3534-
if (report_failures || is_latencies)
3530+
* Report per-command statistics: latencies, serialization &
3531+
* deadlock failures.
3532+
*/
3533+
if (report_per_command)
35353534
{
35363535
Command **commands;
35373536

3538-
if (report_failures && is_latencies)
3539-
printf(" - statement serialization, deadlock failures and latencies in milliseconds:\n");
3540-
else if (report_failures)
3541-
printf(" - statement serialization and deadlock failures:\n");
3542-
else
3543-
printf(" - statement latencies in milliseconds:\n");
3537+
printf(" - statement latencies in milliseconds, serialization & deadlock failures:\n");
35443538

35453539
for (commands = sql_script[i].commands;
35463540
*commands != NULL;
35473541
commands++)
3548-
{
3549-
if (report_failures && is_latencies)
3550-
printf(" %25" INT64_MODIFIER "d %25" INT64_MODIFIER "d %11.3f %s\n",
3551-
(*commands)->serialization_failures,
3552-
(*commands)->deadlock_failures,
3553-
1000.0 * (*commands)->stats.sum /
3554-
(*commands)->stats.count,
3555-
(*commands)->line);
3556-
else if (report_failures)
3557-
printf(" %25" INT64_MODIFIER "d %25" INT64_MODIFIER "d %s\n",
3558-
(*commands)->serialization_failures,
3559-
(*commands)->deadlock_failures,
3560-
(*commands)->line);
3561-
else
3562-
printf(" %11.3f %s\n",
3563-
1000.0 * (*commands)->stats.sum /
3564-
(*commands)->stats.count,
3565-
(*commands)->line);
3566-
}
3542+
printf(" %11.3f %25" INT64_MODIFIER "d %25" INT64_MODIFIER "d %s\n",
3543+
1000.0 * (*commands)->stats.sum /
3544+
(*commands)->stats.count,
3545+
(*commands)->serialization_failures,
3546+
(*commands)->deadlock_failures,
3547+
(*commands)->line);
35673548
}
35683549
}
35693550
}
@@ -3593,7 +3574,7 @@ main(int argc, char **argv)
35933574
{"progress", required_argument, NULL, 'P'},
35943575
{"protocol", required_argument, NULL, 'M'},
35953576
{"quiet", no_argument, NULL, 'q'},
3596-
{"report-latencies", no_argument, NULL, 'r'},
3577+
{"report-per-command", no_argument, NULL, 'r'},
35973578
{"rate", required_argument, NULL, 'R'},
35983579
{"scale", required_argument, NULL, 's'},
35993580
{"select-only", no_argument, NULL, 'S'},
@@ -3613,7 +3594,6 @@ main(int argc, char **argv)
36133594
#ifdef WITH_RSOCKET
36143595
{"with-rsocket", no_argument, NULL, 7},
36153596
#endif
3616-
{"report-failures", no_argument, NULL, 8},
36173597
{NULL, 0, NULL, 0}
36183598
};
36193599

@@ -3756,7 +3736,7 @@ main(int argc, char **argv)
37563736
case 'r':
37573737
benchmarking_option_set = true;
37583738
per_script_stats = true;
3759-
is_latencies = true;
3739+
report_per_command = true;
37603740
break;
37613741
case 's':
37623742
scale_given = true;
@@ -3985,11 +3965,6 @@ main(int argc, char **argv)
39853965
isRsocket = true;
39863966
break;
39873967
#endif
3988-
case 8:
3989-
benchmarking_option_set = true;
3990-
per_script_stats = true;
3991-
report_failures = true;
3992-
break;
39933968
default:
39943969
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
39953970
exit(1);

0 commit comments

Comments
 (0)