diff options
| author | Dan Engelbrecht <[email protected]> | 2024-10-02 10:08:46 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-10-02 10:08:46 +0200 |
| commit | 0b86039ebbbce0138790f9039189dddb4b70b73a (patch) | |
| tree | e3deda42d154cb779ff8ab3dd29d04a5dc4069f0 /src/zenstore/include | |
| parent | Porject -> Project (diff) | |
| download | zen-0b86039ebbbce0138790f9039189dddb4b70b73a.tar.xz zen-0b86039ebbbce0138790f9039189dddb4b70b73a.zip | |
gc block size target max size (#180)
* If a block is small (less than half max size) we add it to blocks to compact
Sort blocks when iterating over them
* do compact of block stores even if no new unused are found
* do compact phase even if bucket is empty
Diffstat (limited to 'src/zenstore/include')
| -rw-r--r-- | src/zenstore/include/zenstore/blockstore.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/zenstore/include/zenstore/blockstore.h b/src/zenstore/include/zenstore/blockstore.h index 5af9aeb10..a98ca5375 100644 --- a/src/zenstore/include/zenstore/blockstore.h +++ b/src/zenstore/include/zenstore/blockstore.h @@ -265,10 +265,19 @@ public: const std::vector<size_t>& KeepChunkIndexes, const std::vector<BlockStoreLocation>& ChunkLocations)> Callback) const { + std::vector<uint32_t> BlockOrder; + BlockOrder.reserve(m_BlockIndexToChunkMapIndex.size()); for (auto It : m_BlockIndexToChunkMapIndex) { - size_t ChunkMapIndex = It.second; - bool Continue = Callback(It.first, m_KeepChunks[ChunkMapIndex], m_ChunkLocations); + BlockOrder.push_back(It.first); + } + std::sort(BlockOrder.begin(), BlockOrder.end()); + for (uint32_t BlockIndex : BlockOrder) + { + auto It = m_BlockIndexToChunkMapIndex.find(BlockIndex); + ZEN_ASSERT(It != m_BlockIndexToChunkMapIndex.end()); + size_t ChunkMapIndex = It->second; + bool Continue = Callback(BlockIndex, m_KeepChunks[ChunkMapIndex], m_ChunkLocations); if (!Continue) { break; |