Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
skpbench.py
Go to the documentation of this file.
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
5
6# Recipe for Skia skpbench.
7
8
9import calendar
10
11PYTHON_VERSION_COMPATIBILITY = "PY3"
12
13DEPS = [
14 'flavor',
15 'recipe_engine/context',
16 'recipe_engine/file',
17 'recipe_engine/path',
18 'recipe_engine/platform',
19 'recipe_engine/properties',
20 'recipe_engine/raw_io',
21 'recipe_engine/step',
22 'recipe_engine/time',
23 'run',
24 'vars',
25]
26
27ADB_BINARY = 'adb.1.0.35'
28
29
30def _run(api, title, *cmd, **kwargs):
31 with api.context(cwd=api.path['start_dir'].join('skia')):
32 return api.run(api.step, title, cmd=list(cmd), **kwargs)
33
34
35def _adb(api, title, *cmd, **kwargs):
36 if 'infra_step' not in kwargs:
37 kwargs['infra_step'] = True
38 return _run(api, title, ADB_BINARY, *cmd, **kwargs)
39
40
42 """benchmark Skia using skpbench."""
43 is_vulkan = 'Vulkan' in api.vars.builder_name
44 is_metal = 'Metal' in api.vars.builder_name
45 is_android = 'Android' in api.vars.builder_name
46 is_apple_m1 = 'AppleM1' in api.vars.builder_name
47 is_all_paths_volatile = 'AllPathsVolatile' in api.vars.builder_name
48 is_mskp = 'Mskp' in api.vars.builder_name
49 is_ddl = 'DDL' in api.vars.builder_name
50 is_9x9 = '9x9' in api.vars.builder_name
51
52 api.file.ensure_directory(
53 'makedirs perf_dir', api.flavor.host_dirs.perf_data_dir)
54
55 if is_android:
56 app = api.vars.build_dir.join('skpbench')
57 _adb(api, 'push skpbench', 'push', app, api.flavor.device_dirs.bin_dir)
58
59 skpbench_dir = api.vars.workdir.join('skia', 'tools', 'skpbench')
60 table = api.path.join(api.vars.swarming_out_dir, 'table')
61
62 if is_vulkan:
63 config = 'vk'
64 elif is_metal:
65 config = 'mtl'
66 elif is_android:
67 config = 'gles'
68 if "MaliG77" in api.vars.builder_name:
69 config = 'glesdmsaa,' + config
70 else:
71 config = 'gl'
72 if "QuadroP400" in api.vars.builder_name or is_apple_m1:
73 config = 'gldmsaa,' + config
74
75 internal_samples = 4 if is_android or is_apple_m1 else 8
76
77 if is_all_paths_volatile:
78 config = "%smsaa%i" % (config, internal_samples)
79
80 skpbench_invocation = api.path.join(api.flavor.device_dirs.bin_dir, 'skpbench')
81
82 # skbug.com/10184
83 if is_vulkan and 'GalaxyS20' in api.vars.builder_name:
84 skpbench_invocation = "LD_LIBRARY_PATH=/data/local/tmp %s" % skpbench_invocation
85
86 skpbench_args = [
87 skpbench_invocation,
88 '--resultsfile', table,
89 '--config', config,
90 '--internalSamples', str(internal_samples),
91 # TODO(dogben): Track down what's causing bots to die.
92 '-v5']
93 if is_ddl:
94 skpbench_args += ['--ddl']
95 # disable the mask generation threads for simplicity's sake in DDL mode
96 skpbench_args += ['--gpuThreads', '0']
97 if is_9x9:
98 skpbench_args += [
99 '--ddlNumRecordingThreads', 9,
100 '--ddlTilingWidthHeight', 3]
101 if is_android:
102 skpbench_args += [
103 '--adb',
104 '--adb_binary', ADB_BINARY]
105 if is_mskp:
106 skpbench_args += [api.flavor.device_dirs.mskp_dir]
107 elif is_all_paths_volatile:
108 skpbench_args += [
109 '--allPathsVolatile',
110 '--suffix', "_volatile",
111 api.path.join(api.flavor.device_dirs.skp_dir, 'desk_*svg.skp'),
112 api.path.join(api.flavor.device_dirs.skp_dir, 'desk_motionmark*.skp'),
113 api.path.join(api.flavor.device_dirs.skp_dir, 'desk_chalkboard.skp')]
114 else:
115 skpbench_args += [api.flavor.device_dirs.skp_dir]
116
117 if api.properties.get('dont_reduce_ops_task_splitting') == 'true':
118 skpbench_args += ['--dontReduceOpsTaskSplitting']
119
120 api.run(api.step, 'skpbench',
121 cmd=['python3', skpbench_dir.join('skpbench.py')] + skpbench_args)
122
123 skiaperf_args = [
124 table,
125 '--properties',
126 'gitHash', api.properties['revision'],
127 ]
128 if api.vars.is_trybot:
129 skiaperf_args.extend([
130 'issue', api.vars.issue,
131 'patchset', api.vars.patchset,
132 'patch_storage', api.vars.patch_storage,
133 ])
134
135 skiaperf_args.extend(['swarming_bot_id', api.vars.swarming_bot_id])
136 skiaperf_args.extend(['swarming_task_id', api.vars.swarming_task_id])
137
138 now = api.time.utcnow()
139 ts = int(calendar.timegm(now.utctimetuple()))
140 json_path = api.path.join(
141 api.flavor.host_dirs.perf_data_dir,
142 'skpbench_%s_%d.json' % (api.properties['revision'], ts))
143
144 skiaperf_args.extend([
145 '--outfile', json_path
146 ])
147
148 skiaperf_args.append('--key')
149 for k in sorted(api.vars.builder_cfg.keys()):
150 if not k in ['configuration', 'role', 'is_trybot']:
151 skiaperf_args.extend([k, api.vars.builder_cfg[k]])
152
153 api.run(api.step, 'Parse skpbench output into Perf json',
154 cmd=['python3', skpbench_dir.join('skiaperf.py')] + skiaperf_args)
155
156
157def RunSteps(api):
158 api.vars.setup()
159 api.file.ensure_directory('makedirs tmp_dir', api.vars.tmp_dir)
160
161 # The app_name passed to api.flavor.setup() is used to determine which app
162 # to install on an attached device. That work is done in skpbench_steps, so
163 # we pass None here.
164 api.flavor.setup(None)
165
166 try:
167 mksp_mode = ('Mskp' in api.vars.builder_name)
168 api.flavor.install(skps=not mksp_mode, mskps=mksp_mode)
169 skpbench_steps(api)
170 finally:
171 api.flavor.cleanup_steps()
172 api.run.check_failure()
173
174
175TEST_BUILDERS = [
176 'Perf-Android-Clang-Pixel2XL-GPU-Adreno540-arm64-Release-All-Android_Skpbench_Mskp',
177 'Perf-Android-Clang-GalaxyS20-GPU-MaliG77-arm64-Release-All-Android_AllPathsVolatile_Skpbench',
178 'Perf-Android-Clang-GalaxyS20-GPU-MaliG77-arm64-Release-All-Android_Vulkan_AllPathsVolatile_Skpbench',
179 'Perf-Win10-Clang-Golo-GPU-QuadroP400-x86_64-Release-All-Vulkan_Skpbench',
180 'Perf-Win10-Clang-Golo-GPU-QuadroP400-x86_64-Release-All-Vulkan_Skpbench_DDLTotal_9x9',
181 'Perf-Win10-Clang-Golo-GPU-QuadroP400-x86_64-Release-All-AllPathsVolatile_Skpbench',
182 'Perf-Mac11-Clang-MacMini9.1-GPU-AppleM1-arm64-Release-All-Metal_AllPathsVolatile_Skpbench',
183]
184
185
186def GenTests(api):
187 for builder in TEST_BUILDERS:
188 test = (
189 api.test(builder) +
190 api.properties(buildername=builder,
191 revision='abc123',
192 path_config='kitchen',
193 swarm_out_dir='[SWARM_OUT_DIR]') +
194 api.path.exists(
195 api.path['start_dir'].join('skia'),
196 api.path['start_dir'].join('skia', 'infra', 'bots', 'assets',
197 'skp', 'VERSION'),
198 ) +
199 api.step_data('get swarming bot id',
200 stdout=api.raw_io.output('skia-bot-123')) +
201 api.step_data('get swarming task id',
202 stdout=api.raw_io.output('123456'))
203 )
204 if 'Win' in builder:
205 test += api.platform('win', 64)
206 yield test
207
208 b = ('Perf-Android-Clang-Pixel2XL-GPU-Adreno540-arm64-Release-All-'
209 'Android_Vulkan_Skpbench')
210 yield (
211 api.test('trybot') +
212 api.properties(buildername=b,
213 revision='abc123',
214 path_config='kitchen',
215 swarm_out_dir='[SWARM_OUT_DIR]',
216 dont_reduce_ops_task_splitting='true') +
217 api.path.exists(
218 api.path['start_dir'].join('skia'),
219 api.path['start_dir'].join('skia', 'infra', 'bots', 'assets',
220 'skp', 'VERSION'),
221 ) +
222 api.step_data('get swarming bot id',
223 stdout=api.raw_io.output('skia-bot-123')) +
224 api.step_data('get swarming task id',
225 stdout=api.raw_io.output('123456')) +
226 api.properties(patch_storage='gerrit') +
227 api.properties.tryserver(
228 buildername=b,
229 gerrit_project='skia',
230 gerrit_url='https://skia-review.googlesource.com/',
231 )
232 )
Type::kYUV Type::kRGBA() int(0.7 *637)
_run(api, title, *cmd, **kwargs)
Definition skpbench.py:30
_adb(api, title, *cmd, **kwargs)
Definition skpbench.py:35
GenTests(api)
Definition skpbench.py:186
RunSteps(api)
Definition skpbench.py:157
skpbench_steps(api)
Definition skpbench.py:41