]> granicus.if.org Git - postgresql/commit
Simplify calculation of Poisson distributed delays in pgbench --rate mode.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 11 Sep 2014 10:00:48 +0000 (13:00 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 11 Sep 2014 10:12:43 +0000 (13:12 +0300)
commitc8b24991115c967abee06ccc78e11532d02cffde
treead736e1ad9e04437d7415b57b7aaa5712f7e3c32
parent8c9dd69fc2638701653c90bbf291884f8ca23d56
Simplify calculation of Poisson distributed delays in pgbench --rate mode.

The previous coding first generated a uniform random value between 0.0 and
1.0, then converted that to an integer between 1 and 10000, and divided that
again by 10000. Those conversions are unnecessary; we can use the double
value that pg_erand48() returns directly. While we're at it, put the logic
into a helper function, getPoissonRand().

The largest delay generated by the old coding was about 9.2 times the
average, because of the way the uniformly distributed value used for the
calculation was truncated to 1/10000 granularity. The new coding doesn't
have such clamping. With my laptop's DBL_MIN value, the maximum delay with
the new coding is about 700x the average. That seems acceptable - any
reasonable pgbench session should last long enough to average that out.

Backpatch to 9.4.
contrib/pgbench/pgbench.c