aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/blockstore.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-10-24 22:51:50 +0200
committerGitHub Enterprise <[email protected]>2025-10-24 22:51:50 +0200
commitd9d7bc03dbb5b1331e4eeb24c38016292c0beebf (patch)
tree8b9b72556855b7e219a0495b7688502dcc784b67 /src/zenstore/blockstore.cpp
parent5.7.7-pre5 (diff)
downloadzen-d9d7bc03dbb5b1331e4eeb24c38016292c0beebf.tar.xz
zen-d9d7bc03dbb5b1331e4eeb24c38016292c0beebf.zip
optimize blockstore filesize (#612)
* since we only ever append to a block store file we don't need to actually flush the position
Diffstat (limited to 'src/zenstore/blockstore.cpp')
-rw-r--r--src/zenstore/blockstore.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/zenstore/blockstore.cpp b/src/zenstore/blockstore.cpp
index 0fee18420..337a5f8e0 100644
--- a/src/zenstore/blockstore.cpp
+++ b/src/zenstore/blockstore.cpp
@@ -163,7 +163,17 @@ BlockStoreFile::Write(const void* Data, uint64_t Size, uint64_t FileOffset)
ZEN_TRACE_CPU("BlockStoreFile::Write");
ZEN_ASSERT(Size + FileOffset <= m_IoBuffer.GetSize());
m_File.Write(Data, Size, FileOffset);
- m_CachedFileSize.store(0);
+
+ uint64_t NewSize = FileOffset + Size;
+ uint64_t CurrentSize = m_CachedFileSize.load();
+ while (NewSize > CurrentSize)
+ {
+ if (m_CachedFileSize.compare_exchange_strong(CurrentSize, NewSize))
+ {
+ break;
+ }
+ }
+ ZEN_ASSERT(m_CachedFileSize.load() >= NewSize);
}
void