aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/cache/cachedisklayer.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2024-09-30 09:27:36 +0200
committerGitHub Enterprise <[email protected]>2024-09-30 09:27:36 +0200
commit54ee1372c4254e185e83c8eb9329ace9704664c6 (patch)
treea766c6bb340db9e26fe23247da7c5fce1fe39395 /src/zenstore/cache/cachedisklayer.cpp
parentFixing compilation errors with fmt v11 (#172) (diff)
downloadzen-54ee1372c4254e185e83c8eb9329ace9704664c6.tar.xz
zen-54ee1372c4254e185e83c8eb9329ace9704664c6.zip
optimize startup time (#175)
* use tsl::robin_set for BlockIndexSet don't calculate full block location when only block index is needed * don't copy visitor function * reserve space for attachments
Diffstat (limited to 'src/zenstore/cache/cachedisklayer.cpp')
-rw-r--r--src/zenstore/cache/cachedisklayer.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/zenstore/cache/cachedisklayer.cpp b/src/zenstore/cache/cachedisklayer.cpp
index a4aa497c4..3fc4eca03 100644
--- a/src/zenstore/cache/cachedisklayer.cpp
+++ b/src/zenstore/cache/cachedisklayer.cpp
@@ -1136,8 +1136,8 @@ ZenCacheDiskLayer::CacheBucket::InitializeIndexFromDisk(RwLock::ExclusiveLockSco
}
else
{
- const BlockStoreLocation& BlockLocation = Location.GetBlockLocation(m_Configuration.PayloadAlignment);
- KnownBlocks.Add(BlockLocation.BlockIndex);
+ uint32_t BlockIndex = Location.Location.BlockLocation.GetBlockIndex();
+ KnownBlocks.insert(BlockIndex);
}
}
m_BlockStore.SyncExistingBlocksOnDisk(KnownBlocks);
@@ -3649,6 +3649,7 @@ ZenCacheDiskLayer::CacheBucket::GetReferences(GcCtx& Ctx, bool StateIsAlreadyLoc
{
continue;
}
+
const IoHash& Key = Entry.first;
if (Loc.IsFlagSet(DiskLocation::kStandaloneFile))
{
@@ -3672,7 +3673,10 @@ ZenCacheDiskLayer::CacheBucket::GetReferences(GcCtx& Ctx, bool StateIsAlreadyLoc
}
}
- for (std::vector<std::size_t> ChunkIndexes : InlineBlockChunkIndexes)
+ OutReferences.reserve(OutReferences.size() + InlineKeys.size() +
+ StandaloneKeys.size()); // Make space for at least one attachment per record
+
+ for (const std::vector<std::size_t>& ChunkIndexes : InlineBlockChunkIndexes)
{
ZEN_ASSERT(!ChunkIndexes.empty());
@@ -3694,12 +3698,15 @@ ZenCacheDiskLayer::CacheBucket::GetReferences(GcCtx& Ctx, bool StateIsAlreadyLoc
auto CaptureAttachments = [&](size_t ChunkIndex, MemoryView Data) {
if (GetAttachments(Data))
{
- size_t AttachmentCount = OutReferences.size() - NextPrecachedReferencesStart;
- if (WriteMetaData && AttachmentCount > 0)
+ if (WriteMetaData)
{
- Keys.push_back(InlineKeys[ChunkIndex]);
- AttachmentCounts.push_back(gsl::narrow<uint32_t>(AttachmentCount));
- NextPrecachedReferencesStart += AttachmentCount;
+ size_t AttachmentCount = OutReferences.size() - NextPrecachedReferencesStart;
+ if (AttachmentCount > 0)
+ {
+ Keys.push_back(InlineKeys[ChunkIndex]);
+ AttachmentCounts.push_back(gsl::narrow<uint32_t>(AttachmentCount));
+ NextPrecachedReferencesStart += AttachmentCount;
+ }
}
}
};