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