Commit 50aeaaaa authored by Dan Melnic's avatar Dan Melnic Committed by Facebook Github Bot

Adjust the growth factor based on the StaticMetaBase::head_::elementsCapacity

Summary: Adjust the growth factor based on the StaticMetaBase::head_::elementsCapacity

Reviewed By: yfeldblum

Differential Revision: D8409650

fbshipit-source-id: 189b839e19a1d3f2f1ac8e4b35a2f11a4d319ad7
parent ea244c69
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
#include <list> #include <list>
#include <mutex> #include <mutex>
constexpr auto kSmallGrowthFactor = 1.1;
constexpr auto kBigGrowthFactor = 1.7;
namespace folly { namespace threadlocal_detail { namespace folly { namespace threadlocal_detail {
void ThreadEntryNode::initIfZero(bool locked) { void ThreadEntryNode::initIfZero(bool locked) {
...@@ -291,7 +294,14 @@ ElementWrapper* StaticMetaBase::reallocate( ...@@ -291,7 +294,14 @@ ElementWrapper* StaticMetaBase::reallocate(
// Growth factor < 2, see folly/docs/FBVector.md; + 5 to prevent // Growth factor < 2, see folly/docs/FBVector.md; + 5 to prevent
// very slow start. // very slow start.
newCapacity = static_cast<size_t>((idval + 5) * 1.7); auto smallCapacity = static_cast<size_t>((idval + 5) * kSmallGrowthFactor);
auto bigCapacity = static_cast<size_t>((idval + 5) * kBigGrowthFactor);
newCapacity = (threadEntry->meta &&
(bigCapacity <= threadEntry->meta->head_.elementsCapacity))
? bigCapacity
: smallCapacity;
assert(newCapacity > prevCapacity); assert(newCapacity > prevCapacity);
ElementWrapper* reallocated = nullptr; ElementWrapper* reallocated = nullptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment