MCPcopy Create free account
hub / github.com/apple/foundationdb / updateProcessStats

Function updateProcessStats

fdbserver/RestoreRoleCommon.actor.cpp:80–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80void updateProcessStats(Reference<RestoreRoleData> self) {
81 if (g_network->isSimulated()) {
82 // memUsage and cpuUsage are not relevant in the simulator,
83 // and relying on the actual values could break seed determinism
84 if (deterministicRandom()->random01() < 0.2) { // not fully utilized cpu
85 self->cpuUsage = deterministicRandom()->random01() * SERVER_KNOBS->FASTRESTORE_SCHED_TARGET_CPU_PERCENT;
86 } else if (deterministicRandom()->random01() < 0.6) { // achieved target cpu but cpu is not busy
87 self->cpuUsage = SERVER_KNOBS->FASTRESTORE_SCHED_TARGET_CPU_PERCENT +
88 deterministicRandom()->random01() * (SERVER_KNOBS->FASTRESTORE_SCHED_MAX_CPU_PERCENT -
89 SERVER_KNOBS->FASTRESTORE_SCHED_TARGET_CPU_PERCENT);
90 } else { // reach desired max cpu usage; use max cpu as 200 to simulate incorrect cpu profiling
91 self->cpuUsage =
92 SERVER_KNOBS->FASTRESTORE_SCHED_MAX_CPU_PERCENT +
93 deterministicRandom()->random01() * (200 - SERVER_KNOBS->FASTRESTORE_SCHED_MAX_CPU_PERCENT);
94 }
95 self->memory = 100.0;
96 self->residentMemory = 100.0;
97 return;
98 }
99
100 SystemStatistics sysStats = getSystemStatistics();
101 if (sysStats.initialized) {
102 self->cpuUsage = 100 * sysStats.processCPUSeconds / sysStats.elapsed;
103 self->memory = sysStats.processMemory;
104 self->residentMemory = sysStats.processResidentMemory;
105 }
106}
107
108// An actor is schedulable to run if the current worker has enough resources, i.e.,
109// the worker's memory usage is below the threshold;

Callers 1

Calls 4

deterministicRandomFunction · 0.85
random01Method · 0.80
getSystemStatisticsFunction · 0.50
isSimulatedMethod · 0.45

Tested by

no test coverage detected