diff options
| author | Dan Engelbrecht <[email protected]> | 2024-10-09 09:40:59 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-10-09 09:40:59 +0200 |
| commit | 2ca4e1c088b6726d44c6f475ff1106374444b1a2 (patch) | |
| tree | 9d1239c09adac8d21b85a5db8f9b209c23825399 /src/zenstore/blockstore.cpp | |
| parent | remove temporary workaround involving _LIBCPP_DISABLE_AVAILABILITY (#191) (diff) | |
| download | zen-2ca4e1c088b6726d44c6f475ff1106374444b1a2.tar.xz zen-2ca4e1c088b6726d44c6f475ff1106374444b1a2.zip | |
don't read chunks into memory during cache batch fetch unless we may cache them in memory (#188)
* Don't read chunks into memory during cache batch fetch unless we may cache them in memory
Diffstat (limited to 'src/zenstore/blockstore.cpp')
| -rw-r--r-- | src/zenstore/blockstore.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/zenstore/blockstore.cpp b/src/zenstore/blockstore.cpp index 239b9e56b..8a6d9c18d 100644 --- a/src/zenstore/blockstore.cpp +++ b/src/zenstore/blockstore.cpp @@ -254,7 +254,6 @@ BlockStoreFile::GetMetaPath() const //////////////////////////////////////////////////////// constexpr uint64_t DefaultIterateSmallChunkWindowSize = 2 * 1024 * 1024; -constexpr uint64_t IterateSmallChunkMaxGapSize = 4 * 1024; BlockStore::BlockStore() { @@ -718,26 +717,27 @@ BlockStore::IterateBlock(std::span<const BlockStoreLocation> ChunkLocations, return true; } - uint64_t IterateSmallChunkWindowSize = Max(DefaultIterateSmallChunkWindowSize, LargeSizeLimit); - if (LargeSizeLimit == 0u) - { - LargeSizeLimit = IterateSmallChunkWindowSize; - } - else + if (LargeSizeLimit == 0) { - IterateSmallChunkWindowSize = - Min((LargeSizeLimit + IterateSmallChunkMaxGapSize) * ChunkLocations.size(), IterateSmallChunkWindowSize); + LargeSizeLimit = DefaultIterateSmallChunkWindowSize; } + uint64_t IterateSmallChunkWindowSize = Max(DefaultIterateSmallChunkWindowSize, LargeSizeLimit); + + const uint64_t IterateSmallChunkMaxGapSize = Max(2048u, IterateSmallChunkWindowSize / 512u); + + IterateSmallChunkWindowSize = Min((LargeSizeLimit + IterateSmallChunkMaxGapSize) * ChunkLocations.size(), IterateSmallChunkWindowSize); + uint32_t BlockIndex = ChunkLocations[InChunkIndexes[0]].BlockIndex; std::vector<size_t> ChunkIndexes(InChunkIndexes.begin(), InChunkIndexes.end()); std::sort(ChunkIndexes.begin(), ChunkIndexes.end(), [&](size_t IndexA, size_t IndexB) -> bool { return ChunkLocations[IndexA].Offset < ChunkLocations[IndexB].Offset; }); - auto GetNextRange = [LargeSizeLimit, IterateSmallChunkWindowSize, &ChunkLocations](uint64_t BlockFileSize, - std::span<const size_t> ChunkIndexes, - size_t StartIndexOffset) -> size_t { + auto GetNextRange = [LargeSizeLimit, + IterateSmallChunkWindowSize, + IterateSmallChunkMaxGapSize, + &ChunkLocations](uint64_t BlockFileSize, std::span<const size_t> ChunkIndexes, size_t StartIndexOffset) -> size_t { size_t ChunkCount = 0; size_t StartIndex = ChunkIndexes[StartIndexOffset]; const BlockStoreLocation& StartLocation = ChunkLocations[StartIndex]; |