pgbench: Avoid unnecessary measurement of connection delays.
authorFujii Masao <fujii@postgresql.org>
Mon, 30 Aug 2021 12:35:24 +0000 (21:35 +0900)
committerFujii Masao <fujii@postgresql.org>
Mon, 30 Aug 2021 12:35:24 +0000 (21:35 +0900)
Commit 547f04e734 changed pgbench so that it used the measurement result
of connection delays in its benchmark report only when -C/--connect option
is specified. But previously those delays were unnecessarily measured
even when that option is not specified. Which was a waste of cycles.
This commit improves pgbench so that it avoids such unnecessary measurement.

Back-patch to v14 where commit 547f04e734 first appeared.

Author: Yugo Nagata
Reviewed-by: Fabien COELHO, Asif Rehman, Fujii Masao
Discussion: https://postgr.es/m/20210614151155.a393bc7d8fed183e38c9f52a@sraoss.co.jp

src/bin/pgbench/pgbench.c

index b0e20c46ae39e474595c2243867123e0fe08cb1b..bca136bdd586ebe5a3917bb6f7a1838601a06b8b 100644 (file)
@@ -6603,6 +6603,7 @@ threadRun(void *arg)
 
        thread_start = pg_time_now();
        thread->started_time = thread_start;
+       thread->conn_duration = 0;
        last_report = thread_start;
        next_report = last_report + (int64) 1000000 * progress;
 
@@ -6626,14 +6627,6 @@ threadRun(void *arg)
                                goto done;
                        }
                }
-
-               /* compute connection delay */
-               thread->conn_duration = pg_time_now() - thread->started_time;
-       }
-       else
-       {
-               /* no connection delay to record */
-               thread->conn_duration = 0;
        }
 
        /* GO */