diff options
| author | Dan Engelbrecht <[email protected]> | 2025-10-27 11:17:36 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-10-27 11:17:36 +0100 |
| commit | 91e085f7caa9c384d8dab781e9b29ce0d70f6626 (patch) | |
| tree | c0ced6e0e825b5074d3012b037fc20847e22a513 /src/zenstore/include | |
| parent | use already built lookup when verifying folder (#615) (diff) | |
| download | zen-91e085f7caa9c384d8dab781e9b29ce0d70f6626.tar.xz zen-91e085f7caa9c384d8dab781e9b29ce0d70f6626.zip | |
optimize blockstore flush (#614)
* rework block store block flushing to only happen once at end of block write outside of locks
* fix warning at startup if no gc.dlog file exists
Diffstat (limited to 'src/zenstore/include')
| -rw-r--r-- | src/zenstore/include/zenstore/blockstore.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/zenstore/include/zenstore/blockstore.h b/src/zenstore/include/zenstore/blockstore.h index 4006f4275..bc9b5da40 100644 --- a/src/zenstore/include/zenstore/blockstore.h +++ b/src/zenstore/include/zenstore/blockstore.h @@ -94,7 +94,7 @@ struct BlockStoreFile : public RefCounted IoBuffer GetChunk(uint64_t Offset, uint64_t Size); void Read(void* Data, uint64_t Size, uint64_t FileOffset); void Write(const void* Data, uint64_t Size, uint64_t FileOffset); - void Flush(uint64_t FinalSize = (uint64_t)-1); + void Flush(); BasicFile& GetBasicFile(); void StreamByteRange(uint64_t FileOffset, uint64_t Size, std::function<void(const void* Data, uint64_t Size)>&& ChunkFun); bool IsOpen() const; @@ -186,17 +186,21 @@ public: IoBuffer GetMetaData(uint32_t BlockIndex) const; private: + void AddActiveWriteBlock(RwLock::ExclusiveLockScope& Lock, uint32_t BlockIndex); + void RemoveActiveWriteBlock(uint32_t BlockIndex); + static const char* GetBlockFileExtension(); static std::filesystem::path GetBlockPath(const std::filesystem::path& BlocksBasePath, const uint32_t BlockIndex); uint32_t GetFreeBlockIndex(uint32_t StartProbeIndex, RwLock::ExclusiveLockScope&, std::filesystem::path& OutBlockPath) const; tsl::robin_map<uint32_t, Ref<BlockStoreFile>> m_ChunkBlocks; - mutable RwLock m_InsertLock; // used to serialize inserts - Ref<BlockStoreFile> m_WriteBlock; - std::uint32_t m_CurrentInsertOffset = 0; - std::atomic_uint32_t m_WriteBlockIndex{}; - std::vector<uint32_t> m_ActiveWriteBlocks; + mutable RwLock m_InsertLock; // used to serialize inserts + Ref<BlockStoreFile> m_WriteBlock; + std::uint32_t m_CurrentInsertOffset = 0; + std::atomic_uint32_t m_WriteBlockIndex{}; + eastl::fixed_vector<uint32_t, 2> m_ActiveWriteBlocks; + eastl::fixed_vector<uint32_t, 2> m_BlocksToFlush; uint64_t m_MaxBlockSize = 1u << 28; uint64_t m_MaxBlockCount = BlockStoreDiskLocation::MaxBlockIndex + 1; |