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