From 727e6c4ada927604277dd644289fd9d0ca8a8063 Mon Sep 17 00:00:00 2001 From: Jake Smith Date: Wed, 27 Sep 2023 12:33:33 +0100 Subject: [PATCH] HPCC-30371 Round up cpus if fractional Signed-off-by: Jake Smith --- system/jlib/jdebug.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/system/jlib/jdebug.cpp b/system/jlib/jdebug.cpp index 934067258c3..bfdc95e9704 100644 --- a/system/jlib/jdebug.cpp +++ b/system/jlib/jdebug.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #ifdef _WIN32 #define DPSAPI_VERSION 1 @@ -1588,11 +1589,9 @@ void applyResourcedCPUAffinity(const IPropertyTree *resourceSection) double cpus = friendlyCPUToDecimal(cpusText); if (0.0 == cpus) throw makeStringExceptionV(0, "Invalid number of resources cpus: %s", cpusText); - unsigned __int64 cpusI = (unsigned __int64)cpus; + unsigned __int64 cpusI = (unsigned __int64)std::ceil(cpus); if (cpus != (double)cpusI) - OWARNLOG("Fractional number of CPUs '%s' specified can cause poor performance, rounding down to: %" I64F "u", cpusText, cpusI); - if (0 == cpusI) // if round down to 0 - cpusI = 1; + OWARNLOG("Fractional number of CPUs '%s' specified can cause poor performance, rounding up to: %" I64F "u", cpusText, cpusI); unsigned realAffinityCpus = evalAffinityCpus(); if (cpusI > realAffinityCpus) OWARNLOG("Attempting to set resourced cpu limit to %u, exceeds cpu affinity of %u", (unsigned)cpusI, realAffinityCpus);