Skip to content

Commit

Permalink
[rqd] Fix use of hyperthreadingMultiplier. (#1013)
Browse files Browse the repository at this point in the history
  • Loading branch information
splhack committed Dec 4, 2021
1 parent a05b90a commit d4b790f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 8 additions & 3 deletions rqd/rqd/rqmachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def getLoadAvg(self):
loadAvgFile = open(rqd.rqconstants.PATH_LOADAVG, "r")
loadAvg = int(float(loadAvgFile.read().split()[0]) * 100)
if self.__enabledHT():
loadAvg = loadAvg // 2
loadAvg = loadAvg // self.__getHyperthreadingMultiplier()
loadAvg = loadAvg + rqd.rqconstants.LOAD_MODIFIER
loadAvg = max(loadAvg, 0)
return loadAvg
Expand Down Expand Up @@ -549,7 +549,7 @@ def __initMachineStats(self, pathCpuInfo=None):
self.__renderHost.num_procs = __numProcs
self.__renderHost.cores_per_proc = __totalCores // __numProcs

if hyperthreadingMultiplier > 1:
if hyperthreadingMultiplier >= 1:
self.__renderHost.attributes['hyperthreadingMultiplier'] = str(hyperthreadingMultiplier)

def getWindowsMemory(self):
Expand Down Expand Up @@ -684,6 +684,9 @@ def getBootReport(self):
def __enabledHT(self):
return 'hyperthreadingMultiplier' in self.__renderHost.attributes

def __getHyperthreadingMultiplier(self):
return int(self.__renderHost.attributes['hyperthreadingMultiplier'])

def setupHT(self):
""" Setup rqd for hyper-threading """

Expand Down Expand Up @@ -719,11 +722,13 @@ def reserveHT(self, reservedCores):
log.critical(err)
raise rqd.rqexceptions.CoreReservationFailureException(err)

hyperthreadingMultiplier = self.__getHyperthreadingMultiplier()
tasksets = []
for _ in range(reservedCores // 100):
core = self.__tasksets.pop()
tasksets.append(str(core))
tasksets.append(str(core + self.__coreInfo.total_cores // 100))
if hyperthreadingMultiplier > 1:
tasksets.append(str(core + self.__coreInfo.total_cores // 100))

log.debug('Taskset: Reserving cores - %s', ','.join(tasksets))

Expand Down
3 changes: 3 additions & 0 deletions rqd/tests/rqmachine_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ def test_getLoadAvg(self):

@mock.patch.object(
rqd.rqmachine.Machine, '_Machine__enabledHT', new=mock.MagicMock(return_value=True))
@mock.patch.object(
rqd.rqmachine.Machine, '_Machine__getHyperthreadingMultiplier',
new=mock.MagicMock(return_value=2))
def test_getLoadAvgHT(self):
self.loadavg.set_contents(LOADAVG_HIGH_USAGE)

Expand Down

0 comments on commit d4b790f

Please sign in to comment.