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

Side by Side Diff: tools/bisect-perf-regression.py

Issue 256593004: [bisect] - Parse DEPS file manually if execfile fails. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes from review. Created 6 years, 8 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 | « no previous file | 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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Performance Test Bisect Tool 6 """Performance Test Bisect Tool
7 7
8 This script bisects a series of changelists using binary search. It starts at 8 This script bisects a series of changelists using binary search. It starts at
9 a bad revision where a performance metric has regressed, and asks for a last 9 a bad revision where a performance metric has regressed, and asks for a last
10 known-good revision. It will then binary search across this revision range by 10 known-good revision. It will then binary search across this revision range by
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 # svn: Needed for git workflow to resolve hashes to svn revisions. 69 # svn: Needed for git workflow to resolve hashes to svn revisions.
70 # from: Parent depot that must be bisected before this is bisected. 70 # from: Parent depot that must be bisected before this is bisected.
71 # deps_var: Key name in vars varible in DEPS file that has revision information. 71 # deps_var: Key name in vars varible in DEPS file that has revision information.
72 DEPOT_DEPS_NAME = { 72 DEPOT_DEPS_NAME = {
73 'chromium' : { 73 'chromium' : {
74 "src" : "src", 74 "src" : "src",
75 "recurse" : True, 75 "recurse" : True,
76 "depends" : None, 76 "depends" : None,
77 "from" : ['cros', 'android-chrome'], 77 "from" : ['cros', 'android-chrome'],
78 'viewvc': 'http://src.chromium.org/viewvc/chrome?view=revision&revision=', 78 'viewvc': 'http://src.chromium.org/viewvc/chrome?view=revision&revision=',
79 'deps_var': None 79 'deps_var': 'chromium_rev'
80 }, 80 },
81 'webkit' : { 81 'webkit' : {
82 "src" : "src/third_party/WebKit", 82 "src" : "src/third_party/WebKit",
83 "recurse" : True, 83 "recurse" : True,
84 "depends" : None, 84 "depends" : None,
85 "from" : ['chromium'], 85 "from" : ['chromium'],
86 'viewvc': 'http://src.chromium.org/viewvc/blink?view=revision&revision=', 86 'viewvc': 'http://src.chromium.org/viewvc/blink?view=revision&revision=',
87 'deps_var': 'webkit_revision' 87 'deps_var': 'webkit_revision'
88 }, 88 },
89 'angle' : { 89 'angle' : {
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 if 'ninja' in os.getenv('GYP_GENERATORS'): 733 if 'ninja' in os.getenv('GYP_GENERATORS'):
734 opts.build_preference = 'ninja' 734 opts.build_preference = 'ninja'
735 else: 735 else:
736 opts.build_preference = 'make' 736 opts.build_preference = 'make'
737 737
738 SetBuildSystemDefault(opts.build_preference) 738 SetBuildSystemDefault(opts.build_preference)
739 739
740 if not bisect_utils.SetupPlatformBuildEnvironment(opts): 740 if not bisect_utils.SetupPlatformBuildEnvironment(opts):
741 raise RuntimeError('Failed to set platform environment.') 741 raise RuntimeError('Failed to set platform environment.')
742 742
743 bisect_utils.RunGClient(['runhooks']) 743 bisect_utils.RunGClient(['runhooks'])
shatch 2014/04/25 22:01:40 Unnecessary call, and ends up running when we run
744 744
745 @staticmethod 745 @staticmethod
746 def FromOpts(opts): 746 def FromOpts(opts):
747 builder = None 747 builder = None
748 if opts.target_platform == 'cros': 748 if opts.target_platform == 'cros':
749 builder = CrosBuilder(opts) 749 builder = CrosBuilder(opts)
750 elif opts.target_platform == 'android': 750 elif opts.target_platform == 'android':
751 builder = AndroidBuilder(opts) 751 builder = AndroidBuilder(opts)
752 elif opts.target_platform == 'android-chrome': 752 elif opts.target_platform == 'android-chrome':
753 builder = AndroidChromeBuilder(opts) 753 builder = AndroidChromeBuilder(opts)
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 1360
1361 bleeding_edge_revision = None 1361 bleeding_edge_revision = None
1362 1362
1363 for c in commits: 1363 for c in commits:
1364 bleeding_edge_revision = self._GetV8BleedingEdgeFromV8TrunkIfMappable(c) 1364 bleeding_edge_revision = self._GetV8BleedingEdgeFromV8TrunkIfMappable(c)
1365 if bleeding_edge_revision: 1365 if bleeding_edge_revision:
1366 break 1366 break
1367 1367
1368 return bleeding_edge_revision 1368 return bleeding_edge_revision
1369 1369
1370 def Get3rdPartyRevisionsFromCurrentRevision(self, depot, revision): 1370 def _ParseRevisionsFromDEPSFileManually(self, depot):
1371 """Parses the DEPS file to determine WebKit/v8/etc... versions. 1371 """Manually parses the vars section of the DEPS file to determine
1372 chromium/blink/etc... revisions.
1373
1374 Args:
1375 depot: Depot being bisected.
1372 1376
1373 Returns: 1377 Returns:
1374 A dict in the format {depot:revision} if successful, otherwise None. 1378 A dict in the format {depot:revision} if successful, otherwise None.
1375 """ 1379 """
1376 cwd = os.getcwd() 1380 # We'll parse the "vars" section of the DEPS file.
1377 self.ChangeToDepotWorkingDirectory(depot) 1381 rxp = re.compile("vars = {(?P<vars_body>[^}]+)", re.MULTILINE)
1382 re_results = rxp.search(ReadStringFromFile(bisect_utils.FILE_DEPS_GIT))
1383 locals = {}
1378 1384
1379 results = {} 1385 if not re_results:
1386 return None
1380 1387
1381 if depot == 'chromium' or depot == 'android-chrome': 1388 # We should be left with a series of entries in the vars component of
1389 # the DEPS file with the following format:
1390 # 'depot_name': 'revision',
1391 vars_body = re_results.group("vars_body")
qyearsley 2014/04/25 20:53:30 Line 1381 and 1391 -- single quotes preferred over
shatch 2014/04/25 22:01:40 Done.
1392 rxp = re.compile("'(?P<depot_body>[\w_-]+)':[\s]+'(?P<rev_body>[\w@]+)'",
1393 re.MULTILINE)
qyearsley 2014/04/25 20:53:30 Style nit: line break style. http://google-stylegu
shatch 2014/04/25 22:01:40 Done.
1394 re_results = rxp.findall(vars_body)
1395
1396 for depot_name, depot_revision in re_results:
1397 depot_revision = depot_revision.strip('@')
1398 for current_name, current_data in DEPOT_DEPS_NAME.iteritems():
1399 if (current_data.has_key('deps_var') and
1400 current_data['deps_var'] == depot_name):
1401 src_name = current_name
1402 locals[src_name] = depot_revision
1403 break
1404 return locals
1405
1406 def _ParseRevisionsFromDEPSFile(self, depot):
1407 """Parses the local DEPS file to determine blink/skia/v8 revisions which may
1408 be needed if the bisect recurses into those depots later.
1409
1410 Args:
1411 depot: Depot being bisected.
1412
1413 Returns:
1414 A dict in the format {depot:revision} if successful, otherwise None.
1415 """
1416 try:
1382 locals = {'Var': lambda _: locals["vars"][_], 1417 locals = {'Var': lambda _: locals["vars"][_],
1383 'From': lambda *args: None} 1418 'From': lambda *args: None}
1384 execfile(bisect_utils.FILE_DEPS_GIT, {}, locals) 1419 execfile(bisect_utils.FILE_DEPS_GIT, {}, locals)
1385 1420 locals = locals['deps']
1386 os.chdir(cwd) 1421 results = {}
1387 1422
1388 rxp = re.compile(".git@(?P<revision>[a-fA-F0-9]+)") 1423 rxp = re.compile(".git@(?P<revision>[a-fA-F0-9]+)")
1389 1424
1390 for d in DEPOT_NAMES: 1425 for d in DEPOT_NAMES:
1391 if DEPOT_DEPS_NAME[d].has_key('platform'): 1426 if DEPOT_DEPS_NAME[d].has_key('platform'):
1392 if DEPOT_DEPS_NAME[d]['platform'] != os.name: 1427 if DEPOT_DEPS_NAME[d]['platform'] != os.name:
1393 continue 1428 continue
1394 1429
1395 if (DEPOT_DEPS_NAME[d]['recurse'] and 1430 if (DEPOT_DEPS_NAME[d]['recurse'] and
1396 depot in DEPOT_DEPS_NAME[d]['from']): 1431 depot in DEPOT_DEPS_NAME[d]['from']):
1397 if (locals['deps'].has_key(DEPOT_DEPS_NAME[d]['src']) or 1432 if (locals.has_key(DEPOT_DEPS_NAME[d]['src']) or
1398 locals['deps'].has_key(DEPOT_DEPS_NAME[d]['src_old'])): 1433 locals.has_key(DEPOT_DEPS_NAME[d]['src_old'])):
1399 if locals['deps'].has_key(DEPOT_DEPS_NAME[d]['src']): 1434 if locals.has_key(DEPOT_DEPS_NAME[d]['src']):
1400 re_results = rxp.search(locals['deps'][DEPOT_DEPS_NAME[d]['src']]) 1435 re_results = rxp.search(locals[DEPOT_DEPS_NAME[d]['src']])
1401 self.depot_cwd[d] = \ 1436 self.depot_cwd[d] = \
1402 os.path.join(self.src_cwd, DEPOT_DEPS_NAME[d]['src'][4:]) 1437 os.path.join(self.src_cwd, DEPOT_DEPS_NAME[d]['src'][4:])
1403 elif locals['deps'].has_key(DEPOT_DEPS_NAME[d]['src_old']): 1438 elif (DEPOT_DEPS_NAME[d].has_key('src_old') and
1439 locals.has_key(DEPOT_DEPS_NAME[d]['src_old'])):
1404 re_results = \ 1440 re_results = \
1405 rxp.search(locals['deps'][DEPOT_DEPS_NAME[d]['src_old']]) 1441 rxp.search(locals[DEPOT_DEPS_NAME[d]['src_old']])
1406 self.depot_cwd[d] = \ 1442 self.depot_cwd[d] = \
1407 os.path.join(self.src_cwd, DEPOT_DEPS_NAME[d]['src_old'][4:]) 1443 os.path.join(self.src_cwd, DEPOT_DEPS_NAME[d]['src_old'][4:])
1408 1444
1409 if re_results: 1445 if re_results:
1410 results[d] = re_results.group('revision') 1446 results[d] = re_results.group('revision')
1411 else: 1447 else:
1412 print 'Couldn\'t parse revision for %s.' % d 1448 warning_text = ('Couldn\'t parse revision for %s while bisecting '
1413 print 1449 '%s' % (d, depot))
1414 return None 1450 if not warningText in self.warnings:
1451 self.warnings.append(warningText)
1415 else: 1452 else:
1416 print 'Couldn\'t find %s while parsing .DEPS.git.' % d 1453 print 'Couldn\'t find %s while parsing .DEPS.git.' % d
1417 print 1454 print
1418 return None 1455 return None
1456 return results
1457 except ImportError:
qyearsley 2014/04/25 20:53:30 This ImportError is thrown on line 1419 (in execfi
shatch 2014/04/25 22:01:40 Yep. I'm thinking it would be a lot more complica
1458 return self._ParseRevisionsFromDEPSFileManually(depot)
1459
1460 def Get3rdPartyRevisionsFromCurrentRevision(self, depot, revision):
1461 """Parses the DEPS file to determine WebKit/v8/etc... versions.
1462
1463 Returns:
1464 A dict in the format {depot:revision} if successful, otherwise None.
1465 """
1466 cwd = os.getcwd()
1467 self.ChangeToDepotWorkingDirectory(depot)
1468
1469 results = {}
1470
1471 if depot == 'chromium' or depot == 'android-chrome':
1472 results = self._ParseRevisionsFromDEPSFile(depot)
1473 os.chdir(cwd)
1419 elif depot == 'cros': 1474 elif depot == 'cros':
1420 cmd = [CROS_SDK_PATH, '--', 'portageq-%s' % self.opts.cros_board, 1475 cmd = [CROS_SDK_PATH, '--', 'portageq-%s' % self.opts.cros_board,
1421 'best_visible', '/build/%s' % self.opts.cros_board, 'ebuild', 1476 'best_visible', '/build/%s' % self.opts.cros_board, 'ebuild',
1422 CROS_CHROMEOS_PATTERN] 1477 CROS_CHROMEOS_PATTERN]
1423 (output, return_code) = RunProcessAndRetrieveOutput(cmd) 1478 (output, return_code) = RunProcessAndRetrieveOutput(cmd)
1424 1479
1425 assert not return_code, 'An error occurred while running' \ 1480 assert not return_code, 'An error occurred while running' \
1426 ' "%s"' % ' '.join(cmd) 1481 ' "%s"' % ' '.join(cmd)
1427 1482
1428 if len(output) > CROS_CHROMEOS_PATTERN: 1483 if len(output) > CROS_CHROMEOS_PATTERN:
(...skipping 2290 matching lines...) Expand 10 before | Expand all | Expand 10 after
3719 # The perf dashboard scrapes the "results" step in order to comment on 3774 # The perf dashboard scrapes the "results" step in order to comment on
3720 # bugs. If you change this, please update the perf dashboard as well. 3775 # bugs. If you change this, please update the perf dashboard as well.
3721 bisect_utils.OutputAnnotationStepStart('Results') 3776 bisect_utils.OutputAnnotationStepStart('Results')
3722 print 'Error: %s' % e.message 3777 print 'Error: %s' % e.message
3723 if opts.output_buildbot_annotations: 3778 if opts.output_buildbot_annotations:
3724 bisect_utils.OutputAnnotationStepClosed() 3779 bisect_utils.OutputAnnotationStepClosed()
3725 return 1 3780 return 1
3726 3781
3727 if __name__ == '__main__': 3782 if __name__ == '__main__':
3728 sys.exit(main()) 3783 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698