Hello Steve,
printf("number of transactions actually processed: " INT64_FORMAT
"/%d\n",
- total->cnt - total->skipped, nxacts * nclients);
+ total->cnt, nxacts * nclients);
I think you want ntx instead of total->cnt here.
Indeed... and this is also what my git branch contains... I just sent the
wrong version, sorry:-( The same fix is also needed in the else branch.
Here is the hopefully right version, which passes tests here.
--
Fabien.
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index ec56a74..1a5c04c 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -2613,7 +2613,7 @@ processXactStats(TState *thread, CState *st, instr_time *now,
doLog(thread, st, agg, skipped, latency, lag);
/* XXX could use a mutex here, but we choose not to */
- if (per_script_stats)
+ if (per_script_stats || latency_limit)
accumStats(&sql_script[st->use_file].stats, skipped, latency, lag);
}
@@ -3556,11 +3556,14 @@ printResults(TState *threads, StatsData *total, instr_time total_time,
double time_include,
tps_include,
tps_exclude;
+ int64 ntx = total->cnt - total->skipped;
time_include = INSTR_TIME_GET_DOUBLE(total_time);
- tps_include = total->cnt / time_include;
- tps_exclude = total->cnt / (time_include -
- (INSTR_TIME_GET_DOUBLE(conn_total_time) / nclients));
+
+ /* tps is about actually executed transactions */
+ tps_include = ntx / time_include;
+ tps_exclude = ntx /
+ (time_include - (INSTR_TIME_GET_DOUBLE(conn_total_time) / nclients));
/* Report test parameters. */
printf("transaction type: %s\n",
@@ -3573,13 +3576,13 @@ printResults(TState *threads, StatsData *total, instr_time total_time,
{
printf("number of transactions per client: %d\n", nxacts);
printf("number of transactions actually processed: " INT64_FORMAT "/%d\n",
- total->cnt - total->skipped, nxacts * nclients);
+ ntx, nxacts * nclients);
}
else
{
printf("duration: %d s\n", duration);
printf("number of transactions actually processed: " INT64_FORMAT "\n",
- total->cnt);
+ ntx);
}
/* Remaining stats are nonsensical if we failed to execute any xacts */
@@ -4706,7 +4709,8 @@ threadRun(void *arg)
{
/* generate and show report */
StatsData cur;
- int64 run = now - last_report;
+ int64 run = now - last_report,
+ ntx;
double tps,
total_run,
latency,
@@ -4721,7 +4725,7 @@ threadRun(void *arg)
* XXX: No locking. There is no guarantee that we get an
* atomic snapshot of the transaction count and latencies, so
* these figures can well be off by a small amount. The
- * progress is report's purpose is to give a quick overview of
+ * progress report's purpose is to give a quick overview of
* how the test is going, so that shouldn't matter too much.
* (If a read from a 64-bit integer is not atomic, you might
* get a "torn" read and completely bogus latencies though!)
@@ -4735,15 +4739,14 @@ threadRun(void *arg)
cur.skipped += thread[i].stats.skipped;
}
+ /* we count only actually executed transactions */
+ ntx = (cur.cnt - cur.skipped) - (last.cnt - last.skipped);
total_run = (now - thread_start) / 1000000.0;
- tps = 1000000.0 * (cur.cnt - last.cnt) / run;
- latency = 0.001 * (cur.latency.sum - last.latency.sum) /
- (cur.cnt - last.cnt);
- sqlat = 1.0 * (cur.latency.sum2 - last.latency.sum2)
- / (cur.cnt - last.cnt);
+ tps = 1000000.0 * ntx / run;
+ latency = 0.001 * (cur.latency.sum - last.latency.sum) / ntx;
+ sqlat = 1.0 * (cur.latency.sum2 - last.latency.sum2) / ntx;
stdev = 0.001 * sqrt(sqlat - 1000000.0 * latency * latency);
- lag = 0.001 * (cur.lag.sum - last.lag.sum) /
- (cur.cnt - last.cnt);
+ lag = 0.001 * (cur.lag.sum - last.lag.sum) / ntx;
if (progress_timestamp)
{
@@ -4760,6 +4763,7 @@ threadRun(void *arg)
(long) tv.tv_sec, (long) (tv.tv_usec / 1000));
}
else
+ /* round seconds are expected, nut the thread may be late */
snprintf(tbuf, sizeof(tbuf), "%.1f s", total_run);
fprintf(stderr,