diff options
author | monster <monster@yandex-team.ru> | 2022-02-10 16:47:19 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:19 +0300 |
commit | b23c1d7a8015c2006a148fd93b84cdeb0aee17a3 (patch) | |
tree | 9814fbd1c3effac9b8377c5d604b367b14e2db55 /library/cpp/actors/prof | |
parent | dd76ae1f6213d065375ab296699f764faafbe5bd (diff) | |
download | ydb-b23c1d7a8015c2006a148fd93b84cdeb0aee17a3.tar.gz |
Restoring authorship annotation for <monster@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/actors/prof')
-rw-r--r-- | library/cpp/actors/prof/tag.cpp | 44 | ||||
-rw-r--r-- | library/cpp/actors/prof/tag.h | 26 | ||||
-rw-r--r-- | library/cpp/actors/prof/tcmalloc.cpp | 64 | ||||
-rw-r--r-- | library/cpp/actors/prof/tcmalloc.h | 18 | ||||
-rw-r--r-- | library/cpp/actors/prof/tcmalloc_null.cpp | 20 | ||||
-rw-r--r-- | library/cpp/actors/prof/ya.make | 14 |
6 files changed, 93 insertions, 93 deletions
diff --git a/library/cpp/actors/prof/tag.cpp b/library/cpp/actors/prof/tag.cpp index caf516812b..9ccf03e1a9 100644 --- a/library/cpp/actors/prof/tag.cpp +++ b/library/cpp/actors/prof/tag.cpp @@ -1,9 +1,9 @@ #include "tag.h" -#include "tcmalloc.h" +#include "tcmalloc.h" #include <library/cpp/charset/ci_string.h> #include <library/cpp/containers/atomizer/atomizer.h> -#include <library/cpp/malloc/api/malloc.h> +#include <library/cpp/malloc/api/malloc.h> #if defined(PROFILE_MEMORY_ALLOCATIONS) #include <library/cpp/lfalloc/dbg_info/dbg_info.h> @@ -76,11 +76,11 @@ namespace NProfiling { return TStringAtoms::Instance().GetTagsCount(); } - static ui32 SetThreadAllocTag_Default(ui32 tag) { - Y_UNUSED(tag); - return 0; - } - + static ui32 SetThreadAllocTag_Default(ui32 tag) { + Y_UNUSED(tag); + return 0; + } + #if defined(PROFILE_MEMORY_ALLOCATIONS) static ui32 SetThreadAllocTag_YT(ui32 tag) { auto prev = NYT::NYTAlloc::GetCurrentMemoryTag(); @@ -96,24 +96,24 @@ namespace NProfiling { return (TSetThreadAllocTag*)NAllocDbg::SetThreadAllocTag; } else if (name.StartsWith("yt")) { return SetThreadAllocTag_YT; - } else if (name.StartsWith("tc")) { - return SetTCMallocThreadAllocTag; + } else if (name.StartsWith("tc")) { + return SetTCMallocThreadAllocTag; + } else { + return SetThreadAllocTag_Default; + } + } +#else + static TSetThreadAllocTag* SetThreadAllocTagFn() { + const auto& info = NMalloc::MallocInfo(); + + TStringBuf name(info.Name); + if (name.StartsWith("tc")) { + return SetTCMallocThreadAllocTag; } else { return SetThreadAllocTag_Default; } } -#else - static TSetThreadAllocTag* SetThreadAllocTagFn() { - const auto& info = NMalloc::MallocInfo(); - - TStringBuf name(info.Name); - if (name.StartsWith("tc")) { - return SetTCMallocThreadAllocTag; - } else { - return SetThreadAllocTag_Default; - } - } -#endif - +#endif + TSetThreadAllocTag* SetThreadAllocTag = SetThreadAllocTagFn(); } diff --git a/library/cpp/actors/prof/tag.h b/library/cpp/actors/prof/tag.h index 81815b7289..357e264a22 100644 --- a/library/cpp/actors/prof/tag.h +++ b/library/cpp/actors/prof/tag.h @@ -5,7 +5,7 @@ /* Common registry for tagging memory profiler. Register a new tag with MakeTag using a unique string. - Use registered tags with SetThreadAllocTag function in allocator API. + Use registered tags with SetThreadAllocTag function in allocator API. */ namespace NProfiling { @@ -22,43 +22,43 @@ namespace NProfiling { class TMemoryTagScope { public: - explicit TMemoryTagScope(ui32 tag) + explicit TMemoryTagScope(ui32 tag) : RestoreTag(SetThreadAllocTag(tag)) { } - explicit TMemoryTagScope(const char* tagName) { + explicit TMemoryTagScope(const char* tagName) { ui32 newTag = MakeTag(tagName); RestoreTag = SetThreadAllocTag(newTag); } TMemoryTagScope(TMemoryTagScope&& move) : RestoreTag(move.RestoreTag) - , Released(move.Released) + , Released(move.Released) { - move.Released = true; + move.Released = true; } TMemoryTagScope& operator=(TMemoryTagScope&& move) { RestoreTag = move.RestoreTag; - Released = move.Released; - move.Released = true; + Released = move.Released; + move.Released = true; return *this; } - static void Reset(ui32 tag) { + static void Reset(ui32 tag) { SetThreadAllocTag(tag); } void Release() { - if (!Released) { + if (!Released) { SetThreadAllocTag(RestoreTag); - Released = true; + Released = true; } } ~TMemoryTagScope() { - if (!Released) { + if (!Released) { SetThreadAllocTag(RestoreTag); } } @@ -67,7 +67,7 @@ namespace NProfiling { TMemoryTagScope(const TMemoryTagScope&) = delete; void operator=(const TMemoryTagScope&) = delete; - ui32 RestoreTag = 0; - bool Released = false; + ui32 RestoreTag = 0; + bool Released = false; }; } diff --git a/library/cpp/actors/prof/tcmalloc.cpp b/library/cpp/actors/prof/tcmalloc.cpp index 331181e80b..3d4f203dbb 100644 --- a/library/cpp/actors/prof/tcmalloc.cpp +++ b/library/cpp/actors/prof/tcmalloc.cpp @@ -1,32 +1,32 @@ -#include "tcmalloc.h" - -#include <contrib/libs/tcmalloc/tcmalloc/malloc_extension.h> - -namespace NProfiling { - -static thread_local ui32 AllocationTag = 0; - -static struct TInitTCMallocCallbacks { - static void* CreateTag() { - return reinterpret_cast<void*>(AllocationTag); - } - static void* CopyTag(void* tag) { - return tag; - } - static void DestroyTag(void* tag) { - Y_UNUSED(tag); - } - - TInitTCMallocCallbacks() { - tcmalloc::MallocExtension::SetSampleUserDataCallbacks( - CreateTag, CopyTag, DestroyTag); - } -} InitTCMallocCallbacks; - -ui32 SetTCMallocThreadAllocTag(ui32 tag) { - ui32 prev = AllocationTag; - AllocationTag = tag; - return prev; -} - -} +#include "tcmalloc.h" + +#include <contrib/libs/tcmalloc/tcmalloc/malloc_extension.h> + +namespace NProfiling { + +static thread_local ui32 AllocationTag = 0; + +static struct TInitTCMallocCallbacks { + static void* CreateTag() { + return reinterpret_cast<void*>(AllocationTag); + } + static void* CopyTag(void* tag) { + return tag; + } + static void DestroyTag(void* tag) { + Y_UNUSED(tag); + } + + TInitTCMallocCallbacks() { + tcmalloc::MallocExtension::SetSampleUserDataCallbacks( + CreateTag, CopyTag, DestroyTag); + } +} InitTCMallocCallbacks; + +ui32 SetTCMallocThreadAllocTag(ui32 tag) { + ui32 prev = AllocationTag; + AllocationTag = tag; + return prev; +} + +} diff --git a/library/cpp/actors/prof/tcmalloc.h b/library/cpp/actors/prof/tcmalloc.h index 0da31a2024..659fb4eaf3 100644 --- a/library/cpp/actors/prof/tcmalloc.h +++ b/library/cpp/actors/prof/tcmalloc.h @@ -1,9 +1,9 @@ -#pragma once - -#include <util/generic/fwd.h> - -namespace NProfiling { - -ui32 SetTCMallocThreadAllocTag(ui32 tag); - -} +#pragma once + +#include <util/generic/fwd.h> + +namespace NProfiling { + +ui32 SetTCMallocThreadAllocTag(ui32 tag); + +} diff --git a/library/cpp/actors/prof/tcmalloc_null.cpp b/library/cpp/actors/prof/tcmalloc_null.cpp index 26e6f61bb9..75c0013154 100644 --- a/library/cpp/actors/prof/tcmalloc_null.cpp +++ b/library/cpp/actors/prof/tcmalloc_null.cpp @@ -1,10 +1,10 @@ -#include "tcmalloc.h" - -namespace NProfiling { - -ui32 SetTCMallocThreadAllocTag(ui32 tag) { - Y_UNUSED(tag); - return 0; -} - -} +#include "tcmalloc.h" + +namespace NProfiling { + +ui32 SetTCMallocThreadAllocTag(ui32 tag) { + Y_UNUSED(tag); + return 0; +} + +} diff --git a/library/cpp/actors/prof/ya.make b/library/cpp/actors/prof/ya.make index d20ee798c4..b5e2497563 100644 --- a/library/cpp/actors/prof/ya.make +++ b/library/cpp/actors/prof/ya.make @@ -23,11 +23,11 @@ IF (PROFILE_MEMORY_ALLOCATIONS) ) ENDIF() -IF(ALLOCATOR == "TCMALLOC_256K") - SRCS(tcmalloc.cpp) - PEERDIR(contrib/libs/tcmalloc) -ELSE() - SRCS(tcmalloc_null.cpp) -ENDIF() - +IF(ALLOCATOR == "TCMALLOC_256K") + SRCS(tcmalloc.cpp) + PEERDIR(contrib/libs/tcmalloc) +ELSE() + SRCS(tcmalloc_null.cpp) +ENDIF() + END() |