@@ -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+
658671template void * GetAlignedPage<>(ui64);
659672template void * GetAlignedPage<TFakeAlignedMmap>(ui64);
660673template void * GetAlignedPage<TFakeUnalignedMmap>(ui64);
0 commit comments