v3 rebase (after pgbench moved to src/bin) and minor style tweaking.
v4 adds a fix to another progress timing issue:
Currently if pgbench/postgres get stuck somewhere, the report catches up
by repeating progresses several time in a row, which looks like that:
progress: 10.0 s ...
progress: 11.0 s ... stuck...
progress: 14.2 s catchup for 11.0 -> 14.2
progress: 14.2 s stupid data
progress: 14.2 s stupid data
progress: 15.0 s ...
progress: 16.0 s ...
The correction removes the "stupid data" lines which compute a reports on
a very short time, including absurd tps figures.
Yet again, shame on me in the first place for this behavior.
--
Fabien.
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 6f35db4..0d71173 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -3639,6 +3639,28 @@ threadRun(void *arg)
maxsock = sock;
}
+ /* also meet the next progress report time if needed */
+ if (progress && min_usec > 0
+#if !defined(PTHREAD_FORK_EMULATION)
+ && thread->tid == 0
+#endif /* !PTHREAD_FORK_EMULATION */
+ )
+ {
+ /* get current time if needed */
+ if (now_usec == 0)
+ {
+ instr_time now;
+
+ INSTR_TIME_SET_CURRENT(now);
+ now_usec = INSTR_TIME_GET_MICROSEC(now);
+ }
+
+ if (now_usec >= next_report)
+ min_usec = 0;
+ else if ((next_report - now_usec) < min_usec)
+ min_usec = next_report - now_usec;
+ }
+
if (min_usec > 0 && maxsock != -1)
{
int nsocks; /* return from select(2) */
@@ -3744,7 +3766,13 @@ threadRun(void *arg)
last_lags = lags;
last_report = now;
last_skipped = thread->throttle_latency_skipped;
- next_report += (int64) progress *1000000;
+
+ /* Ensure that the next report is in the future, in case
+ * pgbench/postgres got stuck somewhere...
+ */
+ do {
+ next_report += (int64) progress * 1000000;
+ } while (now >= next_report);
}
}
#else
@@ -3808,7 +3836,13 @@ threadRun(void *arg)
last_lags = lags;
last_report = now;
last_skipped = thread->throttle_latency_skipped;
- next_report += (int64) progress *1000000;
+
+ /* Ensure that the next report is in the future, in case
+ * pgbench/postgres got stuck somewhere...
+ */
+ do {
+ next_report += (int64) progress * 1000000;
+ } while (now >= next_report);
}
}
#endif /* PTHREAD_FORK_EMULATION */
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers