diff options
| author | Dan Engelbrecht <[email protected]> | 2025-05-16 12:03:21 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-05-16 12:03:21 +0200 |
| commit | f3d794f2a8f8ae96760bcab4880d34c589250b6a (patch) | |
| tree | 4da325ef30788e399b017077ea7e589a56cb6013 /src/zen/cmds/builds_cmd.cpp | |
| parent | Merge pull request #396 from ue-foundation/zs/config-retention-8days (diff) | |
| download | archived-zen-f3d794f2a8f8ae96760bcab4880d34c589250b6a.tar.xz archived-zen-f3d794f2a8f8ae96760bcab4880d34c589250b6a.zip | |
sparse win file write (#398)
* Added `--use-sparse-files` option to `zen builds` command improving write performance of large files. Enabled by default.
Diffstat (limited to 'src/zen/cmds/builds_cmd.cpp')
| -rw-r--r-- | src/zen/cmds/builds_cmd.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/zen/cmds/builds_cmd.cpp b/src/zen/cmds/builds_cmd.cpp index c4a1344d4..117d0b291 100644 --- a/src/zen/cmds/builds_cmd.cpp +++ b/src/zen/cmds/builds_cmd.cpp @@ -95,6 +95,7 @@ namespace { const bool SingleThreaded = false; bool BoostWorkerThreads = false; + bool UseSparseFiles = false; WorkerThreadPool& GetIOWorkerPool() { @@ -4261,8 +4262,19 @@ namespace { ZEN_TRACE_CPU("WriteFileCache_WriteToFile_CacheWrite"); ZEN_ASSERT_SLOW(std::find(SeenTargetIndexes.begin(), SeenTargetIndexes.end(), TargetIndex) == SeenTargetIndexes.end()); - OutputFile = std::move(NewOutputFile); + OutputFile = std::move(NewOutputFile); + if (UseSparseFiles) + { + void* Handle = OutputFile->Handle(); + if (!PrepareFileForScatteredWrite(Handle, TargetFinalSize)) + { + ZEN_DEBUG("Unable to to prepare file '{}' with size {} for random write", + GetTargetPath(TargetIndex), + TargetFinalSize); + } + } OpenFileWriter = std::make_unique<BasicFileWriter>(*OutputFile, Min(TargetFinalSize, 256u * 1024u)); + OpenFileWriter->Write(Buffer, FileOffset); m_DiskStats.WriteCount++; m_DiskStats.WriteByteCount += Buffer.GetSize(); @@ -8858,6 +8870,12 @@ BuildsCommand::BuildsCommand() auto AddSystemOptions = [this](cxxopts::Options& Ops) { Ops.add_option("", "", "system-dir", "Specify system root", cxxopts::value(m_SystemRootDir), "<systemdir>"); + Ops.add_option("", + "", + "use-sparse-files", + "Enable use of sparse files when writing large files. Defaults to true.", + cxxopts::value(m_UseSparseFiles), + "<usesparsefiles>"); }; auto AddAuthOptions = [this](cxxopts::Options& Ops) { @@ -9872,6 +9890,7 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) }; BoostWorkerThreads = m_BoostWorkerThreads; + UseSparseFiles = m_UseSparseFiles; try { |