diff options
author | Martin Poirier <theeth@yahoo.com> | 2009-09-21 20:01:31 +0400 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2009-09-21 20:01:31 +0400 |
commit | 34a9f423f8ab1debe78ae4d883bf6c4995d9e0ee (patch) | |
tree | fc524f65dc147a90a9c3f6e5f6bff26e23a15f51 /release | |
parent | 1e63545a3b6331b6c1d05a15c5dc48f4aa148f19 (diff) |
netrender: more load balancing rules
Diffstat (limited to 'release')
-rw-r--r-- | release/io/netrender/balancing.py | 23 | ||||
-rw-r--r-- | release/io/netrender/master.py | 13 | ||||
-rw-r--r-- | release/io/netrender/model.py | 5 |
3 files changed, 36 insertions, 5 deletions
diff --git a/release/io/netrender/balancing.py b/release/io/netrender/balancing.py index 89e1e3f7b06..62b6dcee519 100644 --- a/release/io/netrender/balancing.py +++ b/release/io/netrender/balancing.py @@ -64,12 +64,31 @@ class Balancer: class RatingCredit(RatingRule): def rate(self, job): - return -job.credits # more credit is better (sort at first in list) + return -job.credits * job.priority # more credit is better (sort at first in list) class NewJobPriority(PriorityRule): + def __init__(self, limit = 1): + self.limit = limit + + def test(self, job): + return job.countFrames(status = DISPATCHED) < self.limit + +class MinimumTimeBetweenDispatchPriority(PriorityRule): + def __init__(self, limit = 10): + self.limit = limit + def test(self, job): - return job.countFrames(status = DISPATCHED) == 0 + return (time.time() - job.last_dispatched) / 60 > self.limit class ExcludeQueuedEmptyJob(ExclusionRule): def test(self, job): return job.status != JOB_QUEUED or job.countFrames(status = QUEUED) == 0 + +class ExcludeSlavesLimit(ExclusionRule): + def __init__(self, count_jobs, count_slaves, limit = 0.75): + self.count_jobs = count_jobs + self.count_slaves = count_slaves + self.limit = limit + + def test(self, job): + return not ( self.count_jobs() == 1 or float(job.countSlaves() + 1) / self.count_slaves() <= self.limit )
\ No newline at end of file diff --git a/release/io/netrender/master.py b/release/io/netrender/master.py index 58c6c1b2d00..1bff5f6340b 100644 --- a/release/io/netrender/master.py +++ b/release/io/netrender/master.py @@ -575,7 +575,9 @@ class RenderMasterServer(http.server.HTTPServer): self.balancer = netrender.balancing.Balancer() self.balancer.addRule(netrender.balancing.RatingCredit()) self.balancer.addException(netrender.balancing.ExcludeQueuedEmptyJob()) + self.balancer.addException(netrender.balancing.ExcludeSlavesLimit(self.countJobs, self.countSlaves)) self.balancer.addPriority(netrender.balancing.NewJobPriority()) + self.balancer.addPriority(netrender.balancing.MinimumTimeBetweenDispatchPriority()) if not os.path.exists(self.path): os.mkdir(self.path) @@ -607,7 +609,18 @@ class RenderMasterServer(http.server.HTTPServer): def update(self): self.balancer.balance(self.jobs) + + def countJobs(self, status = JOB_QUEUED): + total = 0 + for j in self.jobs: + if j.status == status: + total += 1 + return total + + def countSlaves(self): + return len(self.slaves) + def removeJob(self, id): job = self.jobs_map.pop(id) diff --git a/release/io/netrender/model.py b/release/io/netrender/model.py index 9a6645e79cf..e8046d7ac8c 100644 --- a/release/io/netrender/model.py +++ b/release/io/netrender/model.py @@ -97,15 +97,14 @@ class RenderJob: def countFrames(self, status=QUEUED): total = 0 - for j in self.frames: - if j.status == status: + for f in self.frames: + if f.status == status: total += 1 return total def countSlaves(self): return len(set((frame.slave for frame in self.frames if frame.status == DISPATCHED))) - def framesStatus(self): results = { |