Browse Source

Add an option to disable refcounted tracking
commit_hash:ceb575c0377d4a48c0507590d878e690e92f5c63

nastprol 5 months ago
parent
commit
e4a44c558f

+ 2 - 0
library/cpp/yt/memory/chunked_memory_pool.cpp

@@ -15,6 +15,8 @@ TAllocationHolder::TAllocationHolder(TMutableRef ref, TRefCountedTypeCookie cook
         TRefCountedTrackerFacade::AllocateTagInstance(Cookie_);
         TRefCountedTrackerFacade::AllocateSpace(Cookie_, Ref_.Size());
     }
+#else
+    Y_UNUSED(cookie);
 #endif
 }
 

+ 6 - 0
library/cpp/yt/memory/ref.cpp

@@ -59,6 +59,8 @@ public:
 #ifdef YT_ENABLE_REF_COUNTED_TRACKING
         TRefCountedTrackerFacade::AllocateTagInstance(Cookie_);
         TRefCountedTrackerFacade::AllocateSpace(Cookie_, String_.length());
+#else
+        Y_UNUSED(cookie);
 #endif
     }
     ~TStringHolder()
@@ -119,7 +121,11 @@ protected:
         TRefCountedTypeCookie cookie)
     {
         Size_ = size;
+#ifdef YT_ENABLE_REF_COUNTED_TRACKING
         Cookie_ = cookie;
+#else
+        Y_UNUSED(cookie);
+#endif
         if (options.InitializeStorage) {
             ::memset(static_cast<TDerived*>(this)->GetBegin(), 0, Size_);
         }

+ 5 - 3
library/cpp/yt/misc/port.h

@@ -7,9 +7,11 @@
     #error YT requires 64-bit platform
 #endif
 
-// This define enables tracking of reference-counted objects to provide
-// various insightful information on memory usage and object creation patterns.
-#define YT_ENABLE_REF_COUNTED_TRACKING
+#ifndef YT_DISABLE_REF_COUNTED_TRACKING
+    // This define enables tracking of reference-counted objects to provide
+    // various insightful information on memory usage and object creation patterns.
+    #define YT_ENABLE_REF_COUNTED_TRACKING
+#endif
 
 // This define enables logging with TRACE level. You can still disable trace logging
 // for particular TU by discarding this macro identifier.