aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/ytalloc/api
diff options
context:
space:
mode:
authorbabenko <babenko@yandex-team.com>2023-05-19 12:58:03 +0300
committerbabenko <babenko@yandex-team.com>2023-05-19 12:58:03 +0300
commit62539a50bcf9bb30844426ccfa6a49ee08bfb3fe (patch)
treeda3a0d539c0dc4b6563f156ac7e9685066ac07fa /library/cpp/ytalloc/api
parent8d9a38ae2a2758b5031dcc6c11efba25ed7cf5ea (diff)
downloadydb-62539a50bcf9bb30844426ccfa6a49ee08bfb3fe.tar.gz
Extract memory tag API to library
Diffstat (limited to 'library/cpp/ytalloc/api')
-rw-r--r--library/cpp/ytalloc/api/fallback.cpp18
-rw-r--r--library/cpp/ytalloc/api/ytalloc-inl.h29
-rw-r--r--library/cpp/ytalloc/api/ytalloc.h48
3 files changed, 0 insertions, 95 deletions
diff --git a/library/cpp/ytalloc/api/fallback.cpp b/library/cpp/ytalloc/api/fallback.cpp
index 5880ede439..d094cf2e93 100644
--- a/library/cpp/ytalloc/api/fallback.cpp
+++ b/library/cpp/ytalloc/api/fallback.cpp
@@ -56,24 +56,6 @@ Y_WEAK size_t GetAllocationSize(size_t size)
////////////////////////////////////////////////////////////////////////////////
-Y_WEAK TMemoryTag GetCurrentMemoryTag()
-{
- return NullMemoryTag;
-}
-
-Y_WEAK void SetCurrentMemoryTag(TMemoryTag /*tag*/)
-{ }
-
-Y_WEAK size_t GetMemoryUsageForTag(TMemoryTag /*tag*/)
-{
- return 0;
-}
-
-Y_WEAK void GetMemoryUsageForTags(const TMemoryTag* /*tags*/, size_t /*count*/, size_t* /*results*/)
-{ }
-
-////////////////////////////////////////////////////////////////////////////////
-
Y_WEAK void SetCurrentMemoryZone(EMemoryZone /*zone*/)
{ }
diff --git a/library/cpp/ytalloc/api/ytalloc-inl.h b/library/cpp/ytalloc/api/ytalloc-inl.h
index 263108423d..997b230aae 100644
--- a/library/cpp/ytalloc/api/ytalloc-inl.h
+++ b/library/cpp/ytalloc/api/ytalloc-inl.h
@@ -73,33 +73,4 @@ void* AllocateConstSize()
////////////////////////////////////////////////////////////////////////////////
-inline TMemoryTagGuard::TMemoryTagGuard()
- : Active_(false)
- , PreviousTag_(NullMemoryTag)
-{ }
-
-inline TMemoryTagGuard::TMemoryTagGuard(TMemoryTag tag)
- : Active_(true)
- , PreviousTag_(GetCurrentMemoryTag())
-{
- SetCurrentMemoryTag(tag);
-}
-
-inline TMemoryTagGuard::TMemoryTagGuard(TMemoryTagGuard&& other)
- : Active_(other.Active_)
- , PreviousTag_(other.PreviousTag_)
-{
- other.Active_ = false;
- other.PreviousTag_ = NullMemoryTag;
-}
-
-inline TMemoryTagGuard::~TMemoryTagGuard()
-{
- if (Active_) {
- SetCurrentMemoryTag(PreviousTag_);
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
} // namespace NYT::NYTAlloc
diff --git a/library/cpp/ytalloc/api/ytalloc.h b/library/cpp/ytalloc/api/ytalloc.h
index d942dde638..219814def2 100644
--- a/library/cpp/ytalloc/api/ytalloc.h
+++ b/library/cpp/ytalloc/api/ytalloc.h
@@ -71,35 +71,6 @@ size_t GetAllocationSize(const void* ptr);
size_t GetAllocationSize(size_t size);
////////////////////////////////////////////////////////////////////////////////
-// Memory tagging API
-//
-// Each allocation can be tagged with a number (from 1 to MaxMemoryTag).
-// Setting this to NullMemoryTag disables tagging.
-// Internally, YTAlloc tracks the number of bytes used by each tag.
-//
-// Tagged allocations are somewhat slower. Others (large and huge) are not affected
-// (but for these performance implications are negligible anyway).
-//
-// The current memory tag used for allocations is stored in TLS.
-
-using TMemoryTag = ui32;
-constexpr TMemoryTag NullMemoryTag = 0;
-constexpr TMemoryTag MaxMemoryTag = (1ULL << 22) - 1;
-
-// Updates the current tag value in TLS.
-void SetCurrentMemoryTag(TMemoryTag tag);
-
-// Returns the current tag value from TLS.
-TMemoryTag GetCurrentMemoryTag();
-
-// Returns the memory usage for a given tag.
-// The value is somewhat approxiate and racy.
-size_t GetMemoryUsageForTag(TMemoryTag tag);
-
-// A batched version of GetMemoryUsageForTag.
-void GetMemoryUsageForTags(const TMemoryTag* tags, size_t count, size_t* results);
-
-////////////////////////////////////////////////////////////////////////////////
// Memory zone API
//
// Each allocation is either in the "normal zone" or "undumpable zone".
@@ -390,25 +361,6 @@ std::vector<TProfiledAllocation> GetProfiledAllocationStatistics();
////////////////////////////////////////////////////////////////////////////////
-//! An RAII guard for setting the current memory tag in a scope.
-class TMemoryTagGuard
-{
-public:
- TMemoryTagGuard();
- explicit TMemoryTagGuard(TMemoryTag tag);
-
- TMemoryTagGuard(const TMemoryTagGuard& other) = delete;
- TMemoryTagGuard(TMemoryTagGuard&& other);
-
- ~TMemoryTagGuard();
-
-private:
- bool Active_;
- TMemoryTag PreviousTag_;
-};
-
-////////////////////////////////////////////////////////////////////////////////
-
} // namespace NYT::NYTAlloc
#define YT_ALLOC_INL_H_