diff options
| author | Dan Engelbrecht <[email protected]> | 2023-10-03 13:31:02 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-03 13:31:02 +0200 |
| commit | 68a72b68592c416969bd36f413eb2b2762b9fcff (patch) | |
| tree | 9a5fc28eb9040f010c92f86a1745f9418dfc91ca /src/zenstore/filecas.cpp | |
| parent | clean up date formatting (#440) (diff) | |
| download | zen-68a72b68592c416969bd36f413eb2b2762b9fcff.tar.xz zen-68a72b68592c416969bd36f413eb2b2762b9fcff.zip | |
faster accesstime save restore (#439)
- Improvement: Reduce time a cache bucket is locked for write when flushing/garbage collecting
- Change format for faster read/write and reduced size on disk
- Don't lock index while writing manifest to disk
- Skip garbage collect if we are currently in a Flush operation
- BlockStore::Flush no longer terminates currently writing block
- Garbage collect references to currently writing block but keep the block as new data may be added
- Fix BlockStore::Prune used disk space calculation
- Don't materialize data in filecas when we just need the size
Diffstat (limited to 'src/zenstore/filecas.cpp')
| -rw-r--r-- | src/zenstore/filecas.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/zenstore/filecas.cpp b/src/zenstore/filecas.cpp index 0d742d7e1..fe568a487 100644 --- a/src/zenstore/filecas.cpp +++ b/src/zenstore/filecas.cpp @@ -795,6 +795,21 @@ FileCasStrategy::IterateChunks(std::function<void(const IoHash& Hash, IoBuffer&& } void +FileCasStrategy::IterateChunks(std::function<void(const IoHash& Hash, uint64_t Size)>&& Callback) +{ + ZEN_TRACE_CPU("FileCas::IterateChunks"); + + ZEN_ASSERT(m_IsInitialized); + + RwLock::SharedLockScope _(m_Lock); + for (const auto& It : m_Index) + { + const IoHash& NameHash = It.first; + Callback(NameHash, It.second.Size); + } +} + +void FileCasStrategy::Flush() { ZEN_TRACE_CPU("FileCas::Flush"); @@ -927,7 +942,7 @@ FileCasStrategy::CollectGarbage(GcContext& GcCtx) { ZEN_TRACE_CPU("FileCas::CollectGarbage::Filter"); - IterateChunks([&](const IoHash& Hash, IoBuffer&& Payload) { + IterateChunks([&](const IoHash& Hash, uint64_t Size) { bool KeepThis = false; CandidateCas[0] = Hash; GcCtx.FilterCids(CandidateCas, [&](const IoHash& Hash) { @@ -935,16 +950,14 @@ FileCasStrategy::CollectGarbage(GcContext& GcCtx) KeepThis = true; }); - const uint64_t FileSize = Payload.GetSize(); - if (!KeepThis) { ChunksToDelete.push_back(Hash); - ChunksToDeleteBytes.fetch_add(FileSize); + ChunksToDeleteBytes.fetch_add(Size); } ++ChunkCount; - ChunkBytes.fetch_add(FileSize); + ChunkBytes.fetch_add(Size); }); } |