MCPcopy Create free account
hub / github.com/catboost/catboost / CgroupV1Cpus

Function CgroupV1Cpus

util/system/info.cpp:55–73  ·  view source on GitHub ↗

This function olny works properly if you apply correct setting to your nanny/deploy project In nanny - Runtime -> Instance spec -> Advanced settings -> Cgroupfs settings: Mount mode = Read only In deploy - Stage - Edit stage - Box - Cgroupfs settings: Mount mode = Read only */

Source from the content-addressed store, hash-verified

53In deploy - Stage - Edit stage - Box - Cgroupfs settings: Mount mode = Read only
54*/
55static inline double CgroupV1Cpus(const TString& cpuCfsQuotaUsPath, const TString& cfsPeriodUsPath) {
56 try {
57 double q = FromString<int32_t>(StripString(TFileInput(cpuCfsQuotaUsPath).ReadAll()));
58
59 if (q <= 0) {
60 return 0;
61 }
62
63 double p = FromString<int32_t>(StripString(TFileInput(cfsPeriodUsPath).ReadAll()));
64
65 if (p <= 0) {
66 return 0;
67 }
68
69 return q / p;
70 } catch (...) {
71 return 0;
72 }
73}
74
75/*
76In cgroups v2 there isn't a dedicated "cpu" directory under /sys/fs/cgroup,

Callers 1

CgroupCpusFunction · 0.85

Calls 3

StripStringFunction · 0.85
ReadAllMethod · 0.80
TFileInputClass · 0.50

Tested by

no test coverage detected