aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/include
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2024-06-04 19:30:34 +0200
committerGitHub Enterprise <[email protected]>2024-06-04 19:30:34 +0200
commitbbe46452530a98a0bd36c0024d4f3f914ae23604 (patch)
treee9c901a6ec68d087bc7e746b38d1573b2999a0ef /src/zenstore/include
parentUse a smaller thread pool for network operations when doing oplog import to r... (diff)
downloadzen-bbe46452530a98a0bd36c0024d4f3f914ae23604.tar.xz
zen-bbe46452530a98a0bd36c0024d4f3f914ae23604.zip
add batching of CacheStore requests for GetCacheValues/GetCacheChunks (#90)
* cache file size of block on open * add ability to control size limit for small chunk callback when iterating block * Add batch fetch of cache values in the GetCacheValues request
Diffstat (limited to 'src/zenstore/include')
-rw-r--r--src/zenstore/include/zenstore/blockstore.h4
-rw-r--r--src/zenstore/include/zenstore/cache/cachedisklayer.h32
-rw-r--r--src/zenstore/include/zenstore/cache/structuredcachestore.h39
3 files changed, 56 insertions, 19 deletions
diff --git a/src/zenstore/include/zenstore/blockstore.h b/src/zenstore/include/zenstore/blockstore.h
index a1e497533..ba8259c82 100644
--- a/src/zenstore/include/zenstore/blockstore.h
+++ b/src/zenstore/include/zenstore/blockstore.h
@@ -107,6 +107,7 @@ private:
const std::filesystem::path m_Path;
IoBuffer m_IoBuffer;
BasicFile m_File;
+ uint64_t m_CachedFileSize = 0;
};
class BlockStoreCompactState;
@@ -183,7 +184,8 @@ public:
bool IterateBlock(std::span<const BlockStoreLocation> ChunkLocations,
std::span<const size_t> ChunkIndexes,
const IterateChunksSmallSizeCallback& SmallSizeCallback,
- const IterateChunksLargeSizeCallback& LargeSizeCallback);
+ const IterateChunksLargeSizeCallback& LargeSizeCallback,
+ uint64_t LargeSizeLimit = 0);
void CompactBlocks(
const BlockStoreCompactState& CompactState,
diff --git a/src/zenstore/include/zenstore/cache/cachedisklayer.h b/src/zenstore/include/zenstore/cache/cachedisklayer.h
index 427c338d6..9dee4d3f7 100644
--- a/src/zenstore/include/zenstore/cache/cachedisklayer.h
+++ b/src/zenstore/include/zenstore/cache/cachedisklayer.h
@@ -164,16 +164,21 @@ public:
explicit ZenCacheDiskLayer(GcManager& Gc, JobQueue& JobQueue, const std::filesystem::path& RootDir, const Configuration& Config);
~ZenCacheDiskLayer();
- struct BatchHandle;
- BatchHandle* BeginPutBatch(std::vector<bool>& OutResult);
- void EndPutBatch(BatchHandle* Batch) noexcept;
+ struct GetBatchHandle;
+ GetBatchHandle* BeginGetBatch(std::vector<ZenCacheValue>& OutResult);
+ void EndGetBatch(GetBatchHandle* Batch) noexcept;
+ bool Get(std::string_view Bucket, const IoHash& HashKey, ZenCacheValue& OutValue);
+ void Get(std::string_view Bucket, const IoHash& HashKey, GetBatchHandle& BatchHandle);
+
+ struct PutBatchHandle;
+ PutBatchHandle* BeginPutBatch(std::vector<bool>& OutResult);
+ void EndPutBatch(PutBatchHandle* Batch) noexcept;
- bool Get(std::string_view Bucket, const IoHash& HashKey, ZenCacheValue& OutValue);
void Put(std::string_view Bucket,
const IoHash& HashKey,
const ZenCacheValue& Value,
std::span<IoHash> References,
- BatchHandle* OptionalBatchHandle);
+ PutBatchHandle* OptionalBatchHandle);
bool Drop();
bool DropBucket(std::string_view Bucket);
void Flush();
@@ -205,12 +210,17 @@ public:
~CacheBucket();
bool OpenOrCreate(std::filesystem::path BucketDir, bool AllowCreate = true);
- struct BatchHandle;
- BatchHandle* BeginPutBatch(std::vector<bool>& OutResult);
- void EndPutBatch(BatchHandle* Batch) noexcept;
- bool Get(const IoHash& HashKey, ZenCacheValue& OutValue);
- void Put(const IoHash& HashKey, const ZenCacheValue& Value, std::span<IoHash> References, BatchHandle* OptionalBatchHandle);
+ struct GetBatchHandle;
+ GetBatchHandle* BeginGetBatch(std::vector<ZenCacheValue>& OutResult);
+ void EndGetBatch(GetBatchHandle* Batch) noexcept;
+ bool Get(const IoHash& HashKey, ZenCacheValue& OutValue);
+ void Get(const IoHash& HashKey, GetBatchHandle& BatchHandle);
+
+ struct PutBatchHandle;
+ PutBatchHandle* BeginPutBatch(std::vector<bool>& OutResult);
+ void EndPutBatch(PutBatchHandle* Batch) noexcept;
+ void Put(const IoHash& HashKey, const ZenCacheValue& Value, std::span<IoHash> References, PutBatchHandle* OptionalBatchHandle);
uint64_t MemCacheTrim(GcClock::TimePoint ExpireTime);
bool Drop();
void Flush();
@@ -342,7 +352,7 @@ public:
void PutInlineCacheValue(const IoHash& HashKey,
const ZenCacheValue& Value,
std::span<IoHash> References,
- BatchHandle* OptionalBatchHandle = nullptr);
+ PutBatchHandle* OptionalBatchHandle = nullptr);
IoBuffer GetInlineCacheValue(const DiskLocation& Loc) const;
CacheValueDetails::ValueDetails GetValueDetails(RwLock::SharedLockScope&, const IoHash& Key, PayloadIndex Index) const;
diff --git a/src/zenstore/include/zenstore/cache/structuredcachestore.h b/src/zenstore/include/zenstore/cache/structuredcachestore.h
index 02bbeed77..7460d01ce 100644
--- a/src/zenstore/include/zenstore/cache/structuredcachestore.h
+++ b/src/zenstore/include/zenstore/cache/structuredcachestore.h
@@ -80,16 +80,21 @@ public:
ZenCacheNamespace(GcManager& Gc, JobQueue& JobQueue, const std::filesystem::path& RootDir, const Configuration& Config);
~ZenCacheNamespace();
- struct BatchHandle;
- BatchHandle* BeginPutBatch(std::vector<bool>& OutResults);
- void EndPutBatch(BatchHandle* Batch) noexcept;
+ struct PutBatchHandle;
+ PutBatchHandle* BeginPutBatch(std::vector<bool>& OutResults);
+ void EndPutBatch(PutBatchHandle* Batch) noexcept;
+
+ struct GetBatchHandle;
+ GetBatchHandle* BeginGetBatch(std::vector<ZenCacheValue>& OutResults);
+ void EndGetBatch(GetBatchHandle* Batch) noexcept;
bool Get(std::string_view Bucket, const IoHash& HashKey, ZenCacheValue& OutValue);
+ void Get(std::string_view Bucket, const IoHash& HashKey, GetBatchHandle& OptionalBatchHandle);
void Put(std::string_view Bucket,
const IoHash& HashKey,
const ZenCacheValue& Value,
std::span<IoHash> References,
- BatchHandle* OptionalBatchHandle = nullptr);
+ PutBatchHandle* OptionalBatchHandle = nullptr);
bool DropBucket(std::string_view Bucket);
void EnumerateBucketContents(std::string_view Bucket,
@@ -199,10 +204,24 @@ public:
~PutBatch();
private:
- ZenCacheStore& m_CacheStore;
- ZenCacheNamespace* m_Store = nullptr;
- ZenCacheNamespace::BatchHandle* m_NamespaceBatchHandle = nullptr;
+ ZenCacheStore& m_CacheStore;
+ ZenCacheNamespace* m_Store = nullptr;
+ ZenCacheNamespace::PutBatchHandle* m_NamespaceBatchHandle = nullptr;
+
+ friend class ZenCacheStore;
+ };
+
+ class GetBatch
+ {
+ public:
+ GetBatch(ZenCacheStore& CacheStore, std::string_view Namespace, std::vector<ZenCacheValue>& OutResult);
+ ~GetBatch();
+ private:
+ ZenCacheStore& m_CacheStore;
+ ZenCacheNamespace* m_Store = nullptr;
+ ZenCacheNamespace::GetBatchHandle* m_NamespaceBatchHandle = nullptr;
+ std::vector<ZenCacheValue>& Results;
friend class ZenCacheStore;
};
@@ -212,6 +231,12 @@ public:
const IoHash& HashKey,
ZenCacheValue& OutValue);
+ void Get(const CacheRequestContext& Context,
+ std::string_view Namespace,
+ std::string_view Bucket,
+ const IoHash& HashKey,
+ GetBatch& BatchHandle);
+
void Put(const CacheRequestContext& Context,
std::string_view Namespace,
std::string_view Bucket,