Hello Heikki,

This now begs the question:

In --rate mode, shouldn't the reported transaction latency also be calculated from the *scheduled* start time, not the time the transaction actually started? Otherwise we're using two different definitions of "latency", one for the purpose of the limit, and another for reporting.

It could. Find a small patch **on top of v5** which does that. I've tried to update the documentation accordingly as well.

Note that the information is already there as the average lag time is reported, ISTM that:

        avg latency2 ~ avg lag + avg latency1

so it is just a matter of choice, both are ok somehow. I would be fine with both.

--
Fabien.
diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c
index 96e5fb9..40427a3 100644
--- a/contrib/pgbench/pgbench.c
+++ b/contrib/pgbench/pgbench.c
@@ -1125,12 +1125,24 @@ top:
 			commands[st->state + 1] == NULL)
 		{
 			instr_time	diff;
-			int64		latency, now;
+			int64		latency;
 
 			INSTR_TIME_SET_CURRENT(diff);
-			now = INSTR_TIME_GET_MICROSEC(diff);
-			INSTR_TIME_SUBTRACT(diff, st->txn_begin);
-			latency = INSTR_TIME_GET_MICROSEC(diff);
+
+			if (throttle_delay)
+			{
+				/* Under throttling, compute latency wrt to the initial schedule,
+				 * not the actual transaction start.
+				 */
+				int64 now = INSTR_TIME_GET_MICROSEC(diff);
+				latency = now - thread->throttle_trigger;
+			}
+			else
+			{
+				INSTR_TIME_SUBTRACT(diff, st->txn_begin);
+				latency = INSTR_TIME_GET_MICROSEC(diff);
+			}
+
 			st->txn_latencies += latency;
 
 			/*
@@ -1144,16 +1156,8 @@ top:
 
 			/* record over the limit transactions if needed.
 			 */
-			if (latency_limit)
-			{
-				/* Under throttling, late means wrt to the initial schedule,
-				 * not the actual transaction start
-				 */
-				if (throttle_delay)
-					latency = now - thread->throttle_trigger;
-				if (latency > latency_limit)
-					thread->latency_late++;
-			}
+			if (latency_limit && latency > latency_limit)
+				thread->latency_late++;
 		}
 
 		/*
diff --git a/doc/src/sgml/pgbench.sgml b/doc/src/sgml/pgbench.sgml
index f80116f..453ae4b 100644
--- a/doc/src/sgml/pgbench.sgml
+++ b/doc/src/sgml/pgbench.sgml
@@ -420,8 +420,10 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
         Show progress report every <literal>sec</> seconds.  The report
         includes the time since the beginning of the run, the tps since the
         last report, and the transaction latency average and standard
-        deviation since the last report.  Under throttling (<option>-R</>), it
-        also includes the average schedule lag time since the last report.
+        deviation since the last report.  Under throttling (<option>-R</>),
+        the latency is computed with respect to the transaction scheduled
+        start time, not the actual transaction beginning time, and it also
+        includes the average schedule lag time since the last report.
        </para>
       </listitem>
      </varlistentry>
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to