1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
// Copyright Epic Games, Inc. All Rights Reserved.
#include <zenremotestore/transferthreadworkers.h>
#include <zencore/intmath.h>
#include <zencore/logging.h>
#include <zencore/thread.h>
#include <zenutil/workerpools.h>
//////////////////////////////////////////////////////////////////////////
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<WorkerThreadPool>(NetworkThreadCount, "net");
m_IOPoolInstance = std::make_unique<WorkerThreadPool>(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<WorkerThreadPool>(NetworkThreadCount, "net");
m_IOPoolInstance = std::make_unique<WorkerThreadPool>(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
|