~ubuntu-branches/ubuntu/trusty/google-perftools/trusty-proposed

« back to all changes in this revision

Viewing changes to debian/patches/TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES.patch

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-04-09 14:36:52 UTC
  • Revision ID: package-import@ubuntu.com-20150409143652-pxntzmjo3831n09u
Tags: 2.1-2ubuntu1.1
d/p/TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES.patch: Cherry pick fix from
upstream VCS to allow total thread cache size to be overridden using an
environment variable, allowing tcmalloc cpu burden when under memory
pressure to be reduced (LP: #1439277).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
5
 
 
6
In order to apply that, we're now doing explicit EnvToInt64 call as
 
7
part of initializing thread cache module.
 
8
---
 
9
 src/thread_cache.cc | 25 ++++++++++++++++++-------
 
10
 1 file changed, 18 insertions(+), 7 deletions(-)
 
11
 
 
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
 
16
@@ -44,13 +44,17 @@
 
17
 using std::min;
 
18
 using std::max;
 
19
 
 
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
 
29
+//
 
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.");
 
37
+
 
38
 
 
39
 namespace tcmalloc {
 
40
 
 
41
@@ -309,6 +313,9 @@ int ThreadCache::GetSamplePeriod() {
 
42
 void ThreadCache::InitModule() {
 
43
   SpinLockHolder h(Static::pageheap_lock());
 
44
   if (!phinited) {
 
45
+    set_overall_thread_cache_size(
 
46
+      EnvToInt64("TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES",
 
47
+                 kDefaultOverallThreadCacheSize));
 
48
     Static::InitStaticVars();
 
49
     threadcache_allocator.Init();
 
50
     phinited = 1;
 
51
@@ -493,6 +500,10 @@ void ThreadCache::GetThreadStats(uint64_t* total_bytes, uint64_t* class_count) {
 
52
   }
 
53
 }
 
54
 
 
55
+extern "C" {
 
56
+  void write(int, const char *, size_t);
 
57
+}
 
58
+
 
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;
 
62
-- 
 
63
1.8.4.2
 
64