improve defaultSize adjustment for rare case when next few j > 0 p.calls after sort
improve defaultSize adjustment for rare case when next few j > 0 p.calls after sort (==> a) have a[j].calls ~= a[0].calls and some of them a[j].size > defaultSize (== a[0].size) + added test TestPoolCalibrateWithAdjustment
For example, if we have after sort.Sort(a): https://github.com/valyala/bytebufferpool/blob/9ccb276166ca44142323af78b12322a5bc714928/pool.go#L118
a[0].calls = 42001, a[0].size = 512a[1].calls = 40000, a[0].size = 1024
Before this commit we use 512 as new p.defaultSize and in this commit we use 1024 as new p.defaultSize, what may prevent very rare case, when in 40000 new allocations out of 82000 we have additional memory allocation for b.B by append after initial allocation by pool.New in price of additional allocated memory for all another allocations, include top 512 sizes
Nearness of the a[j].calls to the initial a[0].calls is adjusted by the calibrateDefaultSizeAdjustmentsSpread and calibrateDSASGcd constants
- also replaced floating-point arithmetic with integer muldiv equivalent (calibrate() should become slightly faster)
- fix tests fn allocNBytes()
- some microoptimizations
Sorry for my bad English