aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/lfalloc/dbg_info
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:17 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:17 +0300
commitd3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch)
treedd4bd3ca0f36b817e96812825ffaf10d645803f2 /library/cpp/lfalloc/dbg_info
parent72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff)
downloadydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/lfalloc/dbg_info')
-rw-r--r--library/cpp/lfalloc/dbg_info/dbg_info.cpp180
-rw-r--r--library/cpp/lfalloc/dbg_info/dbg_info.h128
2 files changed, 154 insertions, 154 deletions
diff --git a/library/cpp/lfalloc/dbg_info/dbg_info.cpp b/library/cpp/lfalloc/dbg_info/dbg_info.cpp
index efdd70a49f..1fb9f7ad93 100644
--- a/library/cpp/lfalloc/dbg_info/dbg_info.cpp
+++ b/library/cpp/lfalloc/dbg_info/dbg_info.cpp
@@ -3,122 +3,122 @@
#include <library/cpp/malloc/api/malloc.h>
namespace NAllocDbg {
- ////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////
- using TGetAllocationCounter = i64(int counter);
+ using TGetAllocationCounter = i64(int counter);
- using TSetThreadAllocTag = int(int tag);
- using TGetPerTagAllocInfo = void(
- bool flushPerThreadCounters,
- TPerTagAllocInfo* info,
- int& maxTag,
- int& numSizes);
+ using TSetThreadAllocTag = int(int tag);
+ using TGetPerTagAllocInfo = void(
+ bool flushPerThreadCounters,
+ TPerTagAllocInfo* info,
+ int& maxTag,
+ int& numSizes);
- using TSetProfileCurrentThread = bool(bool newVal);
+ using TSetProfileCurrentThread = bool(bool newVal);
using TSetProfileAllThreads = bool(bool newVal);
- using TSetAllocationSamplingEnabled = bool(bool newVal);
+ using TSetAllocationSamplingEnabled = bool(bool newVal);
- using TSetAllocationSampleRate = size_t(size_t newVal);
- using TSetAllocationSampleMaxSize = size_t(size_t newVal);
+ using TSetAllocationSampleRate = size_t(size_t newVal);
+ using TSetAllocationSampleMaxSize = size_t(size_t newVal);
- using TSetAllocationCallback = TAllocationCallback*(TAllocationCallback* newVal);
- using TSetDeallocationCallback = TDeallocationCallback*(TDeallocationCallback* newVal);
+ using TSetAllocationCallback = TAllocationCallback*(TAllocationCallback* newVal);
+ using TSetDeallocationCallback = TDeallocationCallback*(TDeallocationCallback* newVal);
- struct TAllocFn {
- TGetAllocationCounter* GetAllocationCounterFast = nullptr;
- TGetAllocationCounter* GetAllocationCounterFull = nullptr;
+ struct TAllocFn {
+ TGetAllocationCounter* GetAllocationCounterFast = nullptr;
+ TGetAllocationCounter* GetAllocationCounterFull = nullptr;
- TSetThreadAllocTag* SetThreadAllocTag = nullptr;
- TGetPerTagAllocInfo* GetPerTagAllocInfo = nullptr;
+ TSetThreadAllocTag* SetThreadAllocTag = nullptr;
+ TGetPerTagAllocInfo* GetPerTagAllocInfo = nullptr;
- TSetProfileCurrentThread* SetProfileCurrentThread = nullptr;
+ TSetProfileCurrentThread* SetProfileCurrentThread = nullptr;
TSetProfileAllThreads* SetProfileAllThreads = nullptr;
- TSetAllocationSamplingEnabled* SetAllocationSamplingEnabled = nullptr;
+ TSetAllocationSamplingEnabled* SetAllocationSamplingEnabled = nullptr;
- TSetAllocationSampleRate* SetAllocationSampleRate = nullptr;
- TSetAllocationSampleMaxSize* SetAllocationSampleMaxSize = nullptr;
+ TSetAllocationSampleRate* SetAllocationSampleRate = nullptr;
+ TSetAllocationSampleMaxSize* SetAllocationSampleMaxSize = nullptr;
- TSetAllocationCallback* SetAllocationCallback = nullptr;
- TSetDeallocationCallback* SetDeallocationCallback = nullptr;
+ TSetAllocationCallback* SetAllocationCallback = nullptr;
+ TSetDeallocationCallback* SetDeallocationCallback = nullptr;
- TAllocFn() {
- auto mallocInfo = NMalloc::MallocInfo();
+ TAllocFn() {
+ auto mallocInfo = NMalloc::MallocInfo();
- GetAllocationCounterFast = (TGetAllocationCounter*)mallocInfo.GetParam("GetLFAllocCounterFast");
- GetAllocationCounterFull = (TGetAllocationCounter*)mallocInfo.GetParam("GetLFAllocCounterFull");
+ GetAllocationCounterFast = (TGetAllocationCounter*)mallocInfo.GetParam("GetLFAllocCounterFast");
+ GetAllocationCounterFull = (TGetAllocationCounter*)mallocInfo.GetParam("GetLFAllocCounterFull");
- SetThreadAllocTag = (TSetThreadAllocTag*)mallocInfo.GetParam("SetThreadAllocTag");
- GetPerTagAllocInfo = (TGetPerTagAllocInfo*)mallocInfo.GetParam("GetPerTagAllocInfo");
+ SetThreadAllocTag = (TSetThreadAllocTag*)mallocInfo.GetParam("SetThreadAllocTag");
+ GetPerTagAllocInfo = (TGetPerTagAllocInfo*)mallocInfo.GetParam("GetPerTagAllocInfo");
- SetProfileCurrentThread = (TSetProfileCurrentThread*)mallocInfo.GetParam("SetProfileCurrentThread");
+ SetProfileCurrentThread = (TSetProfileCurrentThread*)mallocInfo.GetParam("SetProfileCurrentThread");
SetProfileAllThreads = (TSetProfileAllThreads*)mallocInfo.GetParam("SetProfileAllThreads");
- SetAllocationSamplingEnabled = (TSetAllocationSamplingEnabled*)mallocInfo.GetParam("SetAllocationSamplingEnabled");
-
- SetAllocationSampleRate = (TSetAllocationSampleRate*)mallocInfo.GetParam("SetAllocationSampleRate");
- SetAllocationSampleMaxSize = (TSetAllocationSampleMaxSize*)mallocInfo.GetParam("SetAllocationSampleMaxSize");
-
- SetAllocationCallback = (TSetAllocationCallback*)mallocInfo.GetParam("SetAllocationCallback");
- SetDeallocationCallback = (TSetDeallocationCallback*)mallocInfo.GetParam("SetDeallocationCallback");
- }
- };
-
- ////////////////////////////////////////////////////////////////////////////////
-
- static TAllocFn AllocFn;
-
- i64 GetAllocationCounterFast(ELFAllocCounter counter) {
- return AllocFn.GetAllocationCounterFast ? AllocFn.GetAllocationCounterFast(counter) : 0;
- }
-
- i64 GetAllocationCounterFull(ELFAllocCounter counter) {
- return AllocFn.GetAllocationCounterFull ? AllocFn.GetAllocationCounterFull(counter) : 0;
- }
-
- int SetThreadAllocTag(int tag) {
- return AllocFn.SetThreadAllocTag ? AllocFn.SetThreadAllocTag(tag) : 0;
- }
-
- TArrayPtr<TPerTagAllocInfo> GetPerTagAllocInfo(
- bool flushPerThreadCounters,
- int& maxTag,
- int& numSizes) {
- if (AllocFn.GetPerTagAllocInfo) {
- AllocFn.GetPerTagAllocInfo(flushPerThreadCounters, nullptr, maxTag, numSizes);
- TArrayPtr<TPerTagAllocInfo> info = new TPerTagAllocInfo[maxTag * numSizes];
- AllocFn.GetPerTagAllocInfo(flushPerThreadCounters, info.Get(), maxTag, numSizes);
- return info;
- }
- maxTag = 0;
- numSizes = 0;
- return nullptr;
- }
-
- bool SetProfileCurrentThread(bool newVal) {
- return AllocFn.SetProfileCurrentThread ? AllocFn.SetProfileCurrentThread(newVal) : false;
+ SetAllocationSamplingEnabled = (TSetAllocationSamplingEnabled*)mallocInfo.GetParam("SetAllocationSamplingEnabled");
+
+ SetAllocationSampleRate = (TSetAllocationSampleRate*)mallocInfo.GetParam("SetAllocationSampleRate");
+ SetAllocationSampleMaxSize = (TSetAllocationSampleMaxSize*)mallocInfo.GetParam("SetAllocationSampleMaxSize");
+
+ SetAllocationCallback = (TSetAllocationCallback*)mallocInfo.GetParam("SetAllocationCallback");
+ SetDeallocationCallback = (TSetDeallocationCallback*)mallocInfo.GetParam("SetDeallocationCallback");
+ }
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////
+
+ static TAllocFn AllocFn;
+
+ i64 GetAllocationCounterFast(ELFAllocCounter counter) {
+ return AllocFn.GetAllocationCounterFast ? AllocFn.GetAllocationCounterFast(counter) : 0;
+ }
+
+ i64 GetAllocationCounterFull(ELFAllocCounter counter) {
+ return AllocFn.GetAllocationCounterFull ? AllocFn.GetAllocationCounterFull(counter) : 0;
+ }
+
+ int SetThreadAllocTag(int tag) {
+ return AllocFn.SetThreadAllocTag ? AllocFn.SetThreadAllocTag(tag) : 0;
+ }
+
+ TArrayPtr<TPerTagAllocInfo> GetPerTagAllocInfo(
+ bool flushPerThreadCounters,
+ int& maxTag,
+ int& numSizes) {
+ if (AllocFn.GetPerTagAllocInfo) {
+ AllocFn.GetPerTagAllocInfo(flushPerThreadCounters, nullptr, maxTag, numSizes);
+ TArrayPtr<TPerTagAllocInfo> info = new TPerTagAllocInfo[maxTag * numSizes];
+ AllocFn.GetPerTagAllocInfo(flushPerThreadCounters, info.Get(), maxTag, numSizes);
+ return info;
+ }
+ maxTag = 0;
+ numSizes = 0;
+ return nullptr;
+ }
+
+ bool SetProfileCurrentThread(bool newVal) {
+ return AllocFn.SetProfileCurrentThread ? AllocFn.SetProfileCurrentThread(newVal) : false;
}
bool SetProfileAllThreads(bool newVal) {
return AllocFn.SetProfileAllThreads ? AllocFn.SetProfileAllThreads(newVal) : false;
}
- bool SetAllocationSamplingEnabled(bool newVal) {
- return AllocFn.SetAllocationSamplingEnabled ? AllocFn.SetAllocationSamplingEnabled(newVal) : false;
- }
+ bool SetAllocationSamplingEnabled(bool newVal) {
+ return AllocFn.SetAllocationSamplingEnabled ? AllocFn.SetAllocationSamplingEnabled(newVal) : false;
+ }
- size_t SetAllocationSampleRate(size_t newVal) {
- return AllocFn.SetAllocationSampleRate ? AllocFn.SetAllocationSampleRate(newVal) : 0;
- }
+ size_t SetAllocationSampleRate(size_t newVal) {
+ return AllocFn.SetAllocationSampleRate ? AllocFn.SetAllocationSampleRate(newVal) : 0;
+ }
- size_t SetAllocationSampleMaxSize(size_t newVal) {
- return AllocFn.SetAllocationSampleMaxSize ? AllocFn.SetAllocationSampleMaxSize(newVal) : 0;
- }
+ size_t SetAllocationSampleMaxSize(size_t newVal) {
+ return AllocFn.SetAllocationSampleMaxSize ? AllocFn.SetAllocationSampleMaxSize(newVal) : 0;
+ }
- TAllocationCallback* SetAllocationCallback(TAllocationCallback* newVal) {
- return AllocFn.SetAllocationCallback ? AllocFn.SetAllocationCallback(newVal) : nullptr;
- }
+ TAllocationCallback* SetAllocationCallback(TAllocationCallback* newVal) {
+ return AllocFn.SetAllocationCallback ? AllocFn.SetAllocationCallback(newVal) : nullptr;
+ }
- TDeallocationCallback* SetDeallocationCallback(TDeallocationCallback* newVal) {
- return AllocFn.SetDeallocationCallback ? AllocFn.SetDeallocationCallback(newVal) : nullptr;
- }
+ TDeallocationCallback* SetDeallocationCallback(TDeallocationCallback* newVal) {
+ return AllocFn.SetDeallocationCallback ? AllocFn.SetDeallocationCallback(newVal) : nullptr;
+ }
}
diff --git a/library/cpp/lfalloc/dbg_info/dbg_info.h b/library/cpp/lfalloc/dbg_info/dbg_info.h
index 0e9bbad869..071562a81a 100644
--- a/library/cpp/lfalloc/dbg_info/dbg_info.h
+++ b/library/cpp/lfalloc/dbg_info/dbg_info.h
@@ -4,74 +4,74 @@
#include <util/system/types.h>
namespace NAllocDbg {
- ////////////////////////////////////////////////////////////////////////////////
- // Allocation statistics
-
- enum ELFAllocCounter {
- CT_USER_ALLOC, // accumulated size requested by user code
- CT_MMAP, // accumulated mmapped size
- CT_MMAP_CNT, // number of mmapped regions
- CT_MUNMAP, // accumulated unmmapped size
- CT_MUNMAP_CNT, // number of munmaped regions
- CT_SYSTEM_ALLOC, // accumulated allocated size for internal lfalloc needs
- CT_SYSTEM_FREE, // accumulated deallocated size for internal lfalloc needs
- CT_SMALL_ALLOC, // accumulated allocated size for fixed-size blocks
- CT_SMALL_FREE, // accumulated deallocated size for fixed-size blocks
- CT_LARGE_ALLOC, // accumulated allocated size for large blocks
- CT_LARGE_FREE, // accumulated deallocated size for large blocks
- CT_SLOW_ALLOC_CNT, // number of slow (not LF) allocations
- CT_DEGRAGMENT_CNT, // number of memory defragmentations
- CT_MAX
- };
-
- i64 GetAllocationCounterFast(ELFAllocCounter counter);
- i64 GetAllocationCounterFull(ELFAllocCounter counter);
-
- ////////////////////////////////////////////////////////////////////////////////
- // Allocation statistics could be tracked on per-tag basis
-
- int SetThreadAllocTag(int tag);
-
- class TScopedTag {
- private:
- int PrevTag;
-
- public:
- explicit TScopedTag(int tag) {
- PrevTag = SetThreadAllocTag(tag);
- }
-
- ~TScopedTag() {
- SetThreadAllocTag(PrevTag);
- }
- };
-
- struct TPerTagAllocInfo {
- ssize_t Count;
- ssize_t Size;
- };
-
- TArrayPtr<TPerTagAllocInfo> GetPerTagAllocInfo(
- bool flushPerThreadCounters,
- int& maxTag,
- int& numSizes);
-
- ////////////////////////////////////////////////////////////////////////////////
- // Allocation sampling could be used to collect detailed information
-
- bool SetProfileCurrentThread(bool newVal);
+ ////////////////////////////////////////////////////////////////////////////////
+ // Allocation statistics
+
+ enum ELFAllocCounter {
+ CT_USER_ALLOC, // accumulated size requested by user code
+ CT_MMAP, // accumulated mmapped size
+ CT_MMAP_CNT, // number of mmapped regions
+ CT_MUNMAP, // accumulated unmmapped size
+ CT_MUNMAP_CNT, // number of munmaped regions
+ CT_SYSTEM_ALLOC, // accumulated allocated size for internal lfalloc needs
+ CT_SYSTEM_FREE, // accumulated deallocated size for internal lfalloc needs
+ CT_SMALL_ALLOC, // accumulated allocated size for fixed-size blocks
+ CT_SMALL_FREE, // accumulated deallocated size for fixed-size blocks
+ CT_LARGE_ALLOC, // accumulated allocated size for large blocks
+ CT_LARGE_FREE, // accumulated deallocated size for large blocks
+ CT_SLOW_ALLOC_CNT, // number of slow (not LF) allocations
+ CT_DEGRAGMENT_CNT, // number of memory defragmentations
+ CT_MAX
+ };
+
+ i64 GetAllocationCounterFast(ELFAllocCounter counter);
+ i64 GetAllocationCounterFull(ELFAllocCounter counter);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Allocation statistics could be tracked on per-tag basis
+
+ int SetThreadAllocTag(int tag);
+
+ class TScopedTag {
+ private:
+ int PrevTag;
+
+ public:
+ explicit TScopedTag(int tag) {
+ PrevTag = SetThreadAllocTag(tag);
+ }
+
+ ~TScopedTag() {
+ SetThreadAllocTag(PrevTag);
+ }
+ };
+
+ struct TPerTagAllocInfo {
+ ssize_t Count;
+ ssize_t Size;
+ };
+
+ TArrayPtr<TPerTagAllocInfo> GetPerTagAllocInfo(
+ bool flushPerThreadCounters,
+ int& maxTag,
+ int& numSizes);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Allocation sampling could be used to collect detailed information
+
+ bool SetProfileCurrentThread(bool newVal);
bool SetProfileAllThreads(bool newVal);
- bool SetAllocationSamplingEnabled(bool newVal);
+ bool SetAllocationSamplingEnabled(bool newVal);
- size_t SetAllocationSampleRate(size_t newVal);
- size_t SetAllocationSampleMaxSize(size_t newVal);
+ size_t SetAllocationSampleRate(size_t newVal);
+ size_t SetAllocationSampleMaxSize(size_t newVal);
#define DBG_ALLOC_INVALID_COOKIE (-1)
- using TAllocationCallback = int(int tag, size_t size, int sizeIdx);
- using TDeallocationCallback = void(int cookie, int tag, size_t size, int sizeIdx);
+ using TAllocationCallback = int(int tag, size_t size, int sizeIdx);
+ using TDeallocationCallback = void(int cookie, int tag, size_t size, int sizeIdx);
- TAllocationCallback* SetAllocationCallback(TAllocationCallback* newVal);
- TDeallocationCallback* SetDeallocationCallback(TDeallocationCallback* newVal);
+ TAllocationCallback* SetAllocationCallback(TAllocationCallback* newVal);
+ TDeallocationCallback* SetDeallocationCallback(TDeallocationCallback* newVal);
-}
+}