aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/lfalloc/alloc_profiler/stackcollect.h
diff options
context:
space:
mode:
authorAlexander Gololobov <davenger@yandex-team.com>2022-02-10 16:47:38 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:38 +0300
commitfccc62e9bfdce9be2fe7e0f23479da3a5512211a (patch)
treec0748b5dcbade83af788c0abfa89c0383d6b779c /library/cpp/lfalloc/alloc_profiler/stackcollect.h
parent39608cdb86363c75ce55b2b9a69841c3b71f22cf (diff)
downloadydb-fccc62e9bfdce9be2fe7e0f23479da3a5512211a.tar.gz
Restoring authorship annotation for Alexander Gololobov <davenger@yandex-team.com>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/lfalloc/alloc_profiler/stackcollect.h')
-rw-r--r--library/cpp/lfalloc/alloc_profiler/stackcollect.h162
1 files changed, 81 insertions, 81 deletions
diff --git a/library/cpp/lfalloc/alloc_profiler/stackcollect.h b/library/cpp/lfalloc/alloc_profiler/stackcollect.h
index 7c10cd2ffd..80715ed7cb 100644
--- a/library/cpp/lfalloc/alloc_profiler/stackcollect.h
+++ b/library/cpp/lfalloc/alloc_profiler/stackcollect.h
@@ -2,89 +2,89 @@
#include <library/cpp/containers/stack_vector/stack_vec.h>
#include <library/cpp/cache/cache.h>
-
+
#include <util/generic/noncopyable.h>
#include <util/generic/ptr.h>
#include <util/stream/output.h>
-namespace NAllocProfiler {
-
-struct TStats {
- intptr_t Allocs = 0;
- intptr_t Frees = 0;
- intptr_t CurrentSize = 0;
-
- void Clear()
- {
- Allocs = 0;
- Frees = 0;
- CurrentSize = 0;
- }
-
- void Alloc(size_t size)
- {
- AtomicIncrement(Allocs);
- AtomicAdd(CurrentSize, size);
- }
-
- void Free(size_t size)
- {
- AtomicIncrement(Frees);
- AtomicSub(CurrentSize, size);
- }
-};
-
-struct TAllocationInfo {
- int Tag;
- TStats Stats;
- TStackVec<void*, 64> Stack;
-
- void Clear() {
- Tag = 0;
- Stats.Clear();
- Stack.clear();
- }
-};
-
-
-class IAllocationStatsDumper {
-public:
- virtual ~IAllocationStatsDumper() = default;
-
- // Total stats
- virtual void DumpTotal(const TStats& total) = 0;
-
- // Stats for individual stack
- virtual void DumpEntry(const TAllocationInfo& allocInfo) = 0;
-
- // App-specific tag printer
- virtual TString FormatTag(int tag);
-
- // Size printer (e.g. "10KB", "100MB", "over 9000")
- virtual TString FormatSize(intptr_t sz);
-};
-
-// Default implementation
-class TAllocationStatsDumper: public IAllocationStatsDumper {
-public:
- explicit TAllocationStatsDumper(IOutputStream& out);
- void DumpTotal(const TStats& total) override;
- void DumpEntry(const TAllocationInfo& allocInfo) override;
-
-private:
- void FormatBackTrace(void* const* stack, size_t sz);
-
-private:
- struct TSymbol {
- const void* Address;
- TString Name;
- };
-
- size_t PrintedCount;
- IOutputStream& Out;
- TLFUCache<void*, TSymbol> SymbolCache;
-};
-
+namespace NAllocProfiler {
+
+struct TStats {
+ intptr_t Allocs = 0;
+ intptr_t Frees = 0;
+ intptr_t CurrentSize = 0;
+
+ void Clear()
+ {
+ Allocs = 0;
+ Frees = 0;
+ CurrentSize = 0;
+ }
+
+ void Alloc(size_t size)
+ {
+ AtomicIncrement(Allocs);
+ AtomicAdd(CurrentSize, size);
+ }
+
+ void Free(size_t size)
+ {
+ AtomicIncrement(Frees);
+ AtomicSub(CurrentSize, size);
+ }
+};
+
+struct TAllocationInfo {
+ int Tag;
+ TStats Stats;
+ TStackVec<void*, 64> Stack;
+
+ void Clear() {
+ Tag = 0;
+ Stats.Clear();
+ Stack.clear();
+ }
+};
+
+
+class IAllocationStatsDumper {
+public:
+ virtual ~IAllocationStatsDumper() = default;
+
+ // Total stats
+ virtual void DumpTotal(const TStats& total) = 0;
+
+ // Stats for individual stack
+ virtual void DumpEntry(const TAllocationInfo& allocInfo) = 0;
+
+ // App-specific tag printer
+ virtual TString FormatTag(int tag);
+
+ // Size printer (e.g. "10KB", "100MB", "over 9000")
+ virtual TString FormatSize(intptr_t sz);
+};
+
+// Default implementation
+class TAllocationStatsDumper: public IAllocationStatsDumper {
+public:
+ explicit TAllocationStatsDumper(IOutputStream& out);
+ void DumpTotal(const TStats& total) override;
+ void DumpEntry(const TAllocationInfo& allocInfo) override;
+
+private:
+ void FormatBackTrace(void* const* stack, size_t sz);
+
+private:
+ struct TSymbol {
+ const void* Address;
+ TString Name;
+ };
+
+ size_t PrintedCount;
+ IOutputStream& Out;
+ TLFUCache<void*, TSymbol> SymbolCache;
+};
+
////////////////////////////////////////////////////////////////////////////////
class TAllocationStackCollector: private TNonCopyable {
@@ -101,7 +101,7 @@ public:
void Clear();
- void Dump(int count, IAllocationStatsDumper& out) const;
+ void Dump(int count, IAllocationStatsDumper& out) const;
};
-} // namespace NAllocProfiler
+} // namespace NAllocProfiler