yandex.patch 4.2 KB

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