Skip to content

Commit

Permalink
HPCC-30371 Round up cpus if fractional
Browse files Browse the repository at this point in the history
Signed-off-by: Jake Smith <[email protected]>
  • Loading branch information
jakesmith committed Sep 27, 2023
1 parent 9a9066c commit 727e6c4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions system/jlib/jdebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <stdio.h>
#include <time.h>
#include <atomic>
#include <cmath>

#ifdef _WIN32
#define DPSAPI_VERSION 1
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 727e6c4

Please sign in to comment.