// Copyright Epic Games, Inc. All Rights Reserved. #include #include #include #include #include ////////////////////////////////////////////////////////////////////////// namespace zen { TransferThreadWorkers::TransferThreadWorkers(bool InBoostWorkers, bool InSingleThreaded) : BoostWorkers(InBoostWorkers) , SingleThreaded(InSingleThreaded) { if (SingleThreaded) { m_NetworkPool = &GetSyncWorkerPool(); m_IOPool = &GetSyncWorkerPool(); WorkersInfo = "Not using thread workers for network or I/O, expect no progress reporting"; } else { unsigned int Cores = GetHardwareConcurrency(); if (BoostWorkers) { // Cores Net Disk // 2 4 3 // 4 6 3 // 8 11 6 // 16 16 12 // 32 16 24 // 64 16 32 // n 16 32 unsigned int NetworkThreadCount = Cores + (Cores / 4u) + Max(1u, (Cores / 8u)); NetworkThreadCount = Min(NetworkThreadCount, 16u); NetworkThreadCount = Max(NetworkThreadCount, 4u); unsigned int IOThreadCount = Cores - (Cores / 4u); IOThreadCount = Min(IOThreadCount, 32u); IOThreadCount = Max(IOThreadCount, 3u); m_NetworkPoolInstance = std::make_unique(NetworkThreadCount, "net"); m_IOPoolInstance = std::make_unique(IOThreadCount, "disk"); WorkersInfo = fmt::format("Worker boost enabled, using {} network threads and {} worker/IO threads", NetworkThreadCount, IOThreadCount); } else { // Cores Net Disk // 2 2 2 // 4 3 2 // 8 5 4 // 16 10 9 // 32 12 18 // 64 12 20 // n 12 20 unsigned int NetworkThreadCount = (Cores / 2u) + Max(1u, (Cores / 8u)); NetworkThreadCount = Min(NetworkThreadCount, 12u); NetworkThreadCount = Max(NetworkThreadCount, 2u); unsigned int IOThreadCount = Cores / 2u + Cores / 16u; IOThreadCount = Min(IOThreadCount, 20u); IOThreadCount = Max(IOThreadCount, 2u); m_NetworkPoolInstance = std::make_unique(NetworkThreadCount, "net"); m_IOPoolInstance = std::make_unique(IOThreadCount, "disk"); WorkersInfo = fmt::format("Using {} network threads and {} worker/IO threads", NetworkThreadCount, IOThreadCount); } m_NetworkPool = m_NetworkPoolInstance.get(); m_IOPool = m_IOPoolInstance.get(); } } } // namespace zen