Bug 617259 - Optimize build prioritization. r=rail
authorChris AtLee <catlee@mozilla.com>
Tue, 07 Dec 2010 09:33:18 -0500
changeset 3359 45fbfd1a794c40eee97f36cd156c04eec8b0836e
parent 3357 27f10622e0dc8e4bb6db43fd0b5f54a1b7b43544
child 3360 00ff5cf919bd57077e48dee31089b3b5ac8722d6
child 3361 3125d448b58773c7099a56989c4b7950ad4ea561
push id1
push userroot
push dateWed, 17 Dec 2014 00:18:48 +0000
reviewersrail
bugs617259
Bug 617259 - Optimize build prioritization. r=rail
mozilla-tests/tests_master.cfg
mozilla-tests/universal_master_sqlite.cfg
mozilla/builder_master.cfg
mozilla/master_common.py
mozilla/universal_master_sqlite.cfg
--- a/mozilla-tests/tests_master.cfg
+++ b/mozilla-tests/tests_master.cfg
@@ -54,34 +54,11 @@ import passwords
 reload(passwords)
 from passwords import BBDB_URL
 c['db_url'] = BBDB_URL
 c['db_poll_interval'] = 60
 c['multiMaster'] = True
 
 c['mergeRequests'] = buildbotcustom.misc.mergeRequests
 
-# Give the release builders highest priority, then all branches priority over try
-def prioritizeBuilders(botmaster, builders):
-    def sortkey(builder):
-        builds = builder.getBuildable()
-        if builds:
-            req_priority = -builds[0].priority
-            submitted_at = builds[0].submittedAt
-        else:
-            req_priority = 0
-            submitted_at = None
-
-        if builder.builder_status.category.endswith('-release'):
-            priority = 0
-        elif builder.builder_status.category == 'tryserver':
-            priority = 2
-        else:
-            priority = 1
-
-        return priority, req_priority, submitted_at
-    builders.sort(key=sortkey)
-    return builders
-c['prioritizeBuilders'] = prioritizeBuilders
-
 # c is shorthand for BuildmasterConfig, so make sure they still refer to the
 # same thing
 assert c is BuildmasterConfig
--- a/mozilla-tests/universal_master_sqlite.cfg
+++ b/mozilla-tests/universal_master_sqlite.cfg
@@ -47,34 +47,11 @@ for branch in ACTIVE_BRANCHES:
 # Required for sendchange
 from buildbot.changes.pb import PBChangeSource
 c['change_source'].append(PBChangeSource())
 
 c['db_url'] = "sqlite:///state.sqlite"
 
 c['mergeRequests'] = buildbotcustom.misc.mergeRequests
 
-# Give the release builders highest priority, then all branches priority over try
-def prioritizeBuilders(botmaster, builders):
-    def sortkey(builder):
-        builds = builder.getBuildable()
-        if builds:
-            req_priority = -builds[0].priority
-            submitted_at = builds[0].submittedAt
-        else:
-            req_priority = 0
-            submitted_at = None
-
-        if builder.builder_status.category.endswith('-release'):
-            priority = 0
-        elif builder.builder_status.category == 'tryserver':
-            priority = 2
-        else:
-            priority = 1
-
-        return priority, req_priority, submitted_at
-    builders.sort(key=sortkey)
-    return builders
-c['prioritizeBuilders'] = prioritizeBuilders
-
 # c is shorthand for BuildmasterConfig, so make sure they still refer to the
 # same thing
 assert c is BuildmasterConfig
--- a/mozilla/builder_master.cfg
+++ b/mozilla/builder_master.cfg
@@ -78,36 +78,11 @@ import passwords
 reload(passwords)
 from passwords import BBDB_URL
 c['db_url'] = BBDB_URL
 c['db_poll_interval'] = 60
 c['multiMaster'] = True
 
 c['mergeRequests'] = buildbotcustom.misc.mergeRequests
 
-# Give the release builders priority over other builders
-def prioritizeBuilders(botmaster, builders):
-    def sortkey(builder):
-        builds = builder.getBuildable()
-        if builds:
-            # The builder that gets sorted first, gets run first, but the build
-            # request priorities are in ascending order (higher priority gets
-            # run next), so flip the sign of the priority so that higher
-            # priorities sort to the front
-            req_priority = -builds[0].priority
-            submitted_at = builds[0].submittedAt
-        else:
-            req_priority = 0
-            submitted_at = None
-
-        if builder.builder_status.category.startswith('release'):
-            priority = 0
-        else:
-            priority = 1
-
-        return priority, req_priority, submitted_at
-    builders.sort(key=sortkey)
-    return builders
-c['prioritizeBuilders'] = prioritizeBuilders
-
 # c is shorthand for BuildmasterConfig, so make sure they still refer to the
 # same thing
 assert c is BuildmasterConfig
--- a/mozilla/master_common.py
+++ b/mozilla/master_common.py
@@ -8,8 +8,35 @@ c['eventHorizon'] = 20
 c['buildCacheSize'] = 10
 c['changeCacheSize'] = 10000
 
 c['status'] = []
 c['slaves'] = []
 c['builders'] = []
 c['schedulers'] = []
 c['change_source'] = []
+
+# Give the release builders priority over other builders
+def prioritizeBuilders(botmaster, builders):
+    def sortkey(builder):
+        builds = builder.getBuildable(1)
+        if builds:
+            # The builder that gets sorted first, gets run first, but the build
+            # request priorities are in ascending order (higher priority gets
+            # run next), so flip the sign of the priority so that higher
+            # priorities sort to the front
+            req_priority = -builds[0].priority
+            submitted_at = builds[0].submittedAt
+        else:
+            req_priority = 0
+            submitted_at = None
+
+        if builder.builder_status.category.startswith('release'):
+            priority = 0
+        elif builder.builder_status.category.startswith('try'):
+            priority = 2
+        else:
+            priority = 1
+
+        return priority, req_priority, submitted_at
+    builders.sort(key=sortkey)
+    return builders
+c['prioritizeBuilders'] = prioritizeBuilders
--- a/mozilla/universal_master_sqlite.cfg
+++ b/mozilla/universal_master_sqlite.cfg
@@ -72,36 +72,11 @@ if ENABLE_RELEASES:
         from buildbot.changes.pb import PBChangeSource
         if len([cs for cs in c['change_source'] if isinstance(cs, PBChangeSource)]) < 1:
             c['change_source'].append(PBChangeSource())
 
 c['db_url'] = "sqlite:///state.sqlite"
 
 c['mergeRequests'] = buildbotcustom.misc.mergeRequests
 
-# Give the release builders priority over other builders
-def prioritizeBuilders(botmaster, builders):
-    def sortkey(builder):
-        builds = builder.getBuildable()
-        if builds:
-            # The builder that gets sorted first, gets run first, but the build
-            # request priorities are in ascending order (higher priority gets
-            # run next), so flip the sign of the priority so that higher
-            # priorities sort to the front
-            req_priority = -builds[0].priority
-            submitted_at = builds[0].submittedAt
-        else:
-            req_priority = 0
-            submitted_at = None
-
-        if builder.builder_status.category == 'release':
-            priority = 0
-        else:
-            priority = 1
-
-        return priority, req_priority, submitted_at
-    builders.sort(key=sortkey)
-    return builders
-c['prioritizeBuilders'] = prioritizeBuilders
-
 # c is shorthand for BuildmasterConfig, so make sure they still refer to the
 # same thing
 assert c is BuildmasterConfig