netrender: usage based balancer. more useful than credits
authorMartin Poirier <theeth@yahoo.com>
Thu, 24 Sep 2009 21:05:54 +0000 (21:05 +0000)
committerMartin Poirier <theeth@yahoo.com>
Thu, 24 Sep 2009 21:05:54 +0000 (21:05 +0000)
release/io/netrender/balancing.py
release/io/netrender/master.py
release/io/netrender/master_html.py
release/io/netrender/model.py

index c167594..372ea7d 100644 (file)
@@ -64,7 +64,13 @@ class Balancer:
 
 class RatingCredit(RatingRule):
        def rate(self, job):
-               return -job.credits * job.priority # more credit is better (sort at first in list)
+               # more credit is better (sort at first in list)
+               return -job.credits * job.priority
+
+class RatingUsage(RatingRule):
+       def rate(self, job):
+               # less usage is better
+               return job.usage / job.priority
 
 class NewJobPriority(PriorityRule):
        def __init__(self, limit = 1):
index 8a0b043..1202b94 100644 (file)
@@ -45,12 +45,12 @@ class MRenderJob(netrender.model.RenderJob):
                self.frames = []
                self.chunks = chunks
                self.priority = priority
+               self.usage = 0.0
                self.credits = credits
                self.blacklist = blacklist
                self.last_dispatched = time.time()
        
                # special server properties
-               self.usage = 0.0
                self.last_update = 0
                self.save_path = ""
                self.files_map = {path: MRenderFile(path, start, end) for path, start, end in files}
@@ -603,9 +603,10 @@ class RenderMasterServer(http.server.HTTPServer):
                self.first_usage = True
                
                self.balancer = netrender.balancing.Balancer()
-               self.balancer.addRule(netrender.balancing.RatingCredit())
+               #self.balancer.addRule(netrender.balancing.RatingCredit())
+               self.balancer.addRule(netrender.balancing.RatingUsage())
                self.balancer.addException(netrender.balancing.ExcludeQueuedEmptyJob())
-               self.balancer.addException(netrender.balancing.ExcludeSlavesLimit(self.countJobs, self.countSlaves))
+               self.balancer.addException(netrender.balancing.ExcludeSlavesLimit(self.countJobs, self.countSlaves, limit = 0.9))
                self.balancer.addPriority(netrender.balancing.NewJobPriority())
                self.balancer.addPriority(netrender.balancing.MinimumTimeBetweenDispatchPriority(limit = 2))
                
index bafc0f4..7513971 100644 (file)
@@ -52,22 +52,36 @@ def get(handler):
                output("<h2>Jobs</h2>")
                
                startTable()
-               headerTable("name", "credits", "usage", "time since last", "length", "done", "dispatched", "error", "priority", "exception")
+               headerTable(    
+                                                                       "name",
+                                                                       "priority",
+                                                                       "credits",
+                                                                       "usage",
+                                                                       "wait",
+                                                                       "length",
+                                                                       "done",
+                                                                       "dispatched",
+                                                                       "error",
+                                                                       "first",
+                                                                       "exception"
+                                                               )
 
                handler.server.update()
                
                for job in handler.server.jobs:
                        results = job.framesStatus()
-                       rowTable(       link(job.name, "/html/job" + job.id),
+                       rowTable(       
+                                                               link(job.name, "/html/job" + job.id),
+                                                               job.priority,
                                                                round(job.credits, 1),
                                                                "%0.1f%%" % (job.usage * 100),
-                                                               int(time.time() - job.last_dispatched),
+                                                               "%is" % int(time.time() - job.last_dispatched),
                                                                len(job),
                                                                results[DONE],
                                                                results[DISPATCHED],
                                                                results[ERROR],
                                                                handler.server.balancer.applyPriorities(job), handler.server.balancer.applyExceptions(job)
-                                                               )
+                                                       )
                
                endTable()
                
index 9cacfb5..91a7c8a 100644 (file)
@@ -81,6 +81,7 @@ class RenderJob:
                self.chunks = 0
                self.priority = 0
                self.credits = 0
+               self.usage = 0.0
                self.blacklist = []
                self.last_dispatched = 0.0
        
@@ -143,6 +144,7 @@ class RenderJob:
                                                        "frames": [f.serialize() for f in self.frames if not frames or f in frames],
                                                        "chunks": self.chunks,
                                                        "priority": self.priority,
+                                                       "usage": self.usage,
                                                        "credits": self.credits,
                                                        "blacklist": self.blacklist,
                                                        "last_dispatched": self.last_dispatched
@@ -160,6 +162,7 @@ class RenderJob:
                job.frames = [RenderFrame.materialize(f) for f in data["frames"]]
                job.chunks = data["chunks"]
                job.priority = data["priority"]
+               job.usage = data["usage"]
                job.credits = data["credits"]
                job.blacklist = data["blacklist"]
                job.last_dispatched = data["last_dispatched"]