Skip to content

Commit c2df45a

Browse files
committed
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
1 parent 77ae7f7 commit c2df45a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

contrib/pgbench/pgbench.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -929,13 +929,17 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
929929
* that the series of delays will approximate a Poisson distribution
930930
* centered on the throttle_delay time.
931931
*
932-
* 1000 implies a 6.9 (-log(1/1000)) to 0.0 (log 1.0) delay multiplier.
932+
* 10000 implies a 9.2 (-log(1/10000)) to 0.0 (log 1) delay multiplier,
933+
* and results in a 0.055 % target underestimation bias:
934+
*
935+
* SELECT 1.0/AVG(-LN(i/10000.0)) FROM generate_series(1,10000) AS i;
936+
* = 1.000552717032611116335474
933937
*
934938
* If transactions are too slow or a given wait is shorter than
935939
* a transaction, the next transaction will start right away.
936940
*/
937-
int64 wait = (int64)
938-
throttle_delay * -log(getrand(thread, 1, 1000)/1000.0);
941+
int64 wait = (int64) (throttle_delay *
942+
1.00055271703 * -log(getrand(thread, 1, 10000)/10000.0));
939943

940944
thread->throttle_trigger += wait;
941945

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy