aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--zenserver/cache/structuredcachestore.cpp26
-rw-r--r--zenstore/cas.cpp5
2 files changed, 18 insertions, 13 deletions
diff --git a/zenserver/cache/structuredcachestore.cpp b/zenserver/cache/structuredcachestore.cpp
index de5bccc3a..cf066fb0e 100644
--- a/zenserver/cache/structuredcachestore.cpp
+++ b/zenserver/cache/structuredcachestore.cpp
@@ -249,11 +249,9 @@ ZenCacheMemoryLayer::Put(std::string_view InBucket, const IoHash& HashKey, const
{
RwLock::SharedLockScope _(m_Lock);
- auto it = m_Buckets.find(std::string(InBucket));
-
- if (it != m_Buckets.end())
+ if (auto It = m_Buckets.find(std::string(InBucket)); It != m_Buckets.end())
{
- Bucket = &it->second;
+ Bucket = &It->second;
}
}
@@ -263,7 +261,14 @@ ZenCacheMemoryLayer::Put(std::string_view InBucket, const IoHash& HashKey, const
RwLock::ExclusiveLockScope _(m_Lock);
- Bucket = &m_Buckets[std::string(InBucket)];
+ if (auto It = m_Buckets.find(std::string(InBucket)); It != m_Buckets.end())
+ {
+ Bucket = &It->second;
+ }
+ else
+ {
+ Bucket = &m_Buckets[std::string(InBucket)];
+ }
}
// Note that since the underlying IoBuffer is retained, the content type is also
@@ -757,7 +762,7 @@ ZenCacheDiskLayer::CacheBucket::GatherReferences(GcContext& GcCtx)
const GcClock::Tick ExpireTicks = ExpireTime.time_since_epoch().count();
- RwLock::ExclusiveLockScope _(m_IndexLock);
+ RwLock::SharedLockScope _(m_IndexLock);
std::vector<IoHash> ValidKeys;
std::vector<IoHash> ExpiredKeys;
@@ -773,7 +778,7 @@ ZenCacheDiskLayer::CacheBucket::GatherReferences(GcContext& GcCtx)
return Entry.LastAccess < Ticks;
});
- Cids.reserve(Entries.size());
+ Cids.reserve(1024);
for (auto Kv = ValidIt; Kv != Entries.end(); ++Kv)
{
@@ -791,10 +796,13 @@ ZenCacheDiskLayer::CacheBucket::GatherReferences(GcContext& GcCtx)
if (CacheValue.Value)
{
ZEN_ASSERT(CacheValue.Value.GetContentType() == ZenContentType::kCbObject);
-
+ if (Cids.size() > 1024)
+ {
+ GcCtx.ContributeCids(Cids);
+ Cids.clear();
+ }
CbObject Obj(SharedBuffer{CacheValue.Value});
Obj.IterateAttachments([&Cids](CbFieldView Field) { Cids.push_back(Field.AsAttachment()); });
- GcCtx.ContributeCids(Cids);
}
}
}
diff --git a/zenstore/cas.cpp b/zenstore/cas.cpp
index 7b58111db..a90e45c04 100644
--- a/zenstore/cas.cpp
+++ b/zenstore/cas.cpp
@@ -39,10 +39,7 @@ CasChunkSet::AddChunkToSet(const IoHash& HashToAdd)
void
CasChunkSet::AddChunksToSet(std::span<const IoHash> HashesToAdd)
{
- for (const IoHash& Hash : HashesToAdd)
- {
- m_ChunkSet.insert(Hash);
- }
+ m_ChunkSet.insert(HashesToAdd.begin(), HashesToAdd.end());
}
void