Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/buildbot_8_4p1/buildbot/process/builder.py

Issue 2415703004: Enable merging buildbot builds dependent on queue length (Closed)
Patch Set: Pass also number of merged builds Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « masters/master.client.v8/master.cfg ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # This file is part of Buildbot. Buildbot is free software: you can 1 # This file is part of Buildbot. Buildbot is free software: you can
2 # redistribute it and/or modify it under the terms of the GNU General Public 2 # redistribute it and/or modify it under the terms of the GNU General Public
3 # License as published by the Free Software Foundation, version 2. 3 # License as published by the Free Software Foundation, version 2.
4 # 4 #
5 # This program is distributed in the hope that it will be useful, but WITHOUT 5 # This program is distributed in the hope that it will be useful, but WITHOUT
6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
8 # details. 8 # details.
9 # 9 #
10 # You should have received a copy of the GNU General Public License along with 10 # You should have received a copy of the GNU General Public License along with
11 # this program; if not, write to the Free Software Foundation, Inc., 51 11 # this program; if not, write to the Free Software Foundation, Inc., 51
12 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 12 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
13 # 13 #
14 # Copyright Buildbot Team Members 14 # Copyright Buildbot Team Members
15 15
16 16
17 import random, weakref 17 import inspect, random, weakref
18 from zope.interface import implements 18 from zope.interface import implements
19 from twisted.python import log, failure 19 from twisted.python import log, failure
20 from twisted.spread import pb 20 from twisted.spread import pb
21 from twisted.application import service, internet 21 from twisted.application import service, internet
22 from twisted.internet import defer 22 from twisted.internet import defer
23 23
24 from buildbot import interfaces 24 from buildbot import interfaces
25 from buildbot.status.progress import Expectations 25 from buildbot.status.progress import Expectations
26 from buildbot.status.builder import RETRY 26 from buildbot.status.builder import RETRY
27 from buildbot.status.buildrequest import BuildRequestStatus 27 from buildbot.status.buildrequest import BuildRequestStatus
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 # we'll need BuildRequest objects, so get those first 846 # we'll need BuildRequest objects, so get those first
847 wfd = defer.waitForDeferred( 847 wfd = defer.waitForDeferred(
848 defer.gatherResults( 848 defer.gatherResults(
849 [ self._brdictToBuildRequest(brdict) 849 [ self._brdictToBuildRequest(brdict)
850 for brdict in unclaimed_requests ])) 850 for brdict in unclaimed_requests ]))
851 yield wfd 851 yield wfd
852 unclaimed_request_objects = wfd.getResult() 852 unclaimed_request_objects = wfd.getResult()
853 breq_object = unclaimed_request_objects.pop( 853 breq_object = unclaimed_request_objects.pop(
854 unclaimed_requests.index(breq)) 854 unclaimed_requests.index(breq))
855 855
856 # Make sure the merge-requests function can take the queue length. Old
tandrii(chromium) 2016/10/13 13:35:22 ...queue length and len(merged_requests).
Michael Achenbach 2016/10/13 13:53:35 wrote "lengths" now
857 # style functions only take two parameters.
858 mergeRequests_with_length_fn = lambda a, b, *_ : mergeRequests_fn(a, b)
tandrii(chromium) 2016/10/13 13:35:22 inspect on bound class functions or on functions w
Michael Achenbach 2016/10/13 13:53:35 Good catch. Now implemented your suggestion to use
859 try:
860 n_args = len(inspect.getargspec(mergeRequests_fn).args)
861 if n_args > 3:
862 # New style function that accepts total and merged parameters.
863 mergeRequests_with_length_fn = mergeRequests_fn
864 except Exception as e:
865 log.err(e, 'Exception analyzing mergeRequests function.')
866
867 # This might not reflect exact number of items that could be merged
868 # (this depends on the canBeMergedWith algorithm), but it can help
869 # indicating how loaded this builder is.
870 queue_length = len(unclaimed_request_objects)
871
856 # gather the mergeable requests 872 # gather the mergeable requests
857 merged_request_objects = [breq_object] 873 merged_request_objects = [breq_object]
858 for other_breq_object in unclaimed_request_objects: 874 for other_breq_object in unclaimed_request_objects:
859 wfd = defer.waitForDeferred( 875 wfd = defer.waitForDeferred(
860 defer.maybeDeferred(lambda : 876 defer.maybeDeferred(lambda :
861 mergeRequests_fn(breq_object, other_breq_object))) 877 mergeRequests_with_length_fn(
878 breq_object,
879 other_breq_object,
880 queue_length,
881 len(merged_request_objects),
882 )))
862 yield wfd 883 yield wfd
863 if wfd.getResult(): 884 if wfd.getResult():
864 merged_request_objects.append(other_breq_object) 885 merged_request_objects.append(other_breq_object)
865 886
866 # convert them back to brdicts and return 887 # convert them back to brdicts and return
867 merged_requests = [ br.brdict for br in merged_request_objects ] 888 merged_requests = [ br.brdict for br in merged_request_objects ]
868 yield merged_requests 889 yield merged_requests
869 890
870 def _brdictToBuildRequest(self, brdict): 891 def _brdictToBuildRequest(self, brdict):
871 """ 892 """
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 d = defer.DeferredList(dl) 1000 d = defer.DeferredList(dl)
980 d.addCallback(self._gatherPingResults) 1001 d.addCallback(self._gatherPingResults)
981 return d 1002 return d
982 1003
983 def _gatherPingResults(self, res): 1004 def _gatherPingResults(self, res):
984 for ignored,success in res: 1005 for ignored,success in res:
985 if not success: 1006 if not success:
986 return False 1007 return False
987 return True 1008 return True
988 1009
OLDNEW
« no previous file with comments | « masters/master.client.v8/master.cfg ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698