aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/tcmalloc/patches/yandex.patch
blob: 98eaf2f4d829194ebecbe9d9a693e349d9934ea9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
commit ab4069ebdd376db4d32c29e1a2414565ec849249 
author: prime 
date: 2021-10-07T14:52:42+03:00 
 
    Apply yandex patches 
 
--- contrib/libs/tcmalloc/tcmalloc/cpu_cache.cc	(5096009d22199137186c9a972bc88409d8ebd513) 
+++ contrib/libs/tcmalloc/tcmalloc/cpu_cache.cc	(ab4069ebdd376db4d32c29e1a2414565ec849249) 
@@ -1112,6 +1112,11 @@ extern "C" bool MallocExtension_Internal_GetPerCpuCachesActive() { 
   return tcmalloc::tcmalloc_internal::Static::CPUCacheActive(); 
 } 
  
+extern "C" void MallocExtension_Internal_DeactivatePerCpuCaches() { 
+  tcmalloc::tcmalloc_internal::Parameters::set_per_cpu_caches(false); 
+  tcmalloc::tcmalloc_internal::Static::DeactivateCPUCache(); 
+} 
+ 
 extern "C" int32_t MallocExtension_Internal_GetMaxPerCpuCacheSize() { 
   return tcmalloc::tcmalloc_internal::Parameters::max_per_cpu_cache_size(); 
 } 
--- contrib/libs/tcmalloc/tcmalloc/internal_malloc_extension.h	(5096009d22199137186c9a972bc88409d8ebd513) 
+++ contrib/libs/tcmalloc/tcmalloc/internal_malloc_extension.h	(ab4069ebdd376db4d32c29e1a2414565ec849249) 
@@ -75,6 +75,7 @@ ABSL_ATTRIBUTE_WEAK void MallocExtension_Internal_GetMemoryLimit( 
 ABSL_ATTRIBUTE_WEAK bool MallocExtension_Internal_GetNumericProperty( 
     const char* name_data, size_t name_size, size_t* value); 
 ABSL_ATTRIBUTE_WEAK bool MallocExtension_Internal_GetPerCpuCachesActive(); 
+ABSL_ATTRIBUTE_WEAK void MallocExtension_Internal_DeactivatePerCpuCaches(); 
 ABSL_ATTRIBUTE_WEAK int32_t MallocExtension_Internal_GetMaxPerCpuCacheSize(); 
 ABSL_ATTRIBUTE_WEAK void MallocExtension_Internal_GetSkipSubreleaseInterval( 
     absl::Duration* ret); 
--- contrib/libs/tcmalloc/tcmalloc/malloc_extension.cc	(5096009d22199137186c9a972bc88409d8ebd513) 
+++ contrib/libs/tcmalloc/tcmalloc/malloc_extension.cc	(ab4069ebdd376db4d32c29e1a2414565ec849249) 
@@ -287,6 +287,16 @@ bool MallocExtension::PerCpuCachesActive() { 
 #endif 
 } 
  
+void MallocExtension::DeactivatePerCpuCaches() { 
+#if ABSL_INTERNAL_HAVE_WEAK_MALLOCEXTENSION_STUBS 
+  if (MallocExtension_Internal_DeactivatePerCpuCaches == nullptr) { 
+    return; 
+  } 
+ 
+  MallocExtension_Internal_DeactivatePerCpuCaches(); 
+#endif 
+} 
+ 
 int32_t MallocExtension::GetMaxPerCpuCacheSize() { 
 #if ABSL_INTERNAL_HAVE_WEAK_MALLOCEXTENSION_STUBS 
   if (MallocExtension_Internal_GetMaxPerCpuCacheSize == nullptr) { 
--- contrib/libs/tcmalloc/tcmalloc/malloc_extension.h	(5096009d22199137186c9a972bc88409d8ebd513) 
+++ contrib/libs/tcmalloc/tcmalloc/malloc_extension.h	(ab4069ebdd376db4d32c29e1a2414565ec849249) 
@@ -329,6 +329,11 @@ class MallocExtension final { 
   // Gets whether TCMalloc is using per-CPU caches. 
   static bool PerCpuCachesActive(); 
  
+  // Extension for unified agent. 
+  // 
+  // Should be removed in the future https://st.yandex-team.ru/UNIFIEDAGENT-321 
+  static void DeactivatePerCpuCaches(); 
+ 
   // Gets the current maximum cache size per CPU cache. 
   static int32_t GetMaxPerCpuCacheSize(); 
   // Sets the maximum cache size per CPU cache.  This is a per-core limit. 
--- contrib/libs/tcmalloc/tcmalloc/static_vars.h	(5096009d22199137186c9a972bc88409d8ebd513) 
+++ contrib/libs/tcmalloc/tcmalloc/static_vars.h	(ab4069ebdd376db4d32c29e1a2414565ec849249) 
@@ -122,6 +122,7 @@ class Static { 
     return cpu_cache_active_; 
   } 
   static void ActivateCPUCache() { cpu_cache_active_ = true; } 
+  static void DeactivateCPUCache() { cpu_cache_active_ = false; } 
  
   static bool ABSL_ATTRIBUTE_ALWAYS_INLINE IsOnFastPath() { 
     return 
--- contrib/libs/tcmalloc/tcmalloc/tcmalloc.cc	(5096009d22199137186c9a972bc88409d8ebd513) 
+++ contrib/libs/tcmalloc/tcmalloc/tcmalloc.cc	(ab4069ebdd376db4d32c29e1a2414565ec849249) 
@@ -2210,14 +2210,7 @@ extern "C" void* TCMallocInternalNewArray(size_t size) 
     TCMALLOC_ALIAS(TCMallocInternalNew); 
 #else 
 { 
-  void* p = fast_alloc(CppPolicy().WithoutHooks(), size); 
-  // We keep this next instruction out of fast_alloc for a reason: when 
-  // it's in, and new just calls fast_alloc, the optimizer may fold the 
-  // new call into fast_alloc, which messes up our whole section-based 
-  // stacktracing (see ABSL_ATTRIBUTE_SECTION, above).  This ensures fast_alloc 
-  // isn't the last thing this fn calls, and prevents the folding. 
-  MallocHook::InvokeNewHook(p, size); 
-  return p; 
+  return fast_alloc(CppPolicy().WithoutHooks(), size); 
 } 
 #endif  // TCMALLOC_ALIAS