From 00dc4e3d0976e0f0cbd8a09a7693bad31b8db511 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Mon, 12 May 2025 10:22:17 +0200 Subject: enable per bucket config (#388) Feature: Add per bucket cache configuration (Lua options file only) Improvement: --cache-memlayer-sizethreshold is now deprecated and has a new name: --cache-bucket-memlayer-sizethreshold to line up with per cache bucket configuration --- src/zenstore/cache/cachedisklayer.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/zenstore/cache/cachedisklayer.cpp') diff --git a/src/zenstore/cache/cachedisklayer.cpp b/src/zenstore/cache/cachedisklayer.cpp index 8b120fda5..e7b2e6bc6 100644 --- a/src/zenstore/cache/cachedisklayer.cpp +++ b/src/zenstore/cache/cachedisklayer.cpp @@ -3617,7 +3617,15 @@ ZenCacheDiskLayer::GetOrCreateBucket(std::string_view InBucket) // We create the bucket without holding a lock since contructor calls GcManager::AddGcReferencer which takes an exclusive lock. // This can cause a deadlock, if GC is running we would block while holding ZenCacheDiskLayer::m_Lock - std::unique_ptr Bucket(std::make_unique(m_Gc, m_TotalMemCachedSize, InBucket, m_Configuration.BucketConfig)); + BucketConfiguration* BucketConfig = &m_Configuration.BucketConfig; + if (auto It = m_Configuration.BucketConfigMap.find_as(InBucket, + std::hash(), + eastl::equal_to_2()); + It != m_Configuration.BucketConfigMap.end()) + { + BucketConfig = &It->second; + } + std::unique_ptr Bucket(std::make_unique(m_Gc, m_TotalMemCachedSize, InBucket, *BucketConfig)); RwLock::ExclusiveLockScope Lock(m_Lock); if (auto It = m_Buckets.find_as(InBucket, std::hash(), eastl::equal_to_2()); @@ -3944,8 +3952,17 @@ ZenCacheDiskLayer::DiscoverBuckets() const std::string BucketName = PathToUtf8(BucketPath.stem()); try { + BucketConfiguration* BucketConfig = &m_Configuration.BucketConfig; + if (auto It = m_Configuration.BucketConfigMap.find_as(std::string_view(BucketName), + std::hash(), + eastl::equal_to_2()); + It != m_Configuration.BucketConfigMap.end()) + { + BucketConfig = &It->second; + } + std::unique_ptr NewBucket = - std::make_unique(m_Gc, m_TotalMemCachedSize, BucketName, m_Configuration.BucketConfig); + std::make_unique(m_Gc, m_TotalMemCachedSize, BucketName, *BucketConfig); CacheBucket* Bucket = nullptr; { -- cgit v1.2.3