@@ -38,6 +38,8 @@ TSharedPageCacheCounters::TSharedPageCacheCounters(const TIntrusivePtr<::NMonito
3838namespace NKikimr {
3939namespace NTabletFlatExecutor {
4040
41+ using namespace NCache ;
42+
4143static bool Satisfies (NLog::EPriority priority = NLog::PRI_DEBUG) {
4244 if (NLog::TSettings *settings = TlsActivationContext->LoggerSettings ())
4345 return settings->Satisfies (priority, NKikimrServices::TABLET_SAUSAGECACHE);
@@ -178,7 +180,7 @@ class TSharedPageCache : public TActorBootstrapped<TSharedPageCache> {
178180 TRequestQueue ScanRequests;
179181
180182 THolder<TSharedPageCacheConfig> Config;
181- TCacheCache<TPage, TPage::TWeight, TCacheCacheConfig::TDefaultGeneration <TPage>> Cache;
183+ THolder<ICacheCache <TPage>> Cache;
182184
183185 ui64 StatBioReqs = 0 ;
184186 ui64 StatHitPages = 0 ;
@@ -193,14 +195,18 @@ class TSharedPageCache : public TActorBootstrapped<TSharedPageCache> {
193195
194196 ui64 MemLimitBytes;
195197
198+ void CreateCache () {
199+ TCacheCacheConfig cacheCacheConfig (1 , Config->Counters ->FreshBytes , Config->Counters ->StagingBytes , Config->Counters ->WarmBytes );
200+ Cache = MakeHolder<TCacheCache<TPage, TPage::TWeight, TCacheCacheConfig::TDefaultGeneration<TPage>>>(std::move (cacheCacheConfig));
201+ }
202+
196203 void ActualizeCacheSizeLimit () {
197204 ui64 limitBytes = Min (Config->LimitBytes .value_or (Max<ui64>()), MemLimitBytes);
198205
199206 // limit of cache depends only on config and mem because passive pages may go in and out arbitrary
200207 // we may have some passive bytes, so if we fully fill this Cache we may exceed the limit
201208 // because of that DoGC should be called to ensure limits
202- // unlimited cache is banned
203- Cache.UpdateCacheSize (Max<ui64>(1 , limitBytes));
209+ Cache->UpdateCacheSize (limitBytes);
204210
205211 if (Config->Counters ) {
206212 Config->Counters ->ConfigLimitBytes ->Set (Config->LimitBytes .value_or (0 ));
@@ -219,7 +225,7 @@ class TSharedPageCache : public TActorBootstrapped<TSharedPageCache> {
219225 THashSet<TCollection*> recheck;
220226 while (GetStatAllBytes () > MemLimitBytes
221227 || GetStatAllBytes () > Config->LimitBytes .value_or (Max<ui64>()) && StatActiveBytes > configActiveReservedBytes) {
222- auto page = Cache. EvictNext ();
228+ auto page = Cache-> EvictNext ();
223229 if (!page) {
224230 break ;
225231 }
@@ -366,7 +372,7 @@ class TSharedPageCache : public TActorBootstrapped<TSharedPageCache> {
366372 ++*Config->Counters ->CacheHitPages ;
367373 *Config->Counters ->CacheHitBytes += page->Size ;
368374 }
369- Evict (Cache. Touch (page));
375+ Evict (Cache-> Touch (page));
370376 break ;
371377 case PageStateNo:
372378 ++pagesToLoad;
@@ -648,7 +654,7 @@ class TSharedPageCache : public TActorBootstrapped<TSharedPageCache> {
648654 AddActivePage (page);
649655 [[fallthrough]];
650656 case PageStateLoaded:
651- Evict (Cache. Touch (page));
657+ Evict (Cache-> Touch (page));
652658 break ;
653659 default :
654660 Y_ABORT (" unknown load state" );
@@ -749,7 +755,7 @@ class TSharedPageCache : public TActorBootstrapped<TSharedPageCache> {
749755
750756 page->Initialize (std::move (paged.Data ));
751757 BodyProvided (collection, paged.PageId , page);
752- Evict (Cache. Touch (page));
758+ Evict (Cache-> Touch (page));
753759 }
754760 }
755761
@@ -882,7 +888,7 @@ class TSharedPageCache : public TActorBootstrapped<TSharedPageCache> {
882888 const TLogoBlobID &pageCollectionId = collectionIt->first ;
883889
884890 if (auto logl = Logger->Log (ELnLev::Debug))
885- logl << " droping pageCollection " << pageCollectionId;
891+ logl << " dropping pageCollection " << pageCollectionId;
886892
887893 for (auto &expe : collection.Expectants ) {
888894 for (auto &xpair : expe.second .SourceRequests ) {
@@ -901,7 +907,7 @@ class TSharedPageCache : public TActorBootstrapped<TSharedPageCache> {
901907 for (const auto &kv : collection.PageMap ) {
902908 auto * page = kv.second .Get ();
903909
904- Cache. Evict (page);
910+ Cache-> Erase (page);
905911 page->CacheGeneration = TCacheCacheConfig::CacheGenNone;
906912
907913 if (page->State == PageStateLoaded) {
@@ -1099,8 +1105,8 @@ class TSharedPageCache : public TActorBootstrapped<TSharedPageCache> {
10991105public:
11001106 TSharedPageCache (THolder<TSharedPageCacheConfig> config)
11011107 : Config(std::move(config))
1102- , Cache(TCacheCacheConfig(1 , Config->Counters->FreshBytes, Config->Counters->StagingBytes, Config->Counters->WarmBytes))
11031108 {
1109+ CreateCache ();
11041110 AsyncRequests.Limit = Config->TotalAsyncQueueInFlyLimit ;
11051111 ScanRequests.Limit = Config->TotalScanQueueInFlyLimit ;
11061112 }
0 commit comments