From 922b512ee0d58f74e66e348b000d613921ad9ecd Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Sun, 5 Apr 2026 19:33:14 +0200 Subject: defer bundle creation to legacy upload path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bundle creation is now lazy — it only runs when an agent actually needs the legacy WriteFiles/ReadBlob protocol. When all agents support CompressedFileTransfer, no bundles are created at all. --- src/zenhorde/hordeprovisioner.cpp | 51 +++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/zenhorde/hordeprovisioner.cpp b/src/zenhorde/hordeprovisioner.cpp index 79dacf57e..825f78c78 100644 --- a/src/zenhorde/hordeprovisioner.cpp +++ b/src/zenhorde/hordeprovisioner.cpp @@ -146,14 +146,10 @@ HordeProvisioner::ThreadAgent(AgentWrapper& Wrapper) auto $ = MakeGuard([&] { m_EstimatedCoreCount.fetch_sub(EstimatedCoresPerAgent); }); { - ZEN_TRACE_CPU("HordeProvisioner::CreateBundles"); - std::lock_guard BundleLock(m_BundleLock); - if (!m_BundlesCreated) + if (m_BinaryFiles.empty()) { - const std::filesystem::path OutputDir = m_WorkingDir / "horde_bundles"; - #if ZEN_PLATFORM_WINDOWS m_BinaryFiles.push_back({m_BinariesPath / "zenserver.exe", false}); #elif ZEN_PLATFORM_LINUX @@ -162,23 +158,6 @@ HordeProvisioner::ThreadAgent(AgentWrapper& Wrapper) #elif ZEN_PLATFORM_MAC m_BinaryFiles.push_back({m_BinariesPath / "zenserver", false}); #endif - - std::vector BundleFiles; - for (const BinaryFileEntry& Entry : m_BinaryFiles) - { - BundleFiles.emplace_back(Entry.Path, Entry.Optional); - } - - BundleResult Result; - if (!BundleCreator::CreateBundle(BundleFiles, OutputDir, Result)) - { - ZEN_WARN("failed to create bundle, cannot provision any agents!"); - m_AskForAgents.store(false); - return; - } - - m_Bundles.emplace_back(Result.Locator, Result.BundleDir); - m_BundlesCreated = true; } if (!m_HordeClient) @@ -303,7 +282,33 @@ HordeProvisioner::ThreadAgent(AgentWrapper& Wrapper) } else { - // Legacy bundle upload + // Legacy bundle upload — create bundles lazily on first use + { + std::lock_guard BundleLock(m_BundleLock); + if (!m_BundlesCreated) + { + ZEN_TRACE_CPU("HordeProvisioner::CreateBundles"); + + const std::filesystem::path OutputDir = m_WorkingDir / "horde_bundles"; + + std::vector BundleFiles; + for (const BinaryFileEntry& Entry : m_BinaryFiles) + { + BundleFiles.emplace_back(Entry.Path, Entry.Optional); + } + + BundleResult Result; + if (!BundleCreator::CreateBundle(BundleFiles, OutputDir, Result)) + { + ZEN_WARN("failed to create bundle, cannot provision any agents!"); + return; + } + + m_Bundles.emplace_back(Result.Locator, Result.BundleDir); + m_BundlesCreated = true; + } + } + for (auto& [Locator, BundleDir] : m_Bundles) { if (Wrapper.ShouldExit.load()) -- cgit v1.2.3