1
From d9fc8a76beb21565b25aa6a32d8bd03b61f71ef7 Mon Sep 17 00:00:00 2001
2
From: Aliaksey Kandratsenka <alk@tut.by>
3
Date: Sat, 9 Nov 2013 14:19:16 -0800
4
Subject: [PATCH] issue-585: fixed use of TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES
6
In order to apply that, we're now doing explicit EnvToInt64 call as
7
part of initializing thread cache module.
9
src/thread_cache.cc | 25 ++++++++++++++++++-------
10
1 file changed, 18 insertions(+), 7 deletions(-)
12
diff --git a/src/thread_cache.cc b/src/thread_cache.cc
13
index 734c7f6..0f489c9 100644
14
--- a/src/thread_cache.cc
15
+++ b/src/thread_cache.cc
20
-DEFINE_int64(tcmalloc_max_total_thread_cache_bytes,
21
- EnvToInt64("TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES",
22
- kDefaultOverallThreadCacheSize),
23
- "Bound on the total amount of bytes allocated to "
24
- "thread caches. This bound is not strict, so it is possible "
25
- "for the cache to go over this bound in certain circumstances. "
26
- "Maximum value of this flag is capped to 1 GB.");
27
+// Note: this is initialized manually in InitModule to ensure that
28
+// it's configured at right time
30
+// DEFINE_int64(tcmalloc_max_total_thread_cache_bytes,
31
+// EnvToInt64("TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES",
32
+// kDefaultOverallThreadCacheSize),
33
+// "Bound on the total amount of bytes allocated to "
34
+// "thread caches. This bound is not strict, so it is possible "
35
+// "for the cache to go over this bound in certain circumstances. "
36
+// "Maximum value of this flag is capped to 1 GB.");
41
@@ -309,6 +313,9 @@ int ThreadCache::GetSamplePeriod() {
42
void ThreadCache::InitModule() {
43
SpinLockHolder h(Static::pageheap_lock());
45
+ set_overall_thread_cache_size(
46
+ EnvToInt64("TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES",
47
+ kDefaultOverallThreadCacheSize));
48
Static::InitStaticVars();
49
threadcache_allocator.Init();
51
@@ -493,6 +500,10 @@ void ThreadCache::GetThreadStats(uint64_t* total_bytes, uint64_t* class_count) {
56
+ void write(int, const char *, size_t);
59
void ThreadCache::set_overall_thread_cache_size(size_t new_size) {
60
// Clip the value to a reasonable range
61
if (new_size < kMinThreadCacheSize) new_size = kMinThreadCacheSize;