aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
authorsabdenovch <sabdenovch@yandex-team.com>2024-12-25 15:32:36 +0300
committersabdenovch <sabdenovch@yandex-team.com>2024-12-25 16:03:19 +0300
commitea2d93eb19aa7ed85fce5abe29427a9afd9d85ee (patch)
tree5384fcbd48cd0bef1d9292b22c7fd11ec9feded9 /library/cpp
parent5a72a4afe8ee13bf0b0f5c7b4694636d22860629 (diff)
downloadydb-ea2d93eb19aa7ed85fce5abe29427a9afd9d85ee.tar.gz
YT-23859: Various memory tracking improvements
commit_hash:c87fb9e7c5cb8a896dd4b758ad73c5c540339df7
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/yt/memory/chunked_memory_allocator.h4
-rw-r--r--library/cpp/yt/memory/chunked_memory_pool-inl.h4
-rw-r--r--library/cpp/yt/memory/ref-inl.h6
3 files changed, 12 insertions, 2 deletions
diff --git a/library/cpp/yt/memory/chunked_memory_allocator.h b/library/cpp/yt/memory/chunked_memory_allocator.h
index 4804a969cf..d5e56c9f70 100644
--- a/library/cpp/yt/memory/chunked_memory_allocator.h
+++ b/library/cpp/yt/memory/chunked_memory_allocator.h
@@ -31,7 +31,9 @@ public:
chunkSize,
maxSmallBlockSizeRatio,
GetRefCountedTypeCookie<TTag>())
- { }
+ {
+ static_assert(sizeof(TTag) <= 1);
+ }
//! Allocates #sizes bytes without any alignment.
TSharedMutableRef AllocateUnaligned(i64 size);
diff --git a/library/cpp/yt/memory/chunked_memory_pool-inl.h b/library/cpp/yt/memory/chunked_memory_pool-inl.h
index 00733235f4..0faad070e9 100644
--- a/library/cpp/yt/memory/chunked_memory_pool-inl.h
+++ b/library/cpp/yt/memory/chunked_memory_pool-inl.h
@@ -71,7 +71,9 @@ inline TChunkedMemoryPool::TChunkedMemoryPool(
: TChunkedMemoryPool(
GetRefCountedTypeCookie<TTag>(),
startChunkSize)
-{ }
+{
+ static_assert(sizeof(TTag) <= 1);
+}
inline char* TChunkedMemoryPool::AllocateUnaligned(size_t size)
{
diff --git a/library/cpp/yt/memory/ref-inl.h b/library/cpp/yt/memory/ref-inl.h
index a2074f9731..13541a285a 100644
--- a/library/cpp/yt/memory/ref-inl.h
+++ b/library/cpp/yt/memory/ref-inl.h
@@ -134,6 +134,7 @@ Y_FORCE_INLINE TSharedRef::operator TRef() const
template <class TTag>
Y_FORCE_INLINE TSharedRef TSharedRef::FromString(TString str)
{
+ static_assert(sizeof(TTag) <= 1);
return FromString(std::move(str), GetRefCountedTypeCookie<TTag>());
}
@@ -145,6 +146,7 @@ Y_FORCE_INLINE TSharedRef TSharedRef::FromString(TString str)
template <class TTag>
Y_FORCE_INLINE TSharedRef TSharedRef::FromString(std::string str)
{
+ static_assert(sizeof(TTag) <= 1);
return FromString(std::move(str), GetRefCountedTypeCookie<TTag>());
}
@@ -161,6 +163,7 @@ Y_FORCE_INLINE TStringBuf TSharedRef::ToStringBuf() const
template <class TTag>
Y_FORCE_INLINE TSharedRef TSharedRef::MakeCopy(TRef ref)
{
+ static_assert(sizeof(TTag) <= 1);
return MakeCopy(ref, GetRefCountedTypeCookie<TTag>());
}
@@ -224,6 +227,7 @@ Y_FORCE_INLINE TSharedMutableRef TSharedMutableRef::AllocatePageAligned(size_t s
template <class TTag>
Y_FORCE_INLINE TSharedMutableRef TSharedMutableRef::MakeCopy(TRef ref)
{
+ static_assert(sizeof(TTag) <= 1);
return MakeCopy(ref, GetRefCountedTypeCookie<TTag>());
}
@@ -243,12 +247,14 @@ Y_FORCE_INLINE TSharedMutableRef TSharedMutableRef::Slice(void* begin, void* end
template <class TTag>
Y_FORCE_INLINE TSharedMutableRef TSharedMutableRef::Allocate(size_t size, TSharedMutableRefAllocateOptions options)
{
+ static_assert(sizeof(TTag) <= 1);
return Allocate(size, options, GetRefCountedTypeCookie<TTag>());
}
template <class TTag>
Y_FORCE_INLINE TSharedMutableRef TSharedMutableRef::AllocatePageAligned(size_t size, TSharedMutableRefAllocateOptions options)
{
+ static_assert(sizeof(TTag) <= 1);
return AllocatePageAligned(size, options, GetRefCountedTypeCookie<TTag>());
}