diff --git a/ydb/core/mon_alloc/monitor.cpp b/ydb/core/mon_alloc/monitor.cpp index 2605190982fb..9f7a1fad901e 100644 --- a/ydb/core/mon_alloc/monitor.cpp +++ b/ydb/core/mon_alloc/monitor.cpp @@ -14,8 +14,6 @@ #include #include #include -#include -#include #include #include @@ -261,117 +259,6 @@ namespace NKikimr { } }; - class TYtAllocMonitor: public IAllocMonitor { - private: - TDynamicCountersPtr CounterGroup; - THashMap PerTag; - - public: - TYtAllocMonitor(TDynamicCountersPtr group) { - CounterGroup = group->GetSubgroup("component", "ytalloc_profile"); - } - - void Update(TDuration interval) override { - Y_UNUSED(interval); -#ifdef PROFILE_MEMORY_ALLOCATIONS - using namespace NYT; - - size_t maxTag = NProfiling::GetTagsCount(); - - TVector tags(maxTag); - std::iota(tags.begin(), tags.end(), 1); - - TVector usages(maxTag); - GetMemoryUsageForTags(tags.data(), tags.size(), usages.data()); - - for (size_t tag = 0; tag < maxTag; ++tag) { - if (!usages[tag]) { - continue; - } - - auto tagName = NProfiling::GetTag(tag); - if (tagName == nullptr) { - tagName = "__DEFAULT__"; - } - - TDynamicCounterPtr& perTag = PerTag[tagName]; - if (!perTag) { - perTag = CounterGroup->GetCounter(tagName); - } - - *perTag = usages[tag]; - } -#endif - } - - void Dump(IOutputStream& out, const TString& relPath) override { - Y_UNUSED(relPath); -#ifdef PROFILE_MEMORY_ALLOCATIONS - using namespace NYT; - - size_t maxTag = NProfiling::GetTagsCount(); - - TVector tags(maxTag); - std::iota(tags.begin(), tags.end(), 1); - - TVector usages(maxTag); - GetMemoryUsageForTags(tags.data(), tags.size(), usages.data()); - - HTML(out) { - TAG(TH3) { - out << "YTAlloc" << Endl; - } - out << "
" << Endl; - TABLE_SORTABLE_CLASS("table") { - TABLEHEAD() { - TABLER() { - TABLEH() { - out << "Tag"; - } - TABLEH() { - out << "" - "Total Space"; - } - } - } - - TABLEBODY() { - for (size_t tag = 0; tag < maxTag; ++tag) { - if (!usages[tag]) { - continue; - } - - auto tagName = NProfiling::GetTag(tag); - if (tagName == nullptr) { - tagName = "__DEFAULT__"; - } - - TABLER() { - TABLED() { - out << tagName; - } - TABLED() { - out << usages[tag]; - } - } - } - } - } - } -#else - HTML(out) { - TAG(TH3) { - out << "YTAlloc" << Endl; - } - out << "
" << Endl; - out << "PROFILE_MEMORY_ALLOCATIONS is off" << Endl; - } -#endif - } - }; - struct TFakeAllocMonitor: public IAllocMonitor { void Update(TDuration interval) override { Y_UNUSED(interval); @@ -390,8 +277,6 @@ namespace NKikimr { std::unique_ptr monitor; if (name.StartsWith("lf")) { monitor = std::make_unique(std::move(group)); - } else if (name.StartsWith("yt")) { - monitor = std::make_unique(std::move(group)); } else if (name.StartsWith("tc")) { monitor = std::move(CreateTcMallocMonitor(std::move(group))); } diff --git a/ydb/core/mon_alloc/profiler.cpp b/ydb/core/mon_alloc/profiler.cpp index 96d80b98841d..5fbdf0155ff0 100644 --- a/ydb/core/mon_alloc/profiler.cpp +++ b/ydb/core/mon_alloc/profiler.cpp @@ -14,7 +14,6 @@ #if defined(PROFILE_MEMORY_ALLOCATIONS) #include -#include #endif #if defined(_linux_) && !defined(WITH_VALGRIND) @@ -58,105 +57,6 @@ namespace NActors { } }; - class TYtAllocProfiler: public IProfilerLogic { - public: - TYtAllocProfiler() { - Init(); - } - - void Start() override { - SetEnabled(true); - } - - void Stop(IOutputStream& out, size_t limit, bool forLog) override { - Y_UNUSED(forLog); - DumpStats(out, limit); - SetEnabled(false); - } - - private: - static int BacktraceProvider(void** frames, int maxFrames, int skipFrames) { - int count = BackTrace(frames, maxFrames); - if (count > skipFrames) { - std::copy(&frames[skipFrames], &frames[count], frames); - count -= skipFrames; - } - return count; - } - - static void Init() { - using namespace NYT::NYTAlloc; - - SetBacktraceProvider(BacktraceProvider); - SetProfilingBacktraceDepth(MaxAllocationProfilingBacktraceDepth); - - // profile every allocation of any size - SetAllocationProfilingSamplingRate(1); - SetMinProfilingBytesUsedToReport(0); - } - - static void SetEnabled(bool enabled) { - using namespace NYT::NYTAlloc; - - SetAllocationProfilingEnabled(enabled); - - for (size_t rank = 0; rank < SmallRankCount; ++rank) { - SetSmallArenaAllocationProfilingEnabled(rank, enabled); - } - - for (size_t rank = 0; rank < LargeRankCount; ++rank) { - SetLargeArenaAllocationProfilingEnabled(rank, enabled); - } - } - - static void DumpStats(IOutputStream& out, size_t limit) { - using namespace NYT::NYTAlloc; - - struct TLess { - static auto AsTupleRef(const TProfiledAllocation& a) { - return std::forward_as_tuple( - a.Counters[EBasicCounter::BytesUsed], - a.Counters[EBasicCounter::BytesAllocated], - a.Counters[EBasicCounter::BytesFreed]); - } - - bool operator()(const TProfiledAllocation& l, const TProfiledAllocation& r) { - return AsTupleRef(r) < AsTupleRef(l); - } - }; - - auto allocations = GetProfiledAllocationStatistics(); - Sort(allocations, TLess()); - - NAllocProfiler::TStats total; - for (const auto& a : allocations) { - total.Alloc(a.Counters[EBasicCounter::BytesAllocated]); - total.Free(a.Counters[EBasicCounter::BytesFreed]); - } - - TAllocDumper dumper(out); - dumper.DumpTotal(total); - - size_t printedCount = 0; - for (const auto& a : allocations) { - NAllocProfiler::TAllocationInfo allocInfo; - allocInfo.Tag = 0; // not supported - allocInfo.Stats.Allocs = a.Counters[EBasicCounter::BytesAllocated]; - allocInfo.Stats.Frees = a.Counters[EBasicCounter::BytesFreed]; - allocInfo.Stats.CurrentSize = a.Counters[EBasicCounter::BytesUsed]; - - allocInfo.Stack.resize(a.Backtrace.FrameCount); - for (int i = 0; i < a.Backtrace.FrameCount; ++i) { - allocInfo.Stack[i] = a.Backtrace.Frames[i]; - } - - dumper.DumpEntry(allocInfo); - if (++printedCount >= limit) { - break; - } - } - } - }; #endif // PROFILE_MEMORY_ALLOCATIONS #if defined(EXEC_PROFILER_ENABLED) @@ -206,8 +106,6 @@ namespace NActors { #if defined(PROFILE_MEMORY_ALLOCATIONS) if (name.StartsWith("lf")) { profiler = std::make_unique(); - } else if (name.StartsWith("yt")) { - profiler = std::make_unique(); } #endif // PROFILE_MEMORY_ALLOCATIONS diff --git a/ydb/core/mon_alloc/stats.cpp b/ydb/core/mon_alloc/stats.cpp index 3e4041c898e8..d6fd8ab51a95 100644 --- a/ydb/core/mon_alloc/stats.cpp +++ b/ydb/core/mon_alloc/stats.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include @@ -91,111 +90,6 @@ namespace NKikimr { } }; - class TYtAllocStats: public IAllocStats { - struct TTimingEventCounters { - TDynamicCounterPtr Count; - TDynamicCounterPtr Size; - }; - - private: - TDynamicCountersPtr CounterGroup; - - NYT::TEnumIndexedVector TotalAllocationCounters; - NYT::TEnumIndexedVector SmallAllocationCounters; - NYT::TEnumIndexedVector LargeAllocationCounters; - std::array, NYT::NYTAlloc::SmallRankCount> SmallArenaAllocationCounters; - std::array, NYT::NYTAlloc::LargeRankCount> LargeArenaAllocationCounters; - NYT::TEnumIndexedVector HugeAllocationCounters; - NYT::TEnumIndexedVector SystemAllocationCounters; - NYT::TEnumIndexedVector UndumpableAllocationCounters; - NYT::TEnumIndexedVector TimingEventCounters; - - public: - TYtAllocStats(TDynamicCountersPtr group) { - CounterGroup = group->GetSubgroup("component", "ytalloc"); - - InitCounters(TotalAllocationCounters, CounterGroup->GetSubgroup("category", "total")); - InitCounters(SmallAllocationCounters, CounterGroup->GetSubgroup("category", "small")); - InitCounters(LargeAllocationCounters, CounterGroup->GetSubgroup("category", "large")); - InitCounters(SmallArenaAllocationCounters, CounterGroup->GetSubgroup("category", "small_arena")); - InitCounters(LargeArenaAllocationCounters, CounterGroup->GetSubgroup("category", "large_arena")); - InitCounters(HugeAllocationCounters, CounterGroup->GetSubgroup("category", "huge")); - InitCounters(SystemAllocationCounters, CounterGroup->GetSubgroup("category", "system")); - InitCounters(UndumpableAllocationCounters, CounterGroup->GetSubgroup("category", "undumpable")); - InitCounters(TimingEventCounters, CounterGroup->GetSubgroup("category", "timing_event")); - } - - void Update() override { - UpdateCounters(TotalAllocationCounters, NYT::NYTAlloc::GetTotalAllocationCounters()); - UpdateCounters(SmallAllocationCounters, NYT::NYTAlloc::GetSmallAllocationCounters()); - UpdateCounters(LargeAllocationCounters, NYT::NYTAlloc::GetLargeAllocationCounters()); - UpdateCounters(SmallArenaAllocationCounters, NYT::NYTAlloc::GetSmallArenaAllocationCounters()); - UpdateCounters(LargeArenaAllocationCounters, NYT::NYTAlloc::GetLargeArenaAllocationCounters()); - UpdateCounters(HugeAllocationCounters, NYT::NYTAlloc::GetHugeAllocationCounters()); - UpdateCounters(SystemAllocationCounters, NYT::NYTAlloc::GetSystemAllocationCounters()); - UpdateCounters(UndumpableAllocationCounters, NYT::NYTAlloc::GetUndumpableAllocationCounters()); - UpdateCounters(TimingEventCounters, NYT::NYTAlloc::GetTimingEventCounters()); - } - - private: - template - static void InitCounters( - NYT::TEnumIndexedVector& counters, - TDynamicCountersPtr group) { - for (auto c : NYT::TEnumTraits::GetDomainValues()) { - counters[c] = group->GetCounter(NYT::TEnumTraits::ToString(c)); - } - } - - template - static void InitCounters( - std::array, N>& counters, - TDynamicCountersPtr group) { - for (size_t i = 0; i < N; ++i) { - InitCounters(counters[i], group->GetSubgroup("rank", ToString(i))); - } - } - - template - static void InitCounters( - NYT::TEnumIndexedVector& counters, - TDynamicCountersPtr group) { - for (auto c : NYT::TEnumTraits::GetDomainValues()) { - const auto& name = NYT::TEnumTraits::ToString(c); - counters[c].Count = group->GetCounter(name + "_Count"); - counters[c].Size = group->GetCounter(name + "_Size"); - } - } - - template - static void UpdateCounters( - NYT::TEnumIndexedVector& counters, - const NYT::TEnumIndexedVector& source) { - for (auto c : NYT::TEnumTraits::GetDomainValues()) { - *counters[c] = source[c]; - } - } - - template - static void UpdateCounters( - std::array, N>& counters, - const std::array, N>& source) { - for (size_t i = 0; i < N; ++i) { - UpdateCounters(counters[i], source[i]); - } - } - - template - static void UpdateCounters( - NYT::TEnumIndexedVector& counters, - const NYT::TEnumIndexedVector& source) { - for (auto c : NYT::TEnumTraits::GetDomainValues()) { - *counters[c].Count = source[c].Count; - *counters[c].Size = source[c].Size; - } - } - }; - struct TFakeAllocStats: public IAllocStats { void Update() override { } @@ -208,8 +102,6 @@ namespace NKikimr { std::unique_ptr stats; if (name.StartsWith("lf")) { stats = std::make_unique(std::move(group)); - } else if (name.StartsWith("yt")) { - stats = std::make_unique(std::move(group)); } else if (name.StartsWith("tc")) { stats = std::move(CreateTcMallocStats(std::move(group))); } diff --git a/ydb/core/mon_alloc/ya.make b/ydb/core/mon_alloc/ya.make index 63e66fd16f6f..b651024fcb3c 100644 --- a/ydb/core/mon_alloc/ya.make +++ b/ydb/core/mon_alloc/ya.make @@ -22,8 +22,6 @@ PEERDIR( library/cpp/lfalloc/dbg_info library/cpp/malloc/api library/cpp/monlib/service/pages - library/cpp/ytalloc/api - library/cpp/yt/memory ydb/core/base ydb/core/control ydb/library/services