aboutsummaryrefslogtreecommitdiff
path: root/zenserver/cache/structuredcachestore.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-04-12 14:19:05 +0200
committerDan Engelbrecht <[email protected]>2022-04-12 22:20:47 +0200
commitb0e81cd90b705c27bc94f0aa9bdf73eeadccc164 (patch)
tree8bbc4344cfc443a1817e9c506fa5b32e1de6b1b7 /zenserver/cache/structuredcachestore.cpp
parentAdd z$.threadedinsert test (diff)
downloadzen-b0e81cd90b705c27bc94f0aa9bdf73eeadccc164.tar.xz
zen-b0e81cd90b705c27bc94f0aa9bdf73eeadccc164.zip
Make sure we generate unique chunks
Diffstat (limited to 'zenserver/cache/structuredcachestore.cpp')
-rw-r--r--zenserver/cache/structuredcachestore.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/zenserver/cache/structuredcachestore.cpp b/zenserver/cache/structuredcachestore.cpp
index 0ce473e89..9ae01c5df 100644
--- a/zenserver/cache/structuredcachestore.cpp
+++ b/zenserver/cache/structuredcachestore.cpp
@@ -270,9 +270,9 @@ SaveCompactBinaryObject(const fs::path& Path, const CbObject& Object)
}
ZenCacheStore::ZenCacheStore(CasGc& Gc, const std::filesystem::path& RootDir)
-: m_RootDir(RootDir)
-, GcStorage(Gc)
+: GcStorage(Gc)
, GcContributor(Gc)
+, m_RootDir(RootDir)
, m_DiskLayer(RootDir)
{
ZEN_INFO("initializing structured cache at '{}'", RootDir);
@@ -2104,7 +2104,7 @@ ZenCacheDiskLayer::CacheBucket::CollectGarbage(GcContext& GcCtx)
if (!NewBlockFile || (WriteOffset + Chunk.size() > MaxBlockSize))
{
- uint32_t NextBlockIndex = m_WriteBlockIndex.load(std::memory_order::memory_order_relaxed);
+ uint32_t NextBlockIndex = m_WriteBlockIndex.load(std::memory_order_relaxed);
std::vector<DiskIndexEntry> LogEntries = MakeDiskIndexEntries(MovedBlockChunks, {});
m_SlogFile.Append(LogEntries);
m_SlogFile.Flush();
@@ -3127,15 +3127,28 @@ TEST_CASE("z$.threadedinsert") // * doctest::skip(true))
for (int32_t Idx = 0; Idx < kChunkCount; ++Idx)
{
+
+ while(true)
{
IoBuffer Chunk = testutils::CreateBinaryCacheValue(kChunkSize);
IoHash Hash = HashBuffer(Chunk);
+ if (Chunks.contains(Hash))
+ {
+ continue;
+ }
Chunks[Hash] = {.Bucket = Bucket1, .Buffer = Chunk};
+ break;
}
+ while(true)
{
IoBuffer Chunk = testutils::CreateBinaryCacheValue(kChunkSize);
IoHash Hash = HashBuffer(Chunk);
+ if (Chunks.contains(Hash))
+ {
+ continue;
+ }
Chunks[Hash] = {.Bucket = Bucket2, .Buffer = Chunk};
+ break;
}
}
@@ -3144,7 +3157,6 @@ TEST_CASE("z$.threadedinsert") // * doctest::skip(true))
WorkerThreadPool ThreadPool(4);
CasGc Gc;
ZenCacheStore Zcs(Gc, TempDir.Path());
- const GcClock::TimePoint CurrentTime = GcClock::Now();
{
for (const auto& Chunk : Chunks)
@@ -3160,7 +3172,7 @@ TEST_CASE("z$.threadedinsert") // * doctest::skip(true))
const uint64_t TotalSize = Zcs.StorageSize().DiskSize;
CHECK_EQ(kChunkSize * Chunks.size(), TotalSize);
- {
+ {
for (const auto& Chunk : Chunks)
{
ThreadPool.ScheduleWork([&Zcs, &Chunk]() {