def fitness(self, job, resource_conf): # Simply call fitness function from super class and add # queued time fitness value afterwards job_fitness = BestFitScheduler.fitness(self, job, resource_conf) self.logger.debug('fitness: %f without queue time', job_fitness) queue_time = time.mktime(time.gmtime())\ - time.mktime(job['QUEUED_TIMESTAMP']) expire_after = self.conf.expire_after if expire_after == 0: # No risk of expiry so we use pure aging job_fitness += queue_time * self.age_mult self.logger.debug('fitness: %f with queue time %f', job_fitness, queue_time) else: # Aging relies on risk of job expiry expire_risk = 1 - abs(expire_after - queue_time)\ / expire_after job_fitness += expire_risk * self.expire_mult # self.logger.level = 10 self.logger.debug('fitness: %f with expire risk %f', job_fitness, expire_risk) # self.logger.level = 20 return job_fitness
def fitness(self, job, resource_conf): # Simply call fitness function from super class and add # absolute and relative queue time fitness bonus afterwards job_fitness = BestFitScheduler.fitness(self, job, resource_conf) self.logger.debug('fitness: %f without time bonus', job_fitness) queue_time = time.mktime(time.gmtime()) - \ time.mktime(job['QUEUED_TIMESTAMP']) job_time = int(job.get('CPUTIME', 60)) # Force rel_bonus between 0 and 1 to avoid very short job "gaming" rel_bonus = 10.0 / max(job_time, 10) # Always apply a mix of absolute and relative aging job_fitness += self.age_mult * queue_time * (1 + rel_bonus) self.logger.debug('fitness: %f with queue / job time %f / %f (%f)', job_fitness, queue_time, job_time, rel_bonus) return job_fitness
def __init__(self, logger, config): BestFitScheduler.__init__(self, logger, config) self.name = 'FairFitScheduler'