@@ -103,6 +103,10 @@ class TGlobalPools {
103
103
return *Pools[index];
104
104
}
105
105
106
+ const TGlobalPagePool<T, SysAlign>& Get (ui32 index) const {
107
+ return *Pools[index];
108
+ }
109
+
106
110
TGlobalPools ()
107
111
{
108
112
Reset ();
@@ -141,7 +145,7 @@ class TGlobalPools {
141
145
i64 GetTotalFreeListBytes () const {
142
146
i64 bytes = 0 ;
143
147
for (ui32 i = 0 ; i <= MidLevels; ++i) {
144
- bytes += Get (i).GetPageCount () * Get (i). GetPageSize ();
148
+ bytes += Get (i).GetSize ();
145
149
}
146
150
147
151
return bytes;
@@ -596,17 +600,19 @@ void* GetAlignedPage(ui64 size) {
596
600
size = TAlignedPagePool::POOL_PAGE_SIZE;
597
601
}
598
602
603
+ auto & pool = TGlobalPools<TMmap, true >::Instance ();
604
+
599
605
if (size <= MaxMidSize) {
600
606
size = FastClp2 (size);
601
607
auto level = LeastSignificantBit (size) - LeastSignificantBit (TAlignedPagePool::POOL_PAGE_SIZE);
602
608
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 ()) {
604
610
return res;
605
611
}
606
612
}
607
613
608
614
auto allocSize = Max<ui64>(MaxMidSize, size);
609
- void * mem = TMmap::Mmap (allocSize);
615
+ void * mem = pool. DoMmap (allocSize);
610
616
if (Y_UNLIKELY (MAP_FAILED == mem)) {
611
617
ythrow yexception () << " Mmap failed to allocate " << allocSize << " bytes: " << LastSystemErrorText ();
612
618
}
@@ -615,7 +621,6 @@ void* GetAlignedPage(ui64 size) {
615
621
// push extra allocated pages to cache
616
622
auto level = LeastSignificantBit (size) - LeastSignificantBit (TAlignedPagePool::POOL_PAGE_SIZE);
617
623
Y_DEBUG_ABORT_UNLESS (level <= MidLevels);
618
- auto & pool = TGlobalPools<TMmap, true >::Instance ();
619
624
ui8* ptr = (ui8*)mem + size;
620
625
ui8* const end = (ui8*)mem + MaxMidSize;
621
626
while (ptr < end) {
@@ -655,6 +660,14 @@ i64 GetTotalFreeListBytes() {
655
660
return TGlobalPools<TMmap, true >::Instance ().GetTotalFreeListBytes () + TGlobalPools<TMmap, false >::Instance ().GetTotalFreeListBytes ();
656
661
}
657
662
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
+
658
671
template void * GetAlignedPage<>(ui64);
659
672
template void * GetAlignedPage<TFakeAlignedMmap>(ui64);
660
673
template void * GetAlignedPage<TFakeUnalignedMmap>(ui64);
0 commit comments