Hi Reinhard, On Thu, Nov 24, 2016 at 10:04:31PM +0100, Reinhard Vicinus wrote: > Hi, > > we use haproxy (1.6.9) to balance very long running POST requests > (around 50 seconds) to backend servers. It generally works like a charm, > but the average queue time and average total session time statistic > values are totally screwed up. > > The problem is that the average is calculated like this for every request: > > sum = sum * 511 / 512 + value > > for a fixed value and enough iterations: > > sum = value * 511 > > the problem is that at every iteration sum will first be multiplied by > 511 and therefore the maximum value during the calculation is: > > value * 511 * 511 > > A unsigned int can store a maximum value of 4294967296. Divided by > 511*511 results in 16448. That means any backend with average times > above 16448ms will be affected by integer overflow and have wrong values.
Yes we do know this limitation. > The attached patch tries to solve this by storing and calculating sum as > unsigned long long instead of a unsigned int. I don't know if the > attached patch will work in every case, but during my limited testing it > worked. It will definitely work, but I didn't want to do it because of the very expensive cost of the 64x64 multiply and divide on 32 bit platforms which causes a measurable performance impact. However I'll do some tests because is often OK, and doing 32x32/32 with a 64-bit intermediary result is OK as well. If I can do it this way, I'll do it. Otherwise I'd prefer that we just switch do long so that 64-bit platforms can benefit from the large timers and 32-bit ones are limited to lower values. Thanks, Willy