Add --with-lg-tcache-limit configuration option to allow for more than 4094 tcaches #2384
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the Couchbase Server Data Service (KV Engine), we use one tcache per arena, per thread (multipies).
We have one arena per bucket, and we currently support 30 buckets, but might eventually bump this up to 100 buckets per instance.
However, because we allocate a tcache per thread as well, the number of tcache which we use ends up being num-buckets x num-threads. Tcaches are allocated when a thread decides to use a bucket's arena, allocating tcaches lazily, so not all threads will need a tcache, but most will.
jemalloc can automatically allocate and make use of a tcache, but we've found that can result in incorrect accounting of memory stats per-arena, which is a deal-breaker for us, because we rely on some of these stats to calculate per-arena memory fragmentation.
We're currently testing how this change performs in our test environments, but plan on proceeding to ship a release with those changes and jemalloc configured with
--with-lg-tcache-limit=15
, to allow for up to 32K tcaches to be created. Note that we don't expect to actually reach that limit, but something within the range of 4-7K is what we'd want to be able to run correctly for some larger machine configurations.This change is ABI-breaking, but does not change the jemalloc API. We link to jemalloc statically, so this is not an issue for us.