aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/blockstore.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/blockstore.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/blockstore.cpp')
-rw-r--r--src/zenstore/blockstore.cpp20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/zenstore/blockstore.cpp b/src/zenstore/blockstore.cpp
index 7c6677052..592d1c7fb 100644
--- a/src/zenstore/blockstore.cpp
+++ b/src/zenstore/blockstore.cpp
@@ -331,17 +331,7 @@ BlockStore::Initialize(const std::filesystem::path& BlocksBasePath, uint64_t Max
}
void
-BlockStore::BlockIndexSet::Add(uint32_t BlockIndex)
-{
- if (!std::binary_search(begin(BlockIndexes), end(BlockIndexes), BlockIndex))
- {
- auto It = std::lower_bound(begin(BlockIndexes), end(BlockIndexes), BlockIndex);
- BlockIndexes.insert(It, BlockIndex);
- }
-}
-
-void
-BlockStore::SyncExistingBlocksOnDisk(const BlockIndexSet& KnownLocations)
+BlockStore::SyncExistingBlocksOnDisk(const BlockIndexSet& KnownBlocks)
{
ZEN_TRACE_CPU("BlockStore::SyncExistingBlocksOnDisk");
@@ -355,7 +345,7 @@ BlockStore::SyncExistingBlocksOnDisk(const BlockIndexSet& KnownLocations)
DeleteBlocks.insert(It.first);
}
- for (const uint32_t BlockIndex : KnownLocations.GetBlockIndices())
+ for (const uint32_t BlockIndex : KnownBlocks)
{
DeleteBlocks.erase(BlockIndex);
if (auto It = m_ChunkBlocks.find(BlockIndex); It != m_ChunkBlocks.end() && !It->second.IsNull())
@@ -1968,9 +1958,9 @@ TEST_CASE("blockstore.clean.stray.blocks")
// Recreate a fake block for a missing chunk location
BlockStore::BlockIndexSet KnownBlocks;
- KnownBlocks.Add(FirstChunkLocation.BlockIndex);
- KnownBlocks.Add(SecondChunkLocation.BlockIndex);
- KnownBlocks.Add(ThirdChunkLocation.BlockIndex);
+ KnownBlocks.insert(FirstChunkLocation.BlockIndex);
+ KnownBlocks.insert(SecondChunkLocation.BlockIndex);
+ KnownBlocks.insert(ThirdChunkLocation.BlockIndex);
Store.SyncExistingBlocksOnDisk(KnownBlocks);
// We create a fake block for the location - we should still not be able to get the chunk