summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorNoah Misch <noah@leadboat.com>2013-09-25 23:09:50 -0400
committerNoah Misch <noah@leadboat.com>2013-09-25 23:11:34 -0400
commitc2df45a37cd9e32815fe2786cbb3ef905daaa7d2 (patch)
treef110318cef8e588033878e3c955cd7817dd516a5 /contrib
parent77ae7f7c356064f5355e004b95f485358dfc1360 (diff)
downloadpostgresql-c2df45a37cd9e32815fe2786cbb3ef905daaa7d2.tar.gz
pgbench: Correct for bias in --rate schedule generation.
Previous code gave a mean delay 0.44% below target. This change also has the effect of increasing the maximum possible delay. Fabien COELHO
Diffstat (limited to 'contrib')
-rw-r--r--contrib/pgbench/pgbench.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c
index 06dd7093fa..66ae48e4a7 100644
--- a/contrib/pgbench/pgbench.c
+++ b/contrib/pgbench/pgbench.c
@@ -929,13 +929,17 @@ top:
* that the series of delays will approximate a Poisson distribution
* centered on the throttle_delay time.
*
- * 1000 implies a 6.9 (-log(1/1000)) to 0.0 (log 1.0) delay multiplier.
+ * 10000 implies a 9.2 (-log(1/10000)) to 0.0 (log 1) delay multiplier,
+ * and results in a 0.055 % target underestimation bias:
+ *
+ * SELECT 1.0/AVG(-LN(i/10000.0)) FROM generate_series(1,10000) AS i;
+ * = 1.000552717032611116335474
*
* If transactions are too slow or a given wait is shorter than
* a transaction, the next transaction will start right away.
*/
- int64 wait = (int64)
- throttle_delay * -log(getrand(thread, 1, 1000)/1000.0);
+ int64 wait = (int64) (throttle_delay *
+ 1.00055271703 * -log(getrand(thread, 1, 10000)/10000.0));
thread->throttle_trigger += wait;