• 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
11
12DEPS = [
13  'flavor',
14  'recipe_engine/context',
15  'recipe_engine/file',
16  'recipe_engine/path',
17  'recipe_engine/platform',
18  'recipe_engine/properties',
19  'recipe_engine/python',
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
41def skpbench_steps(api):
42  """benchmark Skia using skpbench."""
43  api.file.ensure_directory(
44      'makedirs perf_dir', api.flavor.host_dirs.perf_data_dir)
45
46  if 'Android' in api.vars.builder_name:
47    app = api.vars.build_dir.join('skpbench')
48    _adb(api, 'push skpbench', 'push', app, api.flavor.device_dirs.bin_dir)
49
50  skpbench_dir = api.vars.slave_dir.join('skia', 'tools', 'skpbench')
51  table = api.path.join(api.vars.swarming_out_dir, 'table')
52
53  if 'Vulkan' in api.vars.builder_name:
54    config = 'vk'
55  else:
56    config = 'gles'
57
58  skpbench_args = [
59        api.path.join(api.flavor.device_dirs.bin_dir, 'skpbench'),
60        '--resultsfile', table,
61        '--config', config,
62        # TODO(dogben): Track down what's causing bots to die.
63        '-v5']
64  if 'DDL' in api.vars.builder_name:
65    # This adds the "--ddl" flag for both DDLTotal and DDLRecord
66    skpbench_args += ['--ddl']
67    # disable the mask generation threads for sanity's sake in DDL mode
68    skpbench_args += ['--gpuThreads', '0']
69  if 'DDLRecord' in api.vars.builder_name:
70    skpbench_args += ['--ddlRecord']
71  if '9x9' in api.vars.builder_name:
72    skpbench_args += [
73        '--ddlNumAdditionalThreads', 9,
74        '--ddlTilingWidthHeight', 3]
75  if 'Android' in api.vars.builder_name:
76    skpbench_args += [
77        '--adb',
78        '--adb_binary', ADB_BINARY]
79  if 'CCPR' in api.vars.builder_name:
80    skpbench_args += [
81        '--pr', 'ccpr', '--cc', '--nocache',
82        api.path.join(api.flavor.device_dirs.skp_dir, 'desk_*svg.skp'),
83        api.path.join(api.flavor.device_dirs.skp_dir, 'desk_chalkboard.skp')]
84  elif 'Mskp' in api.vars.builder_name:
85    skpbench_args += [api.flavor.device_dirs.mskp_dir]
86  else:
87    skpbench_args += [api.flavor.device_dirs.skp_dir]
88
89  api.run(api.python, 'skpbench',
90      script=skpbench_dir.join('skpbench.py'),
91      args=skpbench_args)
92
93  skiaperf_args = [
94    table,
95    '--properties',
96    'gitHash', api.properties['revision'],
97  ]
98  if api.vars.is_trybot:
99    skiaperf_args.extend([
100      'issue',    api.vars.issue,
101      'patchset', api.vars.patchset,
102      'patch_storage', api.vars.patch_storage,
103    ])
104
105  skiaperf_args.extend(['swarming_bot_id', api.vars.swarming_bot_id])
106  skiaperf_args.extend(['swarming_task_id', api.vars.swarming_task_id])
107
108  now = api.time.utcnow()
109  ts = int(calendar.timegm(now.utctimetuple()))
110  json_path = api.path.join(
111      api.flavor.host_dirs.perf_data_dir,
112      'skpbench_%s_%d.json' % (api.properties['revision'], ts))
113
114  skiaperf_args.extend([
115    '--outfile', json_path
116  ])
117
118  keys_blacklist = ['configuration', 'role', 'is_trybot']
119  skiaperf_args.append('--key')
120  for k in sorted(api.vars.builder_cfg.keys()):
121    if not k in keys_blacklist:
122      skiaperf_args.extend([k, api.vars.builder_cfg[k]])
123
124  api.run(api.python, 'Parse skpbench output into Perf json',
125      script=skpbench_dir.join('skiaperf.py'),
126      args=skiaperf_args)
127
128
129def RunSteps(api):
130  api.vars.setup()
131  api.file.ensure_directory('makedirs tmp_dir', api.vars.tmp_dir)
132  api.flavor.setup()
133
134  try:
135    mksp_mode = ('Mskp' in api.vars.builder_name)
136    api.flavor.install(skps=not mksp_mode, mskps=mksp_mode)
137    skpbench_steps(api)
138  finally:
139    api.flavor.cleanup_steps()
140  api.run.check_failure()
141
142
143TEST_BUILDERS = [
144  ('Perf-Android-Clang-Pixel-GPU-Adreno530-arm64-Release-All-'
145   'Android_Skpbench_Mskp'),
146  ('Perf-Android-Clang-Pixel-GPU-Adreno530-arm64-Release-All-'
147   'Android_CCPR_Skpbench'),
148  'Perf-Win10-Clang-Golo-GPU-QuadroP400-x86_64-Release-All-Vulkan_Skpbench',
149  ('Perf-Win10-Clang-Golo-GPU-QuadroP400-x86_64-Release-All-'
150   'Vulkan_Skpbench_DDLTotal_9x9'),
151  ('Perf-Win10-Clang-Golo-GPU-QuadroP400-x86_64-Release-All-'
152   'Vulkan_Skpbench_DDLRecord_9x9'),
153]
154
155
156def GenTests(api):
157  for builder in TEST_BUILDERS:
158    test = (
159      api.test(builder) +
160      api.properties(buildername=builder,
161                     revision='abc123',
162                     path_config='kitchen',
163                     swarm_out_dir='[SWARM_OUT_DIR]') +
164      api.path.exists(
165          api.path['start_dir'].join('skia'),
166          api.path['start_dir'].join('skia', 'infra', 'bots', 'assets',
167                                     'skp', 'VERSION'),
168      ) +
169      api.step_data('get swarming bot id',
170          stdout=api.raw_io.output('skia-bot-123')) +
171      api.step_data('get swarming task id',
172          stdout=api.raw_io.output('123456'))
173    )
174    if 'Win' in builder and not 'LenovoYogaC630' in builder:
175      test += api.platform('win', 64)
176    yield test
177
178  b = ('Perf-Android-Clang-Pixel2XL-GPU-Adreno540-arm64-Release-All-'
179       'Android_Vulkan_Skpbench')
180  yield (
181    api.test('trybot') +
182    api.properties(buildername=b,
183                   revision='abc123',
184                   path_config='kitchen',
185                   swarm_out_dir='[SWARM_OUT_DIR]') +
186    api.path.exists(
187        api.path['start_dir'].join('skia'),
188        api.path['start_dir'].join('skia', 'infra', 'bots', 'assets',
189                                   'skp', 'VERSION'),
190    ) +
191    api.step_data('get swarming bot id',
192        stdout=api.raw_io.output('skia-bot-123')) +
193    api.step_data('get swarming task id',
194        stdout=api.raw_io.output('123456')) +
195    api.properties(patch_storage='gerrit') +
196    api.properties.tryserver(
197        buildername=b,
198        gerrit_project='skia',
199        gerrit_url='https://skia-review.googlesource.com/',
200    )
201  )
202