aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
authorbabenko <babenko@yandex-team.com>2024-01-25 19:09:19 +0300
committerAlexander Smirnov <alex@ydb.tech>2024-01-26 20:49:16 +0300
commit97a6113075180982290fb695fd24a666d2b7ceac (patch)
tree969b6c9e2246058d03b0d5c107a7f9c31c9c1046 /library/cpp
parent8f02fda318bb8a50e1712350512d4cb82fff229b (diff)
downloadydb-97a6113075180982290fb695fd24a666d2b7ceac.tar.gz
Introduce TEnumIndexedArray as a refurbished version of TEnumIndexedVector
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/yt/misc/enum.h1
-rw-r--r--library/cpp/yt/misc/enum_indexed_array-inl.h73
-rw-r--r--library/cpp/yt/misc/enum_indexed_array.h64
-rw-r--r--library/cpp/yt/misc/unittests/enum_indexed_array_ut.cpp45
-rw-r--r--library/cpp/yt/misc/unittests/ya.make1
-rw-r--r--library/cpp/yt/string/format-inl.h22
-rw-r--r--library/cpp/yt/string/unittests/enum_ut.cpp1
-rw-r--r--library/cpp/ytalloc/api/fallback.cpp18
-rw-r--r--library/cpp/ytalloc/api/ytalloc.h21
-rw-r--r--library/cpp/ytalloc/impl/core-inl.h70
10 files changed, 262 insertions, 54 deletions
diff --git a/library/cpp/yt/misc/enum.h b/library/cpp/yt/misc/enum.h
index 1494ca7907..9da79b9fd3 100644
--- a/library/cpp/yt/misc/enum.h
+++ b/library/cpp/yt/misc/enum.h
@@ -185,6 +185,7 @@ struct TEnumTraits<T, true>
////////////////////////////////////////////////////////////////////////////////
+// TODO(babenko): drop in favor of TEnumIndexedArray
//! A statically sized vector with elements of type |T| indexed by
//! the items of enumeration type |E|.
/*!
diff --git a/library/cpp/yt/misc/enum_indexed_array-inl.h b/library/cpp/yt/misc/enum_indexed_array-inl.h
new file mode 100644
index 0000000000..edda891683
--- /dev/null
+++ b/library/cpp/yt/misc/enum_indexed_array-inl.h
@@ -0,0 +1,73 @@
+#pragma once
+#ifndef ENUM_INDEXED_ARRAY_INL_H_
+#error "Direct inclusion of this file is not allowed, include enum.h"
+// For the sake of sane code completion.
+#include "enum_indexed_array.h"
+#endif
+
+#include <library/cpp/yt/assert/assert.h>
+
+namespace NYT {
+
+////////////////////////////////////////////////////////////////////////////////
+
+template <class E, class T, E Min, E Max>
+TEnumIndexedArray<E, T, Min, Max>::TEnumIndexedArray(std::initializer_list<std::pair<E, T>> elements)
+{
+ for (const auto& [index, value] : elements) {
+ (*this)[index] = value;
+ }
+}
+
+template <class E, class T, E Min, E Max>
+T& TEnumIndexedArray<E, T, Min, Max>::operator[] (E index)
+{
+ YT_ASSERT(IsValidIndex(index));
+ return Items_[ToUnderlying(index) - ToUnderlying(Min)];
+}
+
+template <class E, class T, E Min, E Max>
+const T& TEnumIndexedArray<E, T, Min, Max>::operator[] (E index) const
+{
+ return const_cast<TEnumIndexedArray&>(*this)[index];
+}
+
+template <class E, class T, E Min, E Max>
+T* TEnumIndexedArray<E, T, Min, Max>::begin()
+{
+ return Items_.data();
+}
+
+template <class E, class T, E Min, E Max>
+const T* TEnumIndexedArray<E, T, Min, Max>::begin() const
+{
+ return Items_.data();
+}
+
+template <class E, class T, E Min, E Max>
+T* TEnumIndexedArray<E, T, Min, Max>::end()
+{
+ return begin() + Size;
+}
+
+template <class E, class T, E Min, E Max>
+const T* TEnumIndexedArray<E, T, Min, Max>::end() const
+{
+ return begin() + Size;
+}
+
+template <class E, class T, E Min, E Max>
+constexpr size_t TEnumIndexedArray<E, T, Min, Max>::size() const
+{
+ return Size;
+}
+
+template <class E, class T, E Min, E Max>
+bool TEnumIndexedArray<E, T, Min, Max>::IsValidIndex(E index)
+{
+ return index >= Min && index <= Max;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+} // namespace NYT
diff --git a/library/cpp/yt/misc/enum_indexed_array.h b/library/cpp/yt/misc/enum_indexed_array.h
new file mode 100644
index 0000000000..8992456277
--- /dev/null
+++ b/library/cpp/yt/misc/enum_indexed_array.h
@@ -0,0 +1,64 @@
+#pragma once
+
+#include "enum.h"
+
+namespace NYT {
+
+////////////////////////////////////////////////////////////////////////////////
+
+//! A statically sized vector with elements of type |T| indexed by
+//! the items of enumeration type |E|.
+/*!
+ * By default, valid indexes are in range from the minimum declared value of |E|
+ * to the maximum declared value of |E|.
+ *
+ * Items are value-initialized on construction.
+ */
+template <
+ class E,
+ class T,
+ E Min = TEnumTraits<E>::GetMinValue(),
+ E Max = TEnumTraits<E>::GetMaxValue()
+>
+class TEnumIndexedArray
+{
+public:
+ static_assert(Min <= Max);
+
+ using TIndex = E;
+ using TValue = T;
+
+ constexpr TEnumIndexedArray() = default;
+ TEnumIndexedArray(std::initializer_list<std::pair<E, T>> elements);
+
+ constexpr TEnumIndexedArray(const TEnumIndexedArray&) = default;
+ constexpr TEnumIndexedArray(TEnumIndexedArray&&) = default;
+
+ constexpr TEnumIndexedArray& operator=(const TEnumIndexedArray&) = default;
+ constexpr TEnumIndexedArray& operator=(TEnumIndexedArray&&) = default;
+
+ T& operator[] (E index);
+ const T& operator[] (E index) const;
+
+ // STL interop.
+ T* begin();
+ const T* begin() const;
+ T* end();
+ const T* end() const;
+
+ constexpr size_t size() const;
+
+ static bool IsValidIndex(E index);
+
+private:
+ static constexpr size_t Size = static_cast<size_t>(Max) - static_cast<size_t>(Min) + 1;
+ std::array<T, Size> Items_{};
+};
+
+////////////////////////////////////////////////////////////////////////////////
+
+} // namespace NYT
+
+#define ENUM_INDEXED_ARRAY_INL_H_
+#include "enum_indexed_array-inl.h"
+#undef ENUM_INDEXED_ARRAY_INL_H_
diff --git a/library/cpp/yt/misc/unittests/enum_indexed_array_ut.cpp b/library/cpp/yt/misc/unittests/enum_indexed_array_ut.cpp
new file mode 100644
index 0000000000..4111c6f4fe
--- /dev/null
+++ b/library/cpp/yt/misc/unittests/enum_indexed_array_ut.cpp
@@ -0,0 +1,45 @@
+#include <library/cpp/testing/gtest/gtest.h>
+
+#include <library/cpp/yt/misc/enum_indexed_array.h>
+
+namespace NYT {
+namespace {
+
+////////////////////////////////////////////////////////////////////////////////
+
+DEFINE_ENUM(EColor,
+ ((Red) (10))
+ ((Green)(20))
+ ((Blue) (30))
+);
+
+TEST(TEnumIndexedArrayTest, Size)
+{
+ TEnumIndexedArray<EColor, int> arr;
+ EXPECT_EQ(std::ssize(arr), 21);
+}
+
+TEST(TEnumIndexedArrayTest, IsValidIndex)
+{
+ TEnumIndexedArray<EColor, int> arr;
+ EXPECT_TRUE(arr.IsValidIndex(EColor::Red));
+ EXPECT_TRUE(arr.IsValidIndex(EColor::Green));
+ EXPECT_TRUE(arr.IsValidIndex(EColor::Blue));
+ EXPECT_TRUE(arr.IsValidIndex(static_cast<EColor>(11)));
+ EXPECT_FALSE(arr.IsValidIndex(static_cast<EColor>(9)));
+}
+
+TEST(TEnumIndexedArrayTest, Simple)
+{
+ TEnumIndexedArray<EColor, int> arr;
+ EXPECT_EQ(arr[EColor::Red], 0);
+ arr[EColor::Red] = 1;
+ EXPECT_EQ(arr[EColor::Red], 1);
+ EXPECT_EQ(arr[EColor::Blue], 0);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+} // namespace
+} // namespace NYT
+
diff --git a/library/cpp/yt/misc/unittests/ya.make b/library/cpp/yt/misc/unittests/ya.make
index 611edd7217..43e9f9b9ff 100644
--- a/library/cpp/yt/misc/unittests/ya.make
+++ b/library/cpp/yt/misc/unittests/ya.make
@@ -4,6 +4,7 @@ INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc)
SRCS(
enum_ut.cpp
+ enum_indexed_array_ut.cpp
guid_ut.cpp
preprocessor_ut.cpp
strong_typedef_ut.cpp
diff --git a/library/cpp/yt/string/format-inl.h b/library/cpp/yt/string/format-inl.h
index c379af712a..c198fdcd65 100644
--- a/library/cpp/yt/string/format-inl.h
+++ b/library/cpp/yt/string/format-inl.h
@@ -12,6 +12,7 @@
#include <library/cpp/yt/small_containers/compact_vector.h>
#include <library/cpp/yt/misc/enum.h>
+#include <library/cpp/yt/misc/enum_indexed_array.h>
#include <util/system/platform.h>
@@ -393,6 +394,27 @@ struct TValueFormatter<THashMultiMap<K, V>>
}
};
+// TEnumIndexedArray
+template <class E, class T>
+struct TValueFormatter<TEnumIndexedArray<E, T>>
+{
+ static void Do(TStringBuilderBase* builder, const TEnumIndexedArray<E, T>& collection, TStringBuf format)
+ {
+ builder->AppendChar('{');
+ bool firstItem = true;
+ for (const auto& index : TEnumTraits<E>::GetDomainValues()) {
+ if (!firstItem) {
+ builder->AppendString(DefaultJoinToStringDelimiter);
+ }
+ FormatValue(builder, index, format);
+ builder->AppendString(": ");
+ FormatValue(builder, collection[index], format);
+ firstItem = false;
+ }
+ builder->AppendChar('}');
+ }
+};
+
// TEnumIndexedVector
template <class E, class T>
struct TValueFormatter<TEnumIndexedVector<E, T>>
diff --git a/library/cpp/yt/string/unittests/enum_ut.cpp b/library/cpp/yt/string/unittests/enum_ut.cpp
index 4059b3d2e6..91a8b04500 100644
--- a/library/cpp/yt/string/unittests/enum_ut.cpp
+++ b/library/cpp/yt/string/unittests/enum_ut.cpp
@@ -13,6 +13,7 @@ namespace {
// Some compile-time sanity checks.
DEFINE_ENUM(ESample, (One)(Two));
static_assert(TFormatTraits<ESample>::HasCustomFormatValue);
+static_assert(TFormatTraits<TEnumIndexedArray<ESample, int>>::HasCustomFormatValue);
static_assert(TFormatTraits<TEnumIndexedVector<ESample, int>>::HasCustomFormatValue);
DEFINE_ENUM(EColor,
diff --git a/library/cpp/ytalloc/api/fallback.cpp b/library/cpp/ytalloc/api/fallback.cpp
index d094cf2e93..d7dca33f88 100644
--- a/library/cpp/ytalloc/api/fallback.cpp
+++ b/library/cpp/ytalloc/api/fallback.cpp
@@ -144,47 +144,47 @@ Y_WEAK void SetEnableMadvisePopulate(bool /*value*/)
////////////////////////////////////////////////////////////////////////////////
-Y_WEAK TEnumIndexedVector<ETotalCounter, ssize_t> GetTotalAllocationCounters()
+Y_WEAK TEnumIndexedArray<ETotalCounter, ssize_t> GetTotalAllocationCounters()
{
return {};
}
-Y_WEAK TEnumIndexedVector<ESmallCounter, ssize_t> GetSmallAllocationCounters()
+Y_WEAK TEnumIndexedArray<ESmallCounter, ssize_t> GetSmallAllocationCounters()
{
return {};
}
-Y_WEAK TEnumIndexedVector<ELargeCounter, ssize_t> GetLargeAllocationCounters()
+Y_WEAK TEnumIndexedArray<ELargeCounter, ssize_t> GetLargeAllocationCounters()
{
return {};
}
-Y_WEAK std::array<TEnumIndexedVector<ESmallArenaCounter, ssize_t>, SmallRankCount> GetSmallArenaAllocationCounters()
+Y_WEAK std::array<TEnumIndexedArray<ESmallArenaCounter, ssize_t>, SmallRankCount> GetSmallArenaAllocationCounters()
{
return {};
}
-Y_WEAK std::array<TEnumIndexedVector<ELargeArenaCounter, ssize_t>, LargeRankCount> GetLargeArenaAllocationCounters()
+Y_WEAK std::array<TEnumIndexedArray<ELargeArenaCounter, ssize_t>, LargeRankCount> GetLargeArenaAllocationCounters()
{
return {};
}
-Y_WEAK TEnumIndexedVector<EHugeCounter, ssize_t> GetHugeAllocationCounters()
+Y_WEAK TEnumIndexedArray<EHugeCounter, ssize_t> GetHugeAllocationCounters()
{
return {};
}
-Y_WEAK TEnumIndexedVector<ESystemCounter, ssize_t> GetSystemAllocationCounters()
+Y_WEAK TEnumIndexedArray<ESystemCounter, ssize_t> GetSystemAllocationCounters()
{
return {};
}
-Y_WEAK TEnumIndexedVector<EUndumpableCounter, ssize_t> GetUndumpableAllocationCounters()
+Y_WEAK TEnumIndexedArray<EUndumpableCounter, ssize_t> GetUndumpableAllocationCounters()
{
return {};
}
-Y_WEAK TEnumIndexedVector<ETimingEventType, TTimingEventCounters> GetTimingEventCounters()
+Y_WEAK TEnumIndexedArray<ETimingEventType, TTimingEventCounters> GetTimingEventCounters()
{
return {};
}
diff --git a/library/cpp/ytalloc/api/ytalloc.h b/library/cpp/ytalloc/api/ytalloc.h
index 219814def2..43ba48852d 100644
--- a/library/cpp/ytalloc/api/ytalloc.h
+++ b/library/cpp/ytalloc/api/ytalloc.h
@@ -3,6 +3,7 @@
#include <stddef.h>
#include <library/cpp/yt/misc/enum.h>
+#include <library/cpp/yt/misc/enum_indexed_array.h>
#include <util/system/types.h>
@@ -289,28 +290,28 @@ DEFINE_ENUM(ETotalCounter,
);
// Returns statistics for all user allocations.
-TEnumIndexedVector<ETotalCounter, ssize_t> GetTotalAllocationCounters();
+TEnumIndexedArray<ETotalCounter, ssize_t> GetTotalAllocationCounters();
// Returns statistics for small allocations; these are included into total statistics.
-TEnumIndexedVector<ESmallCounter, ssize_t> GetSmallAllocationCounters();
+TEnumIndexedArray<ESmallCounter, ssize_t> GetSmallAllocationCounters();
// Returns statistics for large allocations; these are included into total statistics.
-TEnumIndexedVector<ELargeCounter, ssize_t> GetLargeAllocationCounters();
+TEnumIndexedArray<ELargeCounter, ssize_t> GetLargeAllocationCounters();
// Returns per-arena statistics for small allocations; these are included into total statistics.
-std::array<TEnumIndexedVector<ESmallArenaCounter, ssize_t>, SmallRankCount> GetSmallArenaAllocationCounters();
+std::array<TEnumIndexedArray<ESmallArenaCounter, ssize_t>, SmallRankCount> GetSmallArenaAllocationCounters();
// Returns per-arena statistics for large allocations; these are included into total statistics.
-std::array<TEnumIndexedVector<ELargeArenaCounter, ssize_t>, LargeRankCount> GetLargeArenaAllocationCounters();
+std::array<TEnumIndexedArray<ELargeArenaCounter, ssize_t>, LargeRankCount> GetLargeArenaAllocationCounters();
// Returns statistics for huge allocations; these are included into total statistics.
-TEnumIndexedVector<EHugeCounter, ssize_t> GetHugeAllocationCounters();
+TEnumIndexedArray<EHugeCounter, ssize_t> GetHugeAllocationCounters();
// Returns statistics for all system allocations; these are not included into total statistics.
-TEnumIndexedVector<ESystemCounter, ssize_t> GetSystemAllocationCounters();
+TEnumIndexedArray<ESystemCounter, ssize_t> GetSystemAllocationCounters();
// Returns statistics for undumpable allocations.
-TEnumIndexedVector<EUndumpableCounter, ssize_t> GetUndumpableAllocationCounters();
+TEnumIndexedArray<EUndumpableCounter, ssize_t> GetUndumpableAllocationCounters();
DEFINE_ENUM(ETimingEventType,
(Mmap)
@@ -333,7 +334,7 @@ struct TTimingEventCounters
// Returns statistics for timing events happened since start.
// See SetTimingEventThreshold.
-TEnumIndexedVector<ETimingEventType, TTimingEventCounters> GetTimingEventCounters();
+TEnumIndexedArray<ETimingEventType, TTimingEventCounters> GetTimingEventCounters();
////////////////////////////////////////////////////////////////////////////////
@@ -349,7 +350,7 @@ struct TBacktrace
struct TProfiledAllocation
{
TBacktrace Backtrace;
- TEnumIndexedVector<EBasicCounter, ssize_t> Counters;
+ TEnumIndexedArray<EBasicCounter, ssize_t> Counters;
};
// Returns statistics for profiled allocations (available when allocation
diff --git a/library/cpp/ytalloc/impl/core-inl.h b/library/cpp/ytalloc/impl/core-inl.h
index 64e95188f4..ba5128bd8d 100644
--- a/library/cpp/ytalloc/impl/core-inl.h
+++ b/library/cpp/ytalloc/impl/core-inl.h
@@ -940,14 +940,14 @@ class TTimingManager
: public TEventLogManagerBase<TTimingEvent, TTimingManager>
{
public:
- TEnumIndexedVector<ETimingEventType, TTimingEventCounters> GetTimingEventCounters()
+ TEnumIndexedArray<ETimingEventType, TTimingEventCounters> GetTimingEventCounters()
{
auto guard = Guard(EventLock_);
return EventCounters_;
}
private:
- TEnumIndexedVector<ETimingEventType, TTimingEventCounters> EventCounters_;
+ TEnumIndexedArray<ETimingEventType, TTimingEventCounters> EventCounters_;
Y_POD_STATIC_THREAD(bool) DisabledForCurrentThread_;
@@ -1523,13 +1523,13 @@ static_assert(
"Wrong MaxMemoryTag");
template <class TCounter>
-using TUntaggedTotalCounters = TEnumIndexedVector<EBasicCounter, TCounter>;
+using TUntaggedTotalCounters = TEnumIndexedArray<EBasicCounter, TCounter>;
template <class TCounter>
struct TTaggedTotalCounterSet
: public TSystemAllocatable
{
- std::array<TEnumIndexedVector<EBasicCounter, TCounter>, TaggedCounterSetSize> Counters;
+ std::array<TEnumIndexedArray<EBasicCounter, TCounter>, TaggedCounterSetSize> Counters;
};
using TLocalTaggedBasicCounterSet = TTaggedTotalCounterSet<ssize_t>;
@@ -1577,20 +1577,20 @@ struct TTotalCounters
}
};
-using TLocalSystemCounters = TEnumIndexedVector<ESystemCounter, ssize_t>;
-using TGlobalSystemCounters = TEnumIndexedVector<ESystemCounter, std::atomic<ssize_t>>;
+using TLocalSystemCounters = TEnumIndexedArray<ESystemCounter, ssize_t>;
+using TGlobalSystemCounters = TEnumIndexedArray<ESystemCounter, std::atomic<ssize_t>>;
-using TLocalSmallCounters = TEnumIndexedVector<ESmallArenaCounter, ssize_t>;
-using TGlobalSmallCounters = TEnumIndexedVector<ESmallArenaCounter, std::atomic<ssize_t>>;
+using TLocalSmallCounters = TEnumIndexedArray<ESmallArenaCounter, ssize_t>;
+using TGlobalSmallCounters = TEnumIndexedArray<ESmallArenaCounter, std::atomic<ssize_t>>;
-using TLocalLargeCounters = TEnumIndexedVector<ELargeArenaCounter, ssize_t>;
-using TGlobalLargeCounters = TEnumIndexedVector<ELargeArenaCounter, std::atomic<ssize_t>>;
+using TLocalLargeCounters = TEnumIndexedArray<ELargeArenaCounter, ssize_t>;
+using TGlobalLargeCounters = TEnumIndexedArray<ELargeArenaCounter, std::atomic<ssize_t>>;
-using TLocalHugeCounters = TEnumIndexedVector<EHugeCounter, ssize_t>;
-using TGlobalHugeCounters = TEnumIndexedVector<EHugeCounter, std::atomic<ssize_t>>;
+using TLocalHugeCounters = TEnumIndexedArray<EHugeCounter, ssize_t>;
+using TGlobalHugeCounters = TEnumIndexedArray<EHugeCounter, std::atomic<ssize_t>>;
-using TLocalUndumpableCounters = TEnumIndexedVector<EUndumpableCounter, ssize_t>;
-using TGlobalUndumpableCounters = TEnumIndexedVector<EUndumpableCounter, std::atomic<ssize_t>>;
+using TLocalUndumpableCounters = TEnumIndexedArray<EUndumpableCounter, ssize_t>;
+using TGlobalUndumpableCounters = TEnumIndexedArray<EUndumpableCounter, std::atomic<ssize_t>>;
Y_FORCE_INLINE ssize_t LoadCounter(ssize_t counter)
{
@@ -1750,7 +1750,7 @@ struct TThreadState
std::array<bool, SmallRankCount> CachedChunkFull{};
#endif
};
- TEnumIndexedVector<EAllocationKind, TSmallBlobCache> SmallBlobCache;
+ TEnumIndexedArray<EAllocationKind, TSmallBlobCache> SmallBlobCache;
};
struct TThreadStateToRegistryNode
@@ -2227,7 +2227,7 @@ public:
}
// Computes memory usage for a list of tags by aggregating counters across threads.
- void GetTaggedMemoryCounters(const TMemoryTag* tags, size_t count, TEnumIndexedVector<EBasicCounter, ssize_t>* counters)
+ void GetTaggedMemoryCounters(const TMemoryTag* tags, size_t count, TEnumIndexedArray<EBasicCounter, ssize_t>* counters)
{
TMemoryTagGuard guard(NullMemoryTag);
@@ -2260,7 +2260,7 @@ public:
{
TMemoryTagGuard guard(NullMemoryTag);
- std::vector<TEnumIndexedVector<EBasicCounter, ssize_t>> counters;
+ std::vector<TEnumIndexedArray<EBasicCounter, ssize_t>> counters;
counters.resize(count);
GetTaggedMemoryCounters(tags, count, counters.data());
@@ -2269,9 +2269,9 @@ public:
}
}
- TEnumIndexedVector<ETotalCounter, ssize_t> GetTotalAllocationCounters()
+ TEnumIndexedArray<ETotalCounter, ssize_t> GetTotalAllocationCounters()
{
- TEnumIndexedVector<ETotalCounter, ssize_t> result;
+ TEnumIndexedArray<ETotalCounter, ssize_t> result;
auto accumulate = [&] (const auto& counters) {
result[ETotalCounter::BytesAllocated] += LoadCounter(counters[EBasicCounter::BytesAllocated]);
@@ -2312,9 +2312,9 @@ public:
return result;
}
- TEnumIndexedVector<ESmallCounter, ssize_t> GetSmallAllocationCounters()
+ TEnumIndexedArray<ESmallCounter, ssize_t> GetSmallAllocationCounters()
{
- TEnumIndexedVector<ESmallCounter, ssize_t> result;
+ TEnumIndexedArray<ESmallCounter, ssize_t> result;
auto totalCounters = GetTotalAllocationCounters();
result[ESmallCounter::BytesAllocated] = totalCounters[ETotalCounter::BytesAllocated];
@@ -2347,9 +2347,9 @@ public:
return result;
}
- TEnumIndexedVector<ELargeCounter, ssize_t> GetLargeAllocationCounters()
+ TEnumIndexedArray<ELargeCounter, ssize_t> GetLargeAllocationCounters()
{
- TEnumIndexedVector<ELargeCounter, ssize_t> result;
+ TEnumIndexedArray<ELargeCounter, ssize_t> result;
auto largeArenaCounters = GetLargeArenaAllocationCounters();
for (size_t rank = 0; rank < LargeRankCount; ++rank) {
result[ESmallCounter::BytesAllocated] += largeArenaCounters[rank][ELargeArenaCounter::BytesAllocated];
@@ -2826,7 +2826,7 @@ private:
}
};
-TExplicitlyConstructableSingleton<TEnumIndexedVector<EAllocationKind, std::array<TExplicitlyConstructableSingleton<TSmallArenaAllocator>, SmallRankCount>>> SmallArenaAllocators;
+TExplicitlyConstructableSingleton<TEnumIndexedArray<EAllocationKind, std::array<TExplicitlyConstructableSingleton<TSmallArenaAllocator>, SmallRankCount>>> SmallArenaAllocators;
////////////////////////////////////////////////////////////////////////////////
@@ -3023,7 +3023,7 @@ private:
std::array<TShardedFreeList<TChunkGroup>, SmallRankCount> RankToChunkGroups_;
};
-TExplicitlyConstructableSingleton<TEnumIndexedVector<EAllocationKind, TExplicitlyConstructableSingleton<TGlobalSmallChunkCache>>> GlobalSmallChunkCaches;
+TExplicitlyConstructableSingleton<TEnumIndexedArray<EAllocationKind, TExplicitlyConstructableSingleton<TGlobalSmallChunkCache>>> GlobalSmallChunkCaches;
////////////////////////////////////////////////////////////////////////////////
@@ -4750,49 +4750,49 @@ void SetEnableMadvisePopulate(bool value)
ConfigurationManager->SetEnableMadvisePopulate(value);
}
-TEnumIndexedVector<ETotalCounter, ssize_t> GetTotalAllocationCounters()
+TEnumIndexedArray<ETotalCounter, ssize_t> GetTotalAllocationCounters()
{
InitializeGlobals();
return StatisticsManager->GetTotalAllocationCounters();
}
-TEnumIndexedVector<ESystemCounter, ssize_t> GetSystemAllocationCounters()
+TEnumIndexedArray<ESystemCounter, ssize_t> GetSystemAllocationCounters()
{
InitializeGlobals();
return StatisticsManager->GetSystemAllocationCounters();
}
-TEnumIndexedVector<ESystemCounter, ssize_t> GetUndumpableAllocationCounters()
+TEnumIndexedArray<ESystemCounter, ssize_t> GetUndumpableAllocationCounters()
{
InitializeGlobals();
return StatisticsManager->GetUndumpableAllocationCounters();
}
-TEnumIndexedVector<ESmallCounter, ssize_t> GetSmallAllocationCounters()
+TEnumIndexedArray<ESmallCounter, ssize_t> GetSmallAllocationCounters()
{
InitializeGlobals();
return StatisticsManager->GetSmallAllocationCounters();
}
-TEnumIndexedVector<ESmallCounter, ssize_t> GetLargeAllocationCounters()
+TEnumIndexedArray<ESmallCounter, ssize_t> GetLargeAllocationCounters()
{
InitializeGlobals();
return StatisticsManager->GetLargeAllocationCounters();
}
-std::array<TEnumIndexedVector<ESmallArenaCounter, ssize_t>, SmallRankCount> GetSmallArenaAllocationCounters()
+std::array<TEnumIndexedArray<ESmallArenaCounter, ssize_t>, SmallRankCount> GetSmallArenaAllocationCounters()
{
InitializeGlobals();
return StatisticsManager->GetSmallArenaAllocationCounters();
}
-std::array<TEnumIndexedVector<ELargeArenaCounter, ssize_t>, LargeRankCount> GetLargeArenaAllocationCounters()
+std::array<TEnumIndexedArray<ELargeArenaCounter, ssize_t>, LargeRankCount> GetLargeArenaAllocationCounters()
{
InitializeGlobals();
return StatisticsManager->GetLargeArenaAllocationCounters();
}
-TEnumIndexedVector<EHugeCounter, ssize_t> GetHugeAllocationCounters()
+TEnumIndexedArray<EHugeCounter, ssize_t> GetHugeAllocationCounters()
{
InitializeGlobals();
return StatisticsManager->GetHugeAllocationCounters();
@@ -4816,7 +4816,7 @@ std::vector<TProfiledAllocation> GetProfiledAllocationStatistics()
}
tags.push_back(AllocationProfilingUnknownMemoryTag);
- std::vector<TEnumIndexedVector<EBasicCounter, ssize_t>> counters;
+ std::vector<TEnumIndexedArray<EBasicCounter, ssize_t>> counters;
counters.resize(tags.size());
StatisticsManager->GetTaggedMemoryCounters(tags.data(), tags.size(), counters.data());
@@ -4838,7 +4838,7 @@ std::vector<TProfiledAllocation> GetProfiledAllocationStatistics()
return statistics;
}
-TEnumIndexedVector<ETimingEventType, TTimingEventCounters> GetTimingEventCounters()
+TEnumIndexedArray<ETimingEventType, TTimingEventCounters> GetTimingEventCounters()
{
InitializeGlobals();
return TimingManager->GetTimingEventCounters();