Re: pgbench calculates summary numbers a wrong way. - Mailing list pgsql-hackers
| From | Kyotaro Horiguchi |
|---|---|
| Subject | Re: pgbench calculates summary numbers a wrong way. |
| Date | |
| Msg-id | 20200917.175945.992033299744600849.horikyota.ntt@gmail.com Whole thread Raw |
| In response to | Re: pgbench calculates summary numbers a wrong way. (Kyotaro Horiguchi <horikyota.ntt@gmail.com>) |
| Responses |
Re: pgbench calculates summary numbers a wrong way.
Re: pgbench calculates summary numbers a wrong way. |
| List | pgsql-hackers |
At Thu, 17 Sep 2020 17:52:23 +0900 (JST), Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote in
> Sorry, I sent a wrong version of the patch, contains some spelling
> errors. This is the right one.
Sigh.. I fixed some more wordings.
regards.
--
Kyotaro Horiguchi
NTT Open Source Software Center
From bd41d38cb056a6b8fe761266a55d0d46245fd9bf Mon Sep 17 00:00:00 2001
From: Kyotaro Horiguchi <horikyoga.ntt@gmail.com>
Date: Thu, 17 Sep 2020 17:20:10 +0900
Subject: [PATCH v3] Fix latency and tps calculation of pgbench
Fix the calculation for "latency average" and the "tps excluding
connections establishing" not to wrongly affected by connections
establishing time.
---
src/bin/pgbench/pgbench.c | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 332eabf637..3fd86eeb8a 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -5194,16 +5194,35 @@ printResults(StatsData *total, instr_time total_time,
instr_time conn_total_time, int64 latency_late)
{
double time_include,
+ time_exclude,
tps_include,
tps_exclude;
int64 ntx = total->cnt - total->skipped;
time_include = INSTR_TIME_GET_DOUBLE(total_time);
+ /*
+ * conn_total_time is the sum of the time each client took to establish a
+ * connection. In the multi-threaded case, all clients run on a thread wait
+ * for all the clients to establish a connection. So the actual total
+ * connection time of a thread is thread->conn_time * thread->nstate. Thus
+ * the total time took for connection establishment is:
+ *
+ * sum(thread->conn_time * thread->nstate) / nclients
+ *
+ * Assuming all clients took the same time to establish a connection and
+ * clients are distributed equally to threads, the expression is
+ * approximated as:
+ *
+ * thread->conn_time * (nclients/nthreads) / nclients
+ * = conn_total_time / nthreads
+ */
+ time_exclude = (time_include -
+ (INSTR_TIME_GET_DOUBLE(conn_total_time) / nthreads));
+
/* tps is about actually executed transactions */
tps_include = ntx / time_include;
- tps_exclude = ntx /
- (time_include - (INSTR_TIME_GET_DOUBLE(conn_total_time) / nclients));
+ tps_exclude = ntx / time_exclude;
/* Report test parameters. */
printf("transaction type: %s\n",
@@ -5249,7 +5268,7 @@ printResults(StatsData *total, instr_time total_time,
{
/* no measurement, show average latency computed from run time */
printf("latency average = %.3f ms\n",
- 1000.0 * time_include * nclients / total->cnt);
+ 1000.0 * time_exclude * nclients / total->cnt);
}
if (throttle_delay)
--
2.18.4
pgsql-hackers by date: