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

Grow arrays by a factor less than 2? #8269

Closed
johnmyleswhite opened this issue Sep 8, 2014 · 3 comments · Fixed by #40453
Closed

Grow arrays by a factor less than 2? #8269

johnmyleswhite opened this issue Sep 8, 2014 · 3 comments · Fixed by #40453
Labels
performance Must go faster speculative Whether the change will be implemented is speculative

Comments

@johnmyleswhite
Copy link
Member

I recently discovered this document in one of FB’s open source libraries for C++: https://github.com/facebook/folly/blob/master/folly/docs/FBVector.md

It makes an interesting argument for growing arrays by a factor smaller than 2 when resizing them so that you can reuse memory more easily. Not sure how much you also need to use a custom malloc routine to get the benefits being claimed, but I thought I'd raise the idea in case we can get any performance enhancements from these ideas.

@johnmyleswhite johnmyleswhite added feature speculative Whether the change will be implemented is speculative performance Must go faster labels Sep 8, 2014
@JeffBezanson
Copy link
Member

This seems like a good idea.

@quinnj
Copy link
Member

quinnj commented Nov 4, 2014

@vchuravy
Copy link
Member

vchuravy commented Nov 4, 2014

ArrayList in Java uses 1.5 as growth factor and [1] gives a bit more background on why this might be considered more optimal.

[1] http://crntaylor.wordpress.com/2011/07/15/optimal-memory-reallocation-and-the-golden-ratio/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster speculative Whether the change will be implemented is speculative
Projects
None yet
5 participants