-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Improve vector growth performance near max_size #1221
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
Conversation
mnatsuhara
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you be interested in finding other affected places in the repo and implementing similar fixes there? (As @BillyONeal mentions in the issue, the same pattern is likely present in other places implementing geometric growth.) If you would rather not, we should probably file a subsequent issue to follow up on other occurrences after vector is fixed.
Yes, I would. I will apply your suggestion on this change and fix other containers for the same issue. @mnatsuhara Sorry I couldn't find anywhere else contain a similar issue. could you provide a clue about where else should I apply this fix? |
|
Lines 4257 to 4269 in 484fbc9
After a quick search, I also don't see any other occurrences of geometric growth that need to be changed. ( valarray grows exactly.) I searched for "geometric", "exponential", and \w+ \+ \w+ / 2. So I think this is sufficient, no need for a followup issue.
|
|
Thanks for making our |
Fixes #1217
As @BillyONeal suggested here I think in the described situation, it is more reasonable to grow the vector to the maximum possible size according to the geometric growth speed.
Furthermore, if someone repeatedly increases vector size it is more likely that he/she wants to increase the size even more. So it is better to have the maximum preallocation space that prevents huge relocating data.
So I've changed it to
max_size()