Skip to content

Commit 1c08994

Browse files
authored
fix aligned page pool counters (#9373)
1 parent cd6aa7b commit 1c08994

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

ydb/core/base/pool_stats_collector.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,21 @@ class TStatsCollectingActor : public NActors::TStatsCollectingActor {
3232
void Init(::NMonitoring::TDynamicCounters* group) {
3333
CounterGroup = group->GetSubgroup("subsystem", "mkqlalloc");
3434
TotalBytes = CounterGroup->GetCounter("GlobalPoolTotalBytes", false);
35+
TotalMmapped = CounterGroup->GetCounter("TotalMmappedBytes", false);
36+
TotalFreeList = CounterGroup->GetCounter("TotalFreeListBytes", false);
3537
}
3638

3739
void Update() {
3840
*TotalBytes = TAlignedPagePool::GetGlobalPagePoolSize();
41+
*TotalMmapped = ::NKikimr::GetTotalMmapedBytes();
42+
*TotalFreeList = ::NKikimr::GetTotalFreeListBytes();
3943
}
4044

4145
private:
4246
TIntrusivePtr<::NMonitoring::TDynamicCounters> CounterGroup;
4347
::NMonitoring::TDynamicCounters::TCounterPtr TotalBytes;
48+
::NMonitoring::TDynamicCounters::TCounterPtr TotalMmapped;
49+
::NMonitoring::TDynamicCounters::TCounterPtr TotalFreeList;
4450
};
4551

4652
void OnWakeup(const TActorContext &ctx) override {

ydb/library/yql/minikql/aligned_page_pool.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ class TGlobalPools {
103103
return *Pools[index];
104104
}
105105

106+
const TGlobalPagePool<T, SysAlign>& Get(ui32 index) const {
107+
return *Pools[index];
108+
}
109+
106110
TGlobalPools()
107111
{
108112
Reset();
@@ -141,7 +145,7 @@ class TGlobalPools {
141145
i64 GetTotalFreeListBytes() const {
142146
i64 bytes = 0;
143147
for (ui32 i = 0; i <= MidLevels; ++i) {
144-
bytes += Get(i).GetPageCount() * Get(i).GetPageSize();
148+
bytes += Get(i).GetSize();
145149
}
146150

147151
return bytes;
@@ -596,17 +600,19 @@ void* GetAlignedPage(ui64 size) {
596600
size = TAlignedPagePool::POOL_PAGE_SIZE;
597601
}
598602

603+
auto& pool = TGlobalPools<TMmap, true>::Instance();
604+
599605
if (size <= MaxMidSize) {
600606
size = FastClp2(size);
601607
auto level = LeastSignificantBit(size) - LeastSignificantBit(TAlignedPagePool::POOL_PAGE_SIZE);
602608
Y_DEBUG_ABORT_UNLESS(level <= MidLevels);
603-
if (auto res = TGlobalPools<TMmap, true>::Instance().Get(level).GetPage()) {
609+
if (auto res = pool.Get(level).GetPage()) {
604610
return res;
605611
}
606612
}
607613

608614
auto allocSize = Max<ui64>(MaxMidSize, size);
609-
void* mem = TMmap::Mmap(allocSize);
615+
void* mem = pool.DoMmap(allocSize);
610616
if (Y_UNLIKELY(MAP_FAILED == mem)) {
611617
ythrow yexception() << "Mmap failed to allocate " << allocSize << " bytes: " << LastSystemErrorText();
612618
}
@@ -615,7 +621,6 @@ void* GetAlignedPage(ui64 size) {
615621
// push extra allocated pages to cache
616622
auto level = LeastSignificantBit(size) - LeastSignificantBit(TAlignedPagePool::POOL_PAGE_SIZE);
617623
Y_DEBUG_ABORT_UNLESS(level <= MidLevels);
618-
auto& pool = TGlobalPools<TMmap, true>::Instance();
619624
ui8* ptr = (ui8*)mem + size;
620625
ui8* const end = (ui8*)mem + MaxMidSize;
621626
while (ptr < end) {
@@ -655,6 +660,14 @@ i64 GetTotalFreeListBytes() {
655660
return TGlobalPools<TMmap, true>::Instance().GetTotalFreeListBytes() + TGlobalPools<TMmap, false>::Instance().GetTotalFreeListBytes();
656661
}
657662

663+
template i64 GetTotalMmapedBytes<>();
664+
template i64 GetTotalMmapedBytes<TFakeAlignedMmap>();
665+
template i64 GetTotalMmapedBytes<TFakeUnalignedMmap>();
666+
667+
template i64 GetTotalFreeListBytes<>();
668+
template i64 GetTotalFreeListBytes<TFakeAlignedMmap>();
669+
template i64 GetTotalFreeListBytes<TFakeUnalignedMmap>();
670+
658671
template void* GetAlignedPage<>(ui64);
659672
template void* GetAlignedPage<TFakeAlignedMmap>(ui64);
660673
template void* GetAlignedPage<TFakeUnalignedMmap>(ui64);

0 commit comments

Comments
 (0)