added job-manager-timeslice-ms, job-use-overflow-time configs

This commit is contained in:
Darren Ranalli 2007-04-25 21:11:44 +00:00
parent 35290754c9
commit 645fd746a4

View File

@ -30,6 +30,7 @@ class JobManager:
# how much time did the job use beyond the allotted timeslice, used to balance # how much time did the job use beyond the allotted timeslice, used to balance
# out CPU usage # out CPU usage
self._jobId2overflowTime = {} self._jobId2overflowTime = {}
self._useOverflowTime = None
# this is a generator that we use to give high-priority jobs more timeslices # this is a generator that we use to give high-priority jobs more timeslices
self._jobIdGenerator = None self._jobIdGenerator = None
self._highestPriority = Job.Priorities.Normal self._highestPriority = Job.Priorities.Normal
@ -123,7 +124,7 @@ class JobManager:
@staticmethod @staticmethod
def getDefaultTimeslice(): def getDefaultTimeslice():
# run for 1/2 millisecond per frame by default # run for 1/2 millisecond per frame by default
return getBase().config.GetFloat('job-manager-timeslice', (1./1000.) * .5) return getBase().config.GetFloat('job-manager-timeslice-ms', .5) / 1000.
def getTimeslice(self): def getTimeslice(self):
if self._timeslice: if self._timeslice:
return self._timeslice return self._timeslice
@ -138,6 +139,8 @@ class JobManager:
return priorities return priorities
def _process(self, task=None): def _process(self, task=None):
if self._useOverflowTime is None:
self._useOverflowTime = config.GetBool('job-use-overflow-time', 1)
if len(self._pri2jobId2job): if len(self._pri2jobId2job):
#assert self.notify.debugCall() #assert self.notify.debugCall()
# figure out how long we can run # figure out how long we can run
@ -160,13 +163,14 @@ class JobManager:
# this job is no longer present # this job is no longer present
continue continue
# check if there's overflow time that we need to make up for # check if there's overflow time that we need to make up for
overflowTime = self._jobId2overflowTime[jobId] if self._useOverflowTime:
timeLeft = endT - globalClock.getRealTime() overflowTime = self._jobId2overflowTime[jobId]
if overflowTime >= timeLeft: timeLeft = endT - globalClock.getRealTime()
self._jobId2overflowTime[jobId] = max(0., overflowTime-timeLeft) if overflowTime >= timeLeft:
# don't run any more jobs this frame, this makes up self._jobId2overflowTime[jobId] = max(0., overflowTime-timeLeft)
# for the extra overflow time that was used before # don't run any more jobs this frame, this makes up
break # for the extra overflow time that was used before
break
job = self._pri2jobId2job[pri][jobId] job = self._pri2jobId2job[pri][jobId]
gen = job._getGenerator() gen = job._getGenerator()
if __debug__: if __debug__: