aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordon-dron <don-dron@yandex-team.com>2024-08-23 10:55:51 +0300
committerdon-dron <don-dron@yandex-team.com>2024-08-23 11:05:46 +0300
commite0af7b4138f90c77b064224f23b9de68e044f31b (patch)
tree0b34ccc9b8a824053041db87add7c2422420df00
parent6494b885fc509f8bb4bee9de2fdc877f7076801d (diff)
downloadydb-e0af7b4138f90c77b064224f23b9de68e044f31b.tar.gz
YT-22619: Improve merge job memory tracking
38867a055f64fbf74a008e2c1dd1ef1cda73736d
-rw-r--r--yt/yt/core/misc/collection_helpers-inl.h6
-rw-r--r--yt/yt/core/misc/collection_helpers.h3
2 files changed, 9 insertions, 0 deletions
diff --git a/yt/yt/core/misc/collection_helpers-inl.h b/yt/yt/core/misc/collection_helpers-inl.h
index 58808471cd..0bfa6d4ec2 100644
--- a/yt/yt/core/misc/collection_helpers-inl.h
+++ b/yt/yt/core/misc/collection_helpers-inl.h
@@ -350,6 +350,12 @@ const T& VectorAtOr(const std::vector<T>& vector, ssize_t index, const T& defaul
return index < std::ssize(vector) ? vector[index] : defaultValue;
}
+template <class T>
+i64 GetVectorMemoryUsage(const std::vector<T>& vector)
+{
+ return vector.capacity() * sizeof(T);
+}
+
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT
diff --git a/yt/yt/core/misc/collection_helpers.h b/yt/yt/core/misc/collection_helpers.h
index 9719a5da6c..f5f316ee30 100644
--- a/yt/yt/core/misc/collection_helpers.h
+++ b/yt/yt/core/misc/collection_helpers.h
@@ -154,6 +154,9 @@ void AssignVectorAt(std::vector<T>& vector, ssize_t index, T&& value, const T& d
template <class T>
const T& VectorAtOr(const std::vector<T>& vector, ssize_t index, const T& defaultValue = T());
+template <class T>
+i64 GetVectorMemoryUsage(const std::vector<T>& vector);
+
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT