Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve defaultSize adjustment for rare case when next few j > 0 p.calls after sort #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Illirgway
Copy link

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):

sort.Sort(a)

  • a[0].calls = 42001, a[0].size = 512
  • a[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

…lls after sort (==> a) have a[j].calls ~= a[0].calls and some of them a[j].size > defaultSize (== a[0].size) + added test TestPoolCalibrateWithAdjustment

+ also replaced floating-point arithmetic with integer muldiv equivalent
+ fix tests fn allocNBytes()
+ some microoptimizations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant