# Explore how the rebucketing procedure works. Buckets are picked along
# multiples of the given base.
rebucket base=10 min=0ns max=100000h
----
bucket[  0] width=0s                 boundary=[-Inf, 0s)
bucket[  1] width=64ns               boundary=[0s, 64ns)
bucket[  2] width=576ns              boundary=[64ns, 640ns)
bucket[  3] width=6.528µs            boundary=[640ns, 7.168µs)
bucket[  4] width=74.752µs           boundary=[7.168µs, 81.92µs)
bucket[  5] width=835.584µs          boundary=[81.92µs, 917.504µs)
bucket[  6] width=9.568256ms         boundary=[917.504µs, 10.48576ms)
bucket[  7] width=106.954752ms       boundary=[10.48576ms, 117.440512ms)
bucket[  8] width=1.224736768s       boundary=[117.440512ms, 1.34217728s)
bucket[  9] width=13.690208256s      boundary=[1.34217728s, 15.032385536s)
bucket[ 10] width=2m36.766306304s    boundary=[15.032385536s, 2m51.79869184s)
bucket[ 11] width=29m12.346656768s   boundary=[2m51.79869184s, 32m4.145348608s)
bucket[ 12] width=5h34m26.087206912s boundary=[32m4.145348608s, 6h6m30.23255552s)
bucket[ 13] width=Inf                boundary=[6h6m30.23255552s, +Inf)


# Buckets are clamped at the max specified.
rebucket base=10 min=0ns max=1s
----
bucket[  0] width=0s                 boundary=[-Inf, 0s)
bucket[  1] width=64ns               boundary=[0s, 64ns)
bucket[  2] width=576ns              boundary=[64ns, 640ns)
bucket[  3] width=6.528µs            boundary=[640ns, 7.168µs)
bucket[  4] width=74.752µs           boundary=[7.168µs, 81.92µs)
bucket[  5] width=835.584µs          boundary=[81.92µs, 917.504µs)
bucket[  6] width=9.568256ms         boundary=[917.504µs, 10.48576ms)
bucket[  7] width=106.954752ms       boundary=[10.48576ms, 117.440512ms)
bucket[  8] width=1.224736768s       boundary=[117.440512ms, 1.34217728s)
bucket[  9] width=Inf                boundary=[1.34217728s, +Inf)

# Buckets are clamped at the min specified, picking the first bucket the houses
# the minimum and starting the base multiplier after that point.
rebucket base=10 min=1h max=10000h
----
bucket[  0] width=32m4.145348608s    boundary=[-Inf, 32m4.145348608s)
bucket[  1] width=5h34m26.087206912s boundary=[32m4.145348608s, 6h6m30.23255552s)
bucket[  2] width=Inf                boundary=[6h6m30.23255552s, +Inf)

# Clamping along both min/max also works.
rebucket base=10 min=1h max=3h
----
bucket[  0] width=32m4.145348608s    boundary=[-Inf, 32m4.145348608s)
bucket[  1] width=5h34m26.087206912s boundary=[32m4.145348608s, 6h6m30.23255552s)
bucket[  2] width=Inf                boundary=[6h6m30.23255552s, +Inf)

# As for the bucket values used in production.
rebucket base=1.1 min=50us max=100ms
----
bucket[  0] width=49.152µs           boundary=[-Inf, 49.152µs)
bucket[  1] width=8.192µs            boundary=[49.152µs, 57.344µs)
bucket[  2] width=8.192µs            boundary=[57.344µs, 65.536µs)
bucket[  3] width=16.384µs           boundary=[65.536µs, 81.92µs)
bucket[  4] width=16.384µs           boundary=[81.92µs, 98.304µs)
bucket[  5] width=16.384µs           boundary=[98.304µs, 114.688µs)
bucket[  6] width=16.384µs           boundary=[114.688µs, 131.072µs)
bucket[  7] width=32.768µs           boundary=[131.072µs, 163.84µs)
bucket[  8] width=32.768µs           boundary=[163.84µs, 196.608µs)
bucket[  9] width=32.768µs           boundary=[196.608µs, 229.376µs)
bucket[ 10] width=32.768µs           boundary=[229.376µs, 262.144µs)
bucket[ 11] width=65.536µs           boundary=[262.144µs, 327.68µs)
bucket[ 12] width=65.536µs           boundary=[327.68µs, 393.216µs)
bucket[ 13] width=65.536µs           boundary=[393.216µs, 458.752µs)
bucket[ 14] width=65.536µs           boundary=[458.752µs, 524.288µs)
bucket[ 15] width=131.072µs          boundary=[524.288µs, 655.36µs)
bucket[ 16] width=131.072µs          boundary=[655.36µs, 786.432µs)
bucket[ 17] width=131.072µs          boundary=[786.432µs, 917.504µs)
bucket[ 18] width=131.072µs          boundary=[917.504µs, 1.048576ms)
bucket[ 19] width=262.144µs          boundary=[1.048576ms, 1.31072ms)
bucket[ 20] width=262.144µs          boundary=[1.31072ms, 1.572864ms)
bucket[ 21] width=262.144µs          boundary=[1.572864ms, 1.835008ms)
bucket[ 22] width=262.144µs          boundary=[1.835008ms, 2.097152ms)
bucket[ 23] width=524.288µs          boundary=[2.097152ms, 2.62144ms)
bucket[ 24] width=524.288µs          boundary=[2.62144ms, 3.145728ms)
bucket[ 25] width=524.288µs          boundary=[3.145728ms, 3.670016ms)
bucket[ 26] width=524.288µs          boundary=[3.670016ms, 4.194304ms)
bucket[ 27] width=1.048576ms         boundary=[4.194304ms, 5.24288ms)
bucket[ 28] width=1.048576ms         boundary=[5.24288ms, 6.291456ms)
bucket[ 29] width=1.048576ms         boundary=[6.291456ms, 7.340032ms)
bucket[ 30] width=1.048576ms         boundary=[7.340032ms, 8.388608ms)
bucket[ 31] width=2.097152ms         boundary=[8.388608ms, 10.48576ms)
bucket[ 32] width=2.097152ms         boundary=[10.48576ms, 12.582912ms)
bucket[ 33] width=2.097152ms         boundary=[12.582912ms, 14.680064ms)
bucket[ 34] width=2.097152ms         boundary=[14.680064ms, 16.777216ms)
bucket[ 35] width=4.194304ms         boundary=[16.777216ms, 20.97152ms)
bucket[ 36] width=4.194304ms         boundary=[20.97152ms, 25.165824ms)
bucket[ 37] width=4.194304ms         boundary=[25.165824ms, 29.360128ms)
bucket[ 38] width=4.194304ms         boundary=[29.360128ms, 33.554432ms)
bucket[ 39] width=8.388608ms         boundary=[33.554432ms, 41.94304ms)
bucket[ 40] width=8.388608ms         boundary=[41.94304ms, 50.331648ms)
bucket[ 41] width=8.388608ms         boundary=[50.331648ms, 58.720256ms)
bucket[ 42] width=8.388608ms         boundary=[58.720256ms, 67.108864ms)
bucket[ 43] width=16.777216ms        boundary=[67.108864ms, 83.88608ms)
bucket[ 44] width=16.777216ms        boundary=[83.88608ms, 100.663296ms)
bucket[ 45] width=Inf                boundary=[100.663296ms, +Inf)

# The full set of bucket boundaries (everything above is a subset of this
# list).
buckets
----
bucket[  0] width=0s                 boundary=[-Inf, 0s)
bucket[  1] width=64ns               boundary=[0s, 64ns)
bucket[  2] width=64ns               boundary=[64ns, 128ns)
bucket[  3] width=64ns               boundary=[128ns, 192ns)
bucket[  4] width=64ns               boundary=[192ns, 256ns)
bucket[  5] width=64ns               boundary=[256ns, 320ns)
bucket[  6] width=64ns               boundary=[320ns, 384ns)
bucket[  7] width=64ns               boundary=[384ns, 448ns)
bucket[  8] width=64ns               boundary=[448ns, 512ns)
bucket[  9] width=128ns              boundary=[512ns, 640ns)
bucket[ 10] width=128ns              boundary=[640ns, 768ns)
bucket[ 11] width=128ns              boundary=[768ns, 896ns)
bucket[ 12] width=128ns              boundary=[896ns, 1.024µs)
bucket[ 13] width=256ns              boundary=[1.024µs, 1.28µs)
bucket[ 14] width=256ns              boundary=[1.28µs, 1.536µs)
bucket[ 15] width=256ns              boundary=[1.536µs, 1.792µs)
bucket[ 16] width=256ns              boundary=[1.792µs, 2.048µs)
bucket[ 17] width=512ns              boundary=[2.048µs, 2.56µs)
bucket[ 18] width=512ns              boundary=[2.56µs, 3.072µs)
bucket[ 19] width=512ns              boundary=[3.072µs, 3.584µs)
bucket[ 20] width=512ns              boundary=[3.584µs, 4.096µs)
bucket[ 21] width=1.024µs            boundary=[4.096µs, 5.12µs)
bucket[ 22] width=1.024µs            boundary=[5.12µs, 6.144µs)
bucket[ 23] width=1.024µs            boundary=[6.144µs, 7.168µs)
bucket[ 24] width=1.024µs            boundary=[7.168µs, 8.192µs)
bucket[ 25] width=2.048µs            boundary=[8.192µs, 10.24µs)
bucket[ 26] width=2.048µs            boundary=[10.24µs, 12.288µs)
bucket[ 27] width=2.048µs            boundary=[12.288µs, 14.336µs)
bucket[ 28] width=2.048µs            boundary=[14.336µs, 16.384µs)
bucket[ 29] width=4.096µs            boundary=[16.384µs, 20.48µs)
bucket[ 30] width=4.096µs            boundary=[20.48µs, 24.576µs)
bucket[ 31] width=4.096µs            boundary=[24.576µs, 28.672µs)
bucket[ 32] width=4.096µs            boundary=[28.672µs, 32.768µs)
bucket[ 33] width=8.192µs            boundary=[32.768µs, 40.96µs)
bucket[ 34] width=8.192µs            boundary=[40.96µs, 49.152µs)
bucket[ 35] width=8.192µs            boundary=[49.152µs, 57.344µs)
bucket[ 36] width=8.192µs            boundary=[57.344µs, 65.536µs)
bucket[ 37] width=16.384µs           boundary=[65.536µs, 81.92µs)
bucket[ 38] width=16.384µs           boundary=[81.92µs, 98.304µs)
bucket[ 39] width=16.384µs           boundary=[98.304µs, 114.688µs)
bucket[ 40] width=16.384µs           boundary=[114.688µs, 131.072µs)
bucket[ 41] width=32.768µs           boundary=[131.072µs, 163.84µs)
bucket[ 42] width=32.768µs           boundary=[163.84µs, 196.608µs)
bucket[ 43] width=32.768µs           boundary=[196.608µs, 229.376µs)
bucket[ 44] width=32.768µs           boundary=[229.376µs, 262.144µs)
bucket[ 45] width=65.536µs           boundary=[262.144µs, 327.68µs)
bucket[ 46] width=65.536µs           boundary=[327.68µs, 393.216µs)
bucket[ 47] width=65.536µs           boundary=[393.216µs, 458.752µs)
bucket[ 48] width=65.536µs           boundary=[458.752µs, 524.288µs)
bucket[ 49] width=131.072µs          boundary=[524.288µs, 655.36µs)
bucket[ 50] width=131.072µs          boundary=[655.36µs, 786.432µs)
bucket[ 51] width=131.072µs          boundary=[786.432µs, 917.504µs)
bucket[ 52] width=131.072µs          boundary=[917.504µs, 1.048576ms)
bucket[ 53] width=262.144µs          boundary=[1.048576ms, 1.31072ms)
bucket[ 54] width=262.144µs          boundary=[1.31072ms, 1.572864ms)
bucket[ 55] width=262.144µs          boundary=[1.572864ms, 1.835008ms)
bucket[ 56] width=262.144µs          boundary=[1.835008ms, 2.097152ms)
bucket[ 57] width=524.288µs          boundary=[2.097152ms, 2.62144ms)
bucket[ 58] width=524.288µs          boundary=[2.62144ms, 3.145728ms)
bucket[ 59] width=524.288µs          boundary=[3.145728ms, 3.670016ms)
bucket[ 60] width=524.288µs          boundary=[3.670016ms, 4.194304ms)
bucket[ 61] width=1.048576ms         boundary=[4.194304ms, 5.24288ms)
bucket[ 62] width=1.048576ms         boundary=[5.24288ms, 6.291456ms)
bucket[ 63] width=1.048576ms         boundary=[6.291456ms, 7.340032ms)
bucket[ 64] width=1.048576ms         boundary=[7.340032ms, 8.388608ms)
bucket[ 65] width=2.097152ms         boundary=[8.388608ms, 10.48576ms)
bucket[ 66] width=2.097152ms         boundary=[10.48576ms, 12.582912ms)
bucket[ 67] width=2.097152ms         boundary=[12.582912ms, 14.680064ms)
bucket[ 68] width=2.097152ms         boundary=[14.680064ms, 16.777216ms)
bucket[ 69] width=4.194304ms         boundary=[16.777216ms, 20.97152ms)
bucket[ 70] width=4.194304ms         boundary=[20.97152ms, 25.165824ms)
bucket[ 71] width=4.194304ms         boundary=[25.165824ms, 29.360128ms)
bucket[ 72] width=4.194304ms         boundary=[29.360128ms, 33.554432ms)
bucket[ 73] width=8.388608ms         boundary=[33.554432ms, 41.94304ms)
bucket[ 74] width=8.388608ms         boundary=[41.94304ms, 50.331648ms)
bucket[ 75] width=8.388608ms         boundary=[50.331648ms, 58.720256ms)
bucket[ 76] width=8.388608ms         boundary=[58.720256ms, 67.108864ms)
bucket[ 77] width=16.777216ms        boundary=[67.108864ms, 83.88608ms)
bucket[ 78] width=16.777216ms        boundary=[83.88608ms, 100.663296ms)
bucket[ 79] width=16.777216ms        boundary=[100.663296ms, 117.440512ms)
bucket[ 80] width=16.777216ms        boundary=[117.440512ms, 134.217728ms)
bucket[ 81] width=33.554432ms        boundary=[134.217728ms, 167.77216ms)
bucket[ 82] width=33.554432ms        boundary=[167.77216ms, 201.326592ms)
bucket[ 83] width=33.554432ms        boundary=[201.326592ms, 234.881024ms)
bucket[ 84] width=33.554432ms        boundary=[234.881024ms, 268.435456ms)
bucket[ 85] width=67.108864ms        boundary=[268.435456ms, 335.54432ms)
bucket[ 86] width=67.108864ms        boundary=[335.54432ms, 402.653184ms)
bucket[ 87] width=67.108864ms        boundary=[402.653184ms, 469.762048ms)
bucket[ 88] width=67.108864ms        boundary=[469.762048ms, 536.870912ms)
bucket[ 89] width=134.217728ms       boundary=[536.870912ms, 671.08864ms)
bucket[ 90] width=134.217728ms       boundary=[671.08864ms, 805.306368ms)
bucket[ 91] width=134.217728ms       boundary=[805.306368ms, 939.524096ms)
bucket[ 92] width=134.217728ms       boundary=[939.524096ms, 1.073741824s)
bucket[ 93] width=268.435456ms       boundary=[1.073741824s, 1.34217728s)
bucket[ 94] width=268.435456ms       boundary=[1.34217728s, 1.610612736s)
bucket[ 95] width=268.435456ms       boundary=[1.610612736s, 1.879048192s)
bucket[ 96] width=268.435456ms       boundary=[1.879048192s, 2.147483648s)
bucket[ 97] width=536.870912ms       boundary=[2.147483648s, 2.68435456s)
bucket[ 98] width=536.870912ms       boundary=[2.68435456s, 3.221225472s)
bucket[ 99] width=536.870912ms       boundary=[3.221225472s, 3.758096384s)
bucket[100] width=536.870912ms       boundary=[3.758096384s, 4.294967296s)
bucket[101] width=1.073741824s       boundary=[4.294967296s, 5.36870912s)
bucket[102] width=1.073741824s       boundary=[5.36870912s, 6.442450944s)
bucket[103] width=1.073741824s       boundary=[6.442450944s, 7.516192768s)
bucket[104] width=1.073741824s       boundary=[7.516192768s, 8.589934592s)
bucket[105] width=2.147483648s       boundary=[8.589934592s, 10.73741824s)
bucket[106] width=2.147483648s       boundary=[10.73741824s, 12.884901888s)
bucket[107] width=2.147483648s       boundary=[12.884901888s, 15.032385536s)
bucket[108] width=2.147483648s       boundary=[15.032385536s, 17.179869184s)
bucket[109] width=4.294967296s       boundary=[17.179869184s, 21.47483648s)
bucket[110] width=4.294967296s       boundary=[21.47483648s, 25.769803776s)
bucket[111] width=4.294967296s       boundary=[25.769803776s, 30.064771072s)
bucket[112] width=4.294967296s       boundary=[30.064771072s, 34.359738368s)
bucket[113] width=8.589934592s       boundary=[34.359738368s, 42.94967296s)
bucket[114] width=8.589934592s       boundary=[42.94967296s, 51.539607552s)
bucket[115] width=8.589934592s       boundary=[51.539607552s, 1m0.129542144s)
bucket[116] width=8.589934592s       boundary=[1m0.129542144s, 1m8.719476736s)
bucket[117] width=17.179869184s      boundary=[1m8.719476736s, 1m25.89934592s)
bucket[118] width=17.179869184s      boundary=[1m25.89934592s, 1m43.079215104s)
bucket[119] width=17.179869184s      boundary=[1m43.079215104s, 2m0.259084288s)
bucket[120] width=17.179869184s      boundary=[2m0.259084288s, 2m17.438953472s)
bucket[121] width=34.359738368s      boundary=[2m17.438953472s, 2m51.79869184s)
bucket[122] width=34.359738368s      boundary=[2m51.79869184s, 3m26.158430208s)
bucket[123] width=34.359738368s      boundary=[3m26.158430208s, 4m0.518168576s)
bucket[124] width=34.359738368s      boundary=[4m0.518168576s, 4m34.877906944s)
bucket[125] width=1m8.719476736s     boundary=[4m34.877906944s, 5m43.59738368s)
bucket[126] width=1m8.719476736s     boundary=[5m43.59738368s, 6m52.316860416s)
bucket[127] width=1m8.719476736s     boundary=[6m52.316860416s, 8m1.036337152s)
bucket[128] width=1m8.719476736s     boundary=[8m1.036337152s, 9m9.755813888s)
bucket[129] width=2m17.438953472s    boundary=[9m9.755813888s, 11m27.19476736s)
bucket[130] width=2m17.438953472s    boundary=[11m27.19476736s, 13m44.633720832s)
bucket[131] width=2m17.438953472s    boundary=[13m44.633720832s, 16m2.072674304s)
bucket[132] width=2m17.438953472s    boundary=[16m2.072674304s, 18m19.511627776s)
bucket[133] width=4m34.877906944s    boundary=[18m19.511627776s, 22m54.38953472s)
bucket[134] width=4m34.877906944s    boundary=[22m54.38953472s, 27m29.267441664s)
bucket[135] width=4m34.877906944s    boundary=[27m29.267441664s, 32m4.145348608s)
bucket[136] width=4m34.877906944s    boundary=[32m4.145348608s, 36m39.023255552s)
bucket[137] width=9m9.755813888s     boundary=[36m39.023255552s, 45m48.77906944s)
bucket[138] width=9m9.755813888s     boundary=[45m48.77906944s, 54m58.534883328s)
bucket[139] width=9m9.755813888s     boundary=[54m58.534883328s, 1h4m8.290697216s)
bucket[140] width=9m9.755813888s     boundary=[1h4m8.290697216s, 1h13m18.046511104s)
bucket[141] width=18m19.511627776s   boundary=[1h13m18.046511104s, 1h31m37.55813888s)
bucket[142] width=18m19.511627776s   boundary=[1h31m37.55813888s, 1h49m57.069766656s)
bucket[143] width=18m19.511627776s   boundary=[1h49m57.069766656s, 2h8m16.581394432s)
bucket[144] width=18m19.511627776s   boundary=[2h8m16.581394432s, 2h26m36.093022208s)
bucket[145] width=36m39.023255552s   boundary=[2h26m36.093022208s, 3h3m15.11627776s)
bucket[146] width=36m39.023255552s   boundary=[3h3m15.11627776s, 3h39m54.139533312s)
bucket[147] width=36m39.023255552s   boundary=[3h39m54.139533312s, 4h16m33.162788864s)
bucket[148] width=36m39.023255552s   boundary=[4h16m33.162788864s, 4h53m12.186044416s)
bucket[149] width=1h13m18.046511104s boundary=[4h53m12.186044416s, 6h6m30.23255552s)
bucket[150] width=1h13m18.046511104s boundary=[6h6m30.23255552s, 7h19m48.279066624s)
bucket[151] width=1h13m18.046511104s boundary=[7h19m48.279066624s, 8h33m6.325577728s)
bucket[152] width=1h13m18.046511104s boundary=[8h33m6.325577728s, 9h46m24.372088832s)
bucket[153] width=2h26m36.093022208s boundary=[9h46m24.372088832s, 12h13m0.46511104s)
bucket[154] width=2h26m36.093022208s boundary=[12h13m0.46511104s, 14h39m36.558133248s)
bucket[155] width=2h26m36.093022208s boundary=[14h39m36.558133248s, 17h6m12.651155456s)
bucket[156] width=2h26m36.093022208s boundary=[17h6m12.651155456s, 19h32m48.744177664s)
bucket[157] width=4h53m12.186044416s boundary=[19h32m48.744177664s, 24h26m0.93022208s)
bucket[158] width=4h53m12.186044416s boundary=[24h26m0.93022208s, 29h19m13.116266496s)
bucket[159] width=4h53m12.186044416s boundary=[29h19m13.116266496s, 34h12m25.302310912s)
bucket[160] width=4h53m12.186044416s boundary=[34h12m25.302310912s, 39h5m37.488355328s)
bucket[161] width=Inf                boundary=[39h5m37.488355328s, +Inf)
