diff options
| author | Dan Engelbrecht <[email protected]> | 2025-09-22 14:59:42 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-09-22 14:59:42 +0200 |
| commit | ca2fd94c1a6098a6b7d44c5e9882862df2cc5ce8 (patch) | |
| tree | 64d13f243ad9290ca73329f325a8c7bb1a4ec9a0 | |
| parent | Added `--oidctoken-exe-unattended` to`zen builds` and `zen oplog-download` co... (diff) | |
| download | zen-ca2fd94c1a6098a6b7d44c5e9882862df2cc5ce8.tar.xz zen-ca2fd94c1a6098a6b7d44c5e9882862df2cc5ce8.zip | |
more responsive cancel during oplog import (#505)
- Improvement: Faster oplog import due to chunk existance check improvement
- Improvement: Cancelling oplog import is now more responsive during initial phase
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | src/zenserver/projectstore/remoteprojectstore.cpp | 18 | ||||
| -rw-r--r-- | src/zenstore/blockstore.cpp | 13 | ||||
| -rw-r--r-- | src/zenstore/include/zenstore/blockstore.h | 12 |
4 files changed, 33 insertions, 12 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index d0ff7b3d3..96b7bba5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,8 @@ - Improvement: `zen command` help now uses available horizontal space for output - Improvement: Partial block request analisys has been improved with reduced download size at lower number of requests - Improvement: Validate that `--zen-cache-host` exists and is responsive before begin used +- Improvement: Faster oplog import due to chunk existance check improvement +- Improvement: Cancelling oplog import is now more responsive during initial phase - Feature: Options `--allow-partial-block-requests` for `zen builds download` command has been augmented with two new modes, `zencacheonly` and `mixed`. Defaults to `mixed`. - `false` only full block requests allowed - `mixed` multiple partial block ranges requests per block allowed to zen cache, single partial block range request per block to host diff --git a/src/zenserver/projectstore/remoteprojectstore.cpp b/src/zenserver/projectstore/remoteprojectstore.cpp index 911628386..e61ccd917 100644 --- a/src/zenserver/projectstore/remoteprojectstore.cpp +++ b/src/zenserver/projectstore/remoteprojectstore.cpp @@ -2743,6 +2743,12 @@ ParseOplogContainer(const CbObject& ContainerObject, NiceBytes(Chunked.RawSize), Chunked.ChunkHashes.size()); } + if (remotestore_impl::IsCancelled(OptionalContext)) + { + return RemoteProjectStore::Result{.ErrorCode = gsl::narrow<int>(HttpResponseCode::OK), + .ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.0, + .Reason = "Operation cancelled"}; + } } size_t NeedBlockCount = 0; @@ -2787,6 +2793,12 @@ ParseOplogContainer(const CbObject& ContainerObject, NeedBlockCount++; } } + if (remotestore_impl::IsCancelled(OptionalContext)) + { + return RemoteProjectStore::Result{.ErrorCode = gsl::narrow<int>(HttpResponseCode::OK), + .ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.0, + .Reason = "Operation cancelled"}; + } } remotestore_impl::ReportMessage(OptionalContext, fmt::format("Requesting {} of {} attachment blocks", NeedBlockCount, BlocksArray.Num())); @@ -2801,6 +2813,12 @@ ParseOplogContainer(const CbObject& ContainerObject, OnNeedAttachment(AttachmentHash); NeedAttachmentCount++; } + if (remotestore_impl::IsCancelled(OptionalContext)) + { + return RemoteProjectStore::Result{.ErrorCode = gsl::narrow<int>(HttpResponseCode::OK), + .ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.0, + .Reason = "Operation cancelled"}; + } }; remotestore_impl::ReportMessage(OptionalContext, fmt::format("Requesting {} of {} large attachments", NeedAttachmentCount, LargeChunksArray.Num())); diff --git a/src/zenstore/blockstore.cpp b/src/zenstore/blockstore.cpp index c50f2bb13..b8fa03305 100644 --- a/src/zenstore/blockstore.cpp +++ b/src/zenstore/blockstore.cpp @@ -121,6 +121,12 @@ BlockStoreFile::FileSize() const { return 0; } + uint64_t Expected = 0; + if (!m_CachedFileSize.compare_exchange_strong(Expected, Size)) + { + // Force a new check next time file size is fetched + m_CachedFileSize.store(0); + } return Size; } return m_CachedFileSize; @@ -153,13 +159,8 @@ void BlockStoreFile::Write(const void* Data, uint64_t Size, uint64_t FileOffset) { ZEN_TRACE_CPU("BlockStoreFile::Write"); -#if ZEN_BUILD_DEBUG - if (uint64_t CachedFileSize = m_CachedFileSize.load(); CachedFileSize > 0) - { - ZEN_ASSERT(FileOffset + Size <= CachedFileSize); - } -#endif // ZEN_BUILD_DEBUG m_File.Write(Data, Size, FileOffset); + m_CachedFileSize.store(0); } void diff --git a/src/zenstore/include/zenstore/blockstore.h b/src/zenstore/include/zenstore/blockstore.h index fce05766f..4006f4275 100644 --- a/src/zenstore/include/zenstore/blockstore.h +++ b/src/zenstore/include/zenstore/blockstore.h @@ -102,12 +102,12 @@ struct BlockStoreFile : public RefCounted IoBuffer GetMetaData() const; private: - std::filesystem::path GetMetaPath() const; - void RemoveMeta(); - const std::filesystem::path m_Path; - IoBuffer m_IoBuffer; - BasicFile m_File; - std::atomic<uint64_t> m_CachedFileSize = 0; + std::filesystem::path GetMetaPath() const; + void RemoveMeta(); + const std::filesystem::path m_Path; + IoBuffer m_IoBuffer; + BasicFile m_File; + mutable std::atomic<uint64_t> m_CachedFileSize = 0; }; class BlockStoreCompactState; |