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

Side by Side Diff: build/win/run_pgo_profiling_benchmarks.py

Issue 2368353003: Add a script to run the PGO benchmarks. (Closed)
Patch Set: 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 | « 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
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4 """Utility script to run the benchmarks during the profiling step of a PGO
scottmg 2016/09/27 17:39:30 nit; blank line after copyright before block comme
Sébastien Marchand 2016/09/27 17:59:56 Done.
5 build.
6 """
7
8 import json
9 import optparse
10 import os
11 import subprocess
12 import sys
13
14 # Make sure that we're running as admin, this is required to run the Telemetry
15 # benchmarks.
16 from win32com.shell import shell
17 if not shell.IsUserAnAdmin():
18 raise Exception('This script has to be run as admin.')
19
20
21 _SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
22 _CHROME_BUILD_DIR = os.path.dirname(_SCRIPT_DIR)
23 _CHROME_SRC_DIR = os.path.dirname(_CHROME_BUILD_DIR)
24
25
26 # List of the benchmark that we run during the profiling step.
27 _BENCHMARKS_TO_RUN = {
28 'blink_perf.bindings',
29 'blink_perf.canvas',
30 'blink_perf.css',
31 'blink_perf.dom',
32 'blink_perf.paint',
33 'blink_perf.svg',
34 'blink_style.top_25',
35 'dromaeo.cssqueryjquery',
36 'dromaeo.domcoreattr',
37 'dromaeo.domcoremodify',
38 'dromaeo.domcorequery',
39 'dromaeo.domcoretraverse',
40 'dromaeo.jslibattrprototype',
41 'dromaeo.jslibeventprototype',
42 'dromaeo.jslibmodifyprototype',
43 'dromaeo.jslibstyleprototype',
44 'dromaeo.jslibtraversejquery',
45 'dromaeo.jslibtraverseprototype',
46 'indexeddb_perf',
47 'media.tough_video_cases',
48 'octane',
49 'smoothness.top_25_smooth',
50 'speedometer',
51 'sunspider',
52 }
53
54
55 def FindPgosweep(target_bits):
56 """Find the directory containing pgosweep.exe."""
scottmg 2016/09/27 17:39:30 nit; " target_bits should be 32 or 64." since I pr
Sébastien Marchand 2016/09/27 17:59:55 Done, added a check as well.
57 win_toolchain_json_file = os.path.join(_CHROME_BUILD_DIR,
58 'win_toolchain.json')
59 if not os.path.exists(win_toolchain_json_file):
60 raise Exception('The toolchain JSON file (%s) is missing.' %
61 win_toolchain_json_file)
62 with open(win_toolchain_json_file) as temp_f:
63 toolchain_data = json.load(temp_f)
64 if not os.path.isdir(toolchain_data['path']):
65 raise Exception('The toolchain JSON file is invalid.')
scottmg 2016/09/27 17:39:30 nit; 'The toolchain JSON file's "path" entry (%s)
Sébastien Marchand 2016/09/27 17:59:56 Done.
66
67 pgo_sweep_dir = os.path.join(toolchain_data['path'], 'VC', 'bin')
68 if target_bits == 64:
69 pgo_sweep_dir = os.path.join(pgo_sweep_dir, 'amd64')
70
71 if not os.path.exists(os.path.join(pgo_sweep_dir, 'pgosweep.exe')):
72 raise Exception('pgosweep.exe is missing from %s.' % pgo_sweep_dir)
73
74 return pgo_sweep_dir
75
76
77 def RunBenchmarks(options):
78 """Run the benchmarks."""
79 # Starts by finding the directory containing pgosweep.exe
80 pgo_sweep_dir = FindPgosweep(options.target_bits)
81 if not pgo_sweep_dir:
scottmg 2016/09/27 17:39:30 I don't think this can return empty/None because t
Sébastien Marchand 2016/09/27 17:59:56 Ha, good point!
82 return 1
83
84 # Find the run_benchmark script.
85 chrome_run_benchmark_script = os.path.join(_CHROME_SRC_DIR, 'tools',
86 'perf', 'run_benchmark')
87 if not os.path.exists(chrome_run_benchmark_script):
88 raise Exception('Unable to find the run_benchmark script '
89 '(%s doesn\'t exist) ' % chrome_run_benchmark_script)
90
91 # Augment the PATH to make sure that the benchmarking script can find
92 # pgosweep.exe and its runtime libraries.
93 env = os.environ.copy()
94 env['PATH'] = str(os.pathsep.join([pgo_sweep_dir, options.build_dir,
95 os.environ['PATH']]))
96 env['PogoSafeMode'] = '1'
97 # Apply a scaling factor of 0.5 to the PGO profiling buffers for the 32-bit
98 # builds, without this the buffers will be too large and the process will
99 # fail to start. See crbug.com/632864#c22.
100 if options.target_bits == 32:
101 env['VCPROFILE_ALLOC_SCALE'] = '0.5'
102
103 # Run all the benchmarks.
104 # TODO(sebmarchand): Make this run in parallel.
scottmg 2016/09/27 17:39:30 [Seems like you wouldn't want to run benchmarks in
Sébastien Marchand 2016/09/27 17:59:56 I don't think that it could cause any issue? When
105 for benchmark in _BENCHMARKS_TO_RUN:
106 try:
107 benchmark_command = [
108 sys.executable,
109 chrome_run_benchmark_script,
110 '--browser', options.browser_type,
111 ]
112 # Automatically set the arguments to run this script on a local build.
113 if options.browser_type == 'exact':
114 benchmark_command += [
115 '--browser-executable', os.path.join(options.build_dir, 'chrome.exe')
116 ]
117 benchmark_command += [
118 '--profiler', 'win_pgo_profiler',
119 benchmark
120 ]
121 subprocess.call(benchmark_command, env=env)
scottmg 2016/09/27 17:39:30 check_call maybe?
Sébastien Marchand 2016/09/27 17:59:56 Done.
122 except:
123 continue
scottmg 2016/09/27 17:39:30 log something about exception maybe?
Sébastien Marchand 2016/09/27 17:59:55 Done.
124
125 return 0
126
127
128 def main():
129 parser = optparse.OptionParser(usage='%prog [options]')
130 parser.add_option(
131 '--browser-type', help='The browser type (to be passed to Telemetry\'s '
132 'benchmark runner).')
133 # TODO(sebmarchand): Parse the args.gn file to automatically set this value.
134 parser.add_option('--target-bits', help='The target\'s bitness.', type=int)
scottmg 2016/09/27 17:39:30 Maybe "target_cpu" and make it a string that's "x8
Sébastien Marchand 2016/09/27 17:59:56 Done.
135 parser.add_option('--build-dir', help='Chrome build directory.')
136 options, _ = parser.parse_args()
137
138 if not options.target_bits:
139 parser.error('--target-bits is required')
140 if not options.build_dir:
141 parser.error('--build-dir is required')
142 if not options.browser_type:
143 options.browser_type = 'exact'
144
145 return RunBenchmarks(options)
146
147
148 if __name__ == '__main__':
149 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