- Notifications
You must be signed in to change notification settings - Fork5
Commit54a2d5b
committed
Simplify calculation of Poisson distributed delays in pgbench --rate mode.
The previous coding first generated a uniform random value between 0.0 and1.0, then converted that to an integer between 1 and 10000, and divided thatagain by 10000. Those conversions are unnecessary; we can use the doublevalue that pg_erand48() returns directly. While we're at it, put the logicinto a helper function, getPoissonRand().The largest delay generated by the old coding was about 9.2 times theaverage, because of the way the uniformly distributed value used for thecalculation was truncated to 1/10000 granularity. The new coding doesn'thave such clamping. With my laptop's DBL_MIN value, the maximum delay withthe new coding is about 700x the average. That seems acceptable - anyreasonable pgbench session should last long enough to average that out.Backpatch to 9.4.1 parent02e3bcc commit54a2d5b
1 file changed
+22
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
552 | 552 | | |
553 | 553 | | |
554 | 554 | | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
555 | 574 | | |
556 | 575 | | |
557 | 576 | | |
| |||
1009 | 1028 | | |
1010 | 1029 | | |
1011 | 1030 | | |
1012 | | - | |
1013 | | - | |
1014 | | - | |
1015 | | - | |
1016 | | - | |
1017 | | - | |
1018 | | - | |
1019 | | - | |
1020 | | - | |
| 1031 | + | |
| 1032 | + | |
1021 | 1033 | | |
1022 | 1034 | | |
1023 | 1035 | | |
1024 | 1036 | | |
1025 | | - | |
1026 | | - | |
| 1037 | + | |
1027 | 1038 | | |
1028 | 1039 | | |
1029 | 1040 | | |
| |||
0 commit comments
Comments
(0)