Memory Reallocation Revisited

Back in January I wrote about a charming result concerning how much memory should be increased when reallocating. Via Artur Malabarba, I came across a tweet by Wilfred Hughes

pointing to Facebook’s implementation of the idea. The FBVector.md file at the link explains why they use a factor of 1.5 instead of 2 (it misses the beautiful result about the golden ratio, though).

Their implementation of the C++ std::vector library has other optimizations, which are also interesting. If you’re working in C++, you should definitely give it a look.

In my original post, I remarked that “none of this is of great import.” The folks at Facebook have shown that that was wrong.

This entry was posted in Programming and tagged . Bookmark the permalink.