aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-10-24 23:10:06 +0200
committerGitHub Enterprise <[email protected]>2025-10-24 23:10:06 +0200
commit6d96e791f9bb8cd25cbdb1c3fecfcaad9fff6a20 (patch)
tree150ec308a9ec64966a8f0effb4fa1361099b617a
parentoptimize blockstore filesize (#612) (diff)
downloadzen-6d96e791f9bb8cd25cbdb1c3fecfcaad9fff6a20.tar.xz
zen-6d96e791f9bb8cd25cbdb1c3fecfcaad9fff6a20.zip
optimize filecas write file (#613)
* try to move file into place before trying speculative remove of target file
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/zenstore/cache/cachedisklayer.cpp26
2 files changed, 11 insertions, 16 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b38929888..d908048c9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,7 @@
- `--zen-cache-host` specifies a Zenserver cache host that overrides any host discovery
- Improvement: If gc disk usage log file is corrupt, remove and restart the log
- Improvement: Optimized file size check if currently written CAS block file
+- Improvement: Remove speculative RemoveFile call when saving large blobs in CAS store
- Bugfix: Add quotes around messages when using `--log-progress` with `zen builds` commands
- Bugfix: Fix ASSERT after running `zen workspace info` on a non-existing workspace. UE-349934
- Bugfix: Fixed issue where GC could start after shutdown of GC had been requested causing a race
diff --git a/src/zenstore/cache/cachedisklayer.cpp b/src/zenstore/cache/cachedisklayer.cpp
index c2e811003..67f587a7c 100644
--- a/src/zenstore/cache/cachedisklayer.cpp
+++ b/src/zenstore/cache/cachedisklayer.cpp
@@ -2724,14 +2724,19 @@ ZenCacheDiskLayer::CacheBucket::PutStandaloneCacheValue(const IoHash& HashKey, c
RwLock::ExclusiveLockScope ValueLock(LockForHash(HashKey));
- // We do a speculative remove of the file instead of probing with a exists call and check the error code instead
- RemoveFile(FsPath, Ec);
+ // Assume parent directory exists
+ DataFile.MoveTemporaryIntoPlace(FsPath, Ec);
if (Ec)
{
- if (Ec.value() != ENOENT)
+ CreateDirectories(FsPath.parent_path());
+
+ // Try again after we or someone else created the directory
+ Ec.clear();
+ DataFile.MoveTemporaryIntoPlace(FsPath, Ec);
+
+ if (Ec)
{
- ZEN_WARN("Failed to remove file '{}' for put in '{}', reason: '{}', retrying.", FsPath, m_BucketDir, Ec.message());
- Sleep(100);
+ // We do a speculative remove of the file instead of probing with a exists call and check the error code instead
Ec.clear();
RemoveFile(FsPath, Ec);
if (Ec && Ec.value() != ENOENT)
@@ -2739,17 +2744,6 @@ ZenCacheDiskLayer::CacheBucket::PutStandaloneCacheValue(const IoHash& HashKey, c
throw std::system_error(Ec, fmt::format("Failed to remove file '{}' for put in '{}'", FsPath, m_BucketDir));
}
}
- }
-
- // Assume parent directory exists
- DataFile.MoveTemporaryIntoPlace(FsPath, Ec);
- if (Ec)
- {
- CreateDirectories(FsPath.parent_path());
-
- // Try again after we or someone else created the directory
- Ec.clear();
- DataFile.MoveTemporaryIntoPlace(FsPath, Ec);
// Retry if we still fail to handle contention to file system
uint32_t RetriesLeft = 3;