aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2024-10-09 09:40:59 +0200
committerGitHub Enterprise <[email protected]>2024-10-09 09:40:59 +0200
commit2ca4e1c088b6726d44c6f475ff1106374444b1a2 (patch)
tree9d1239c09adac8d21b85a5db8f9b209c23825399 /src
parentremove temporary workaround involving _LIBCPP_DISABLE_AVAILABILITY (#191) (diff)
downloadzen-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')
-rw-r--r--src/zenstore/blockstore.cpp24
-rw-r--r--src/zenstore/cache/cachedisklayer.cpp3
2 files changed, 14 insertions, 13 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];
diff --git a/src/zenstore/cache/cachedisklayer.cpp b/src/zenstore/cache/cachedisklayer.cpp
index 8a2de34e2..9161905d7 100644
--- a/src/zenstore/cache/cachedisklayer.cpp
+++ b/src/zenstore/cache/cachedisklayer.cpp
@@ -1503,7 +1503,8 @@ ZenCacheDiskLayer::CacheBucket::EndGetBatch(GetBatchHandle* Batch) noexcept
{
ZEN_TRACE_CPU("Z$::Bucket::EndGetBatch::ReadInline");
m_BlockStore.IterateChunks(InlineBlockLocations, [&](uint32_t, std::span<const size_t> ChunkIndexes) -> bool {
- const uint64_t LargeChunkSizeLimit = Max(m_Configuration.MemCacheSizeThreshold, 32u * 1024u);
+ // Only read into memory the IoBuffers we could potentially add to memcache
+ const uint64_t LargeChunkSizeLimit = Max(m_Configuration.MemCacheSizeThreshold, 1u * 1024u);
m_BlockStore.IterateBlock(
InlineBlockLocations,
ChunkIndexes,