• 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 module for Skia Swarming perf.
7
8
9import calendar
10
11
12DEPS = [
13  'core',
14  'env',
15  'flavor',
16  'recipe_engine/file',
17  'recipe_engine/json',
18  'recipe_engine/path',
19  'recipe_engine/platform',
20  'recipe_engine/properties',
21  'recipe_engine/raw_io',
22  'recipe_engine/step',
23  'recipe_engine/time',
24  'run',
25  'vars',
26]
27
28
29def nanobench_flags(api, bot):
30  args = ['--pre_log']
31
32  if 'GPU' in bot:
33    args.append('--images')
34    args.extend(['--gpuStatsDump', 'true'])
35
36  if 'Android' in bot and 'GPU' in bot:
37    args.extend(['--useThermalManager', '1,1,10,1000'])
38
39  args.extend(['--scales', '1.0', '1.1'])
40
41  if 'iOS' in bot:
42    args.extend(['--skps', 'ignore_skps'])
43
44  configs = ['8888', 'nonrendering', 'hwui' ]
45
46  if '-arm-' not in bot:
47    # For Android CPU tests, these take too long and cause the task to time out.
48    configs += [ 'f16', 'srgb' ]
49  if '-GCE-' in bot:
50    configs += [ '565' ]
51
52  gl_prefix = 'gl'
53  sample_count = '8'
54  if 'Android' in bot or 'iOS' in bot:
55    sample_count = '4'
56    # The NVIDIA_Shield has a regular OpenGL implementation. We bench that
57    # instead of ES.
58    if 'NVIDIA_Shield' not in bot:
59      gl_prefix = 'gles'
60    # The NP produces a long error stream when we run with MSAA.
61    # iOS crashes (skia:6399)
62    if 'NexusPlayer' in bot or 'iOS' in bot:
63      sample_count = ''
64  elif 'Intel' in bot:
65    sample_count = ''
66  elif 'ChromeOS' in bot:
67    gl_prefix = 'gles'
68
69  configs.append(gl_prefix)
70  if sample_count is not '':
71    configs.extend([gl_prefix + 'msaa' + sample_count,
72      gl_prefix + 'nvpr' + sample_count,
73      gl_prefix + 'nvprdit' + sample_count])
74
75  # We want to test both the OpenGL config and the GLES config on Linux Intel:
76  # GL is used by Chrome, GLES is used by ChromeOS.
77  if 'Intel' in bot and api.vars.is_linux:
78    configs.append('gles')
79
80  # Bench instanced rendering on a limited number of platforms
81  inst_config = gl_prefix + 'inst'
82  if 'PixelC' in bot or 'NVIDIA_Shield' in bot or 'MacMini6.2' in bot:
83    configs.extend([inst_config, inst_config + sample_count])
84
85  if 'CommandBuffer' in bot:
86    configs = ['commandbuffer']
87  if 'Vulkan' in bot:
88    configs = ['vk']
89
90  if 'ANGLE' in bot:
91    # Test only ANGLE configs.
92    configs = ['angle_d3d11_es2']
93    if sample_count is not '':
94      configs.append('angle_d3d11_es2_msaa' + sample_count)
95
96  if 'ChromeOS' in bot:
97    # Just run GLES for now - maybe add gles_msaa4 in the future
98    configs = ['gles']
99
100  args.append('--config')
101  args.extend(configs)
102
103  if 'Valgrind' in bot:
104    # Don't care about Valgrind performance.
105    args.extend(['--loops',   '1'])
106    args.extend(['--samples', '1'])
107    # Ensure that the bot framework does not think we have timed out.
108    args.extend(['--keepAlive', 'true'])
109
110  # Some people don't like verbose output.
111  verbose = False
112
113  match = []
114  if 'Android' in bot:
115    # Segfaults when run as GPU bench. Very large texture?
116    match.append('~blurroundrect')
117    match.append('~patch_grid')  # skia:2847
118    match.append('~desk_carsvg')
119  if 'NexusPlayer' in bot:
120    match.append('~desk_unicodetable')
121  if 'Nexus5' in bot:
122    match.append('~keymobi_shop_mobileweb_ebay_com.skp')  # skia:5178
123  if 'iOS' in bot:
124    match.append('~blurroundrect')
125    match.append('~patch_grid')  # skia:2847
126    match.append('~desk_carsvg')
127    match.append('~keymobi')
128    match.append('~path_hairline')
129    match.append('~GLInstancedArraysBench') # skia:4714
130  if 'IntelIris540' in bot and 'ANGLE' in bot:
131    match.append('~tile_image_filter_tiled_64')  # skia:6082
132  if ('Vulkan' in bot and ('IntelIris540' in bot or 'IntelIris640' in bot) and
133      'Win' in bot):
134    # skia:6398
135    match.append('~GM_varied_text_clipped_lcd')
136    match.append('~GM_varied_text_ignorable_clip_lcd')
137    match.append('~blendmode_mask_DstATop')
138    match.append('~blendmode_mask_SrcIn')
139    match.append('~blendmode_mask_SrcOut')
140    match.append('~blendmode_mask_Src')
141    match.append('~fontscaler_lcd')
142    match.append('~rotated_rects_aa_alternating_transparent_and_opaque_src')
143    match.append('~rotated_rects_aa_changing_transparent_src')
144    match.append('~rotated_rects_aa_same_transparent_src')
145    match.append('~shadermask_LCD_FF')
146    match.append('~srcmode_rects_1')
147    match.append('~text_16_LCD_88')
148    match.append('~text_16_LCD_BK')
149    match.append('~text_16_LCD_FF')
150    match.append('~text_16_LCD_WT')
151    # skia:6863
152    match.append('~desk_skbug6850overlay2')
153  if ('Intel' in bot and api.vars.is_linux and not 'Vulkan' in bot):
154    # TODO(dogben): Track down what's causing bots to die.
155    verbose = True
156  if 'Vulkan' in bot and 'NexusPlayer' in bot:
157    match.append('~blendmode_') # skia:6691
158  if 'ANGLE' in bot and 'Radeon' in bot and 'Release' in bot:
159    # skia:6534
160    match.append('~shapes_mixed_10000_32x33')
161    match.append('~shapes_oval_10000_32x32')
162    match.append('~shapes_oval_10000_32x33')
163    match.append('~shapes_rect_100_500x500')
164    match.append('~shapes_rrect_10000_32x32')
165  if 'ANGLE' in bot and 'GTX960' in bot and 'Release' in bot:
166    # skia:6534
167    match.append('~shapes_mixed_10000_32x33')
168    match.append('~shapes_rect_100_500x500')
169    match.append('~shapes_rrect_10000_32x32')
170
171  # We do not need or want to benchmark the decodes of incomplete images.
172  # In fact, in nanobench we assert that the full image decode succeeds.
173  match.append('~inc0.gif')
174  match.append('~inc1.gif')
175  match.append('~incInterlaced.gif')
176  match.append('~inc0.jpg')
177  match.append('~incGray.jpg')
178  match.append('~inc0.wbmp')
179  match.append('~inc1.wbmp')
180  match.append('~inc0.webp')
181  match.append('~inc1.webp')
182  match.append('~inc0.ico')
183  match.append('~inc1.ico')
184  match.append('~inc0.png')
185  match.append('~inc1.png')
186  match.append('~inc2.png')
187  match.append('~inc12.png')
188  match.append('~inc13.png')
189  match.append('~inc14.png')
190  match.append('~inc0.webp')
191  match.append('~inc1.webp')
192
193  if match:
194    args.append('--match')
195    args.extend(match)
196
197  if verbose:
198    args.append('--verbose')
199
200  return args
201
202
203def perf_steps(api):
204  """Run Skia benchmarks."""
205  if api.vars.upload_perf_results:
206    api.flavor.create_clean_device_dir(
207        api.flavor.device_dirs.perf_data_dir)
208
209  # Run nanobench.
210  properties = [
211    '--properties',
212    'gitHash',      api.vars.got_revision,
213  ]
214  if api.vars.is_trybot:
215    properties.extend([
216      'issue',    api.vars.issue,
217      'patchset', api.vars.patchset,
218      'patch_storage', api.vars.patch_storage,
219    ])
220  properties.extend(['swarming_bot_id', api.vars.swarming_bot_id])
221  properties.extend(['swarming_task_id', api.vars.swarming_task_id])
222
223  target = 'nanobench'
224  args = [
225      target,
226      '--undefok',   # This helps branches that may not know new flags.
227      '-i',       api.flavor.device_dirs.resource_dir,
228      '--skps',   api.flavor.device_dirs.skp_dir,
229      '--images', api.flavor.device_path_join(
230          api.flavor.device_dirs.images_dir, 'nanobench'),
231  ]
232
233  # Do not run svgs on Valgrind.
234  if 'Valgrind' not in api.vars.builder_name:
235    if ('Vulkan' not in api.vars.builder_name or
236        'NexusPlayer' not in api.vars.builder_name):
237      args.extend(['--svgs',  api.flavor.device_dirs.svg_dir])
238
239  skip_flag = None
240  if api.vars.builder_cfg.get('cpu_or_gpu') == 'CPU':
241    skip_flag = '--nogpu'
242  elif api.vars.builder_cfg.get('cpu_or_gpu') == 'GPU':
243    skip_flag = '--nocpu'
244  if skip_flag:
245    args.append(skip_flag)
246  args.extend(nanobench_flags(api, api.vars.builder_name))
247
248  if 'Chromecast' in api.vars.builder_cfg.get('os', ''):
249    # Due to limited disk space, run a watered down perf run on Chromecast.
250    args = [
251      target,
252      '--config',
253      '8888',
254      'gles',
255    ]
256    if api.vars.builder_cfg.get('cpu_or_gpu') == 'CPU':
257      args.extend(['--nogpu'])
258    elif api.vars.builder_cfg.get('cpu_or_gpu') == 'GPU':
259      args.extend(['--nocpu'])
260    args.extend([
261      '-i', api.flavor.device_dirs.resource_dir,
262      '--images', api.flavor.device_path_join(
263          api.flavor.device_dirs.resource_dir, 'color_wheel.jpg'),
264      '--skps',  api.flavor.device_dirs.skp_dir,
265      '--pre_log',
266      '--match', # skia:6581
267      '~matrixconvolution',
268      '~blur_image_filter',
269      '~blur_0.01',
270      '~GM_animated-image-blurs',
271      '~blendmode_mask_',
272    ])
273
274  if api.vars.upload_perf_results:
275    now = api.time.utcnow()
276    ts = int(calendar.timegm(now.utctimetuple()))
277    json_path = api.flavor.device_path_join(
278        api.flavor.device_dirs.perf_data_dir,
279        'nanobench_%s_%d.json' % (api.vars.got_revision, ts))
280    args.extend(['--outResultsFile', json_path])
281    args.extend(properties)
282
283    keys_blacklist = ['configuration', 'role', 'is_trybot']
284    args.append('--key')
285    for k in sorted(api.vars.builder_cfg.keys()):
286      if not k in keys_blacklist:
287        args.extend([k, api.vars.builder_cfg[k]])
288
289  env = {}
290  if 'Ubuntu16' in api.vars.builder_name:
291    # The vulkan in this asset name simply means that the graphics driver
292    # supports Vulkan. It is also the driver used for GL code.
293    dri_path = api.vars.slave_dir.join('linux_vulkan_intel_driver_release')
294    if 'Debug' in api.vars.builder_name:
295      dri_path = api.vars.slave_dir.join('linux_vulkan_intel_driver_debug')
296
297    if 'Vulkan' in api.vars.builder_name:
298      sdk_path = api.vars.slave_dir.join('linux_vulkan_sdk', 'bin')
299      lib_path = api.vars.slave_dir.join('linux_vulkan_sdk', 'lib')
300      env.update({
301        'PATH':'%%(PATH)s:%s' % sdk_path,
302        'LD_LIBRARY_PATH': '%s:%s' % (lib_path, dri_path),
303        'LIBGL_DRIVERS_PATH': dri_path,
304        'VK_ICD_FILENAMES':'%s' % dri_path.join('intel_icd.x86_64.json'),
305      })
306    else:
307      # Even the non-vulkan NUC jobs could benefit from the newer drivers.
308      env.update({
309        'LD_LIBRARY_PATH': dri_path,
310        'LIBGL_DRIVERS_PATH': dri_path,
311      })
312
313  # See skia:2789.
314  extra_config_parts = api.vars.builder_cfg.get('extra_config', '').split('_')
315  if 'AbandonGpuContext' in extra_config_parts:
316    args.extend(['--abandonGpuContext', '--nocpu'])
317
318  with api.env(env):
319    api.run(api.flavor.step, target, cmd=args,
320            abort_on_failure=False)
321
322  # Copy results to swarming out dir.
323  if api.vars.upload_perf_results:
324    api.file.ensure_directory('makedirs perf_dir', api.vars.perf_data_dir)
325    api.flavor.copy_directory_contents_to_host(
326        api.flavor.device_dirs.perf_data_dir,
327        api.vars.perf_data_dir)
328
329
330def RunSteps(api):
331  api.core.setup()
332  env = {}
333  if 'iOS' in api.vars.builder_name:
334    env['IOS_BUNDLE_ID'] = 'com.google.nanobench'
335    env['IOS_MOUNT_POINT'] = api.vars.slave_dir.join('mnt_iosdevice')
336  with api.env(env):
337    try:
338      if 'Chromecast' in api.vars.builder_name:
339        api.flavor.install(resources=True, skps=True)
340      else:
341        api.flavor.install_everything()
342      perf_steps(api)
343    finally:
344      api.flavor.cleanup_steps()
345    api.run.check_failure()
346
347
348TEST_BUILDERS = [
349  'Perf-Android-Clang-NVIDIA_Shield-GPU-TegraX1-arm64-Debug-Android_Vulkan',
350  'Perf-Android-Clang-Nexus10-CPU-Exynos5250-arm-Release-Android',
351  'Perf-Android-Clang-Nexus5-GPU-Adreno330-arm-Debug-Android',
352  'Perf-Android-Clang-Nexus7-GPU-Tegra3-arm-Release-Android',
353  'Perf-Android-Clang-NexusPlayer-GPU-PowerVR-x86-Release-Android',
354  'Perf-Android-Clang-NexusPlayer-GPU-PowerVR-x86-Release-Android_Vulkan',
355  'Perf-Android-Clang-PixelC-GPU-TegraX1-arm64-Release-Android',
356  'Perf-ChromeOS-Clang-Chromebook_C100p-GPU-MaliT764-arm-Release',
357  'Perf-Chromecast-GCC-Chorizo-CPU-Cortex_A7-arm-Debug',
358  'Perf-Chromecast-GCC-Chorizo-GPU-Cortex_A7-arm-Release',
359  'Perf-Mac-Clang-MacMini6.2-CPU-AVX-x86_64-Release',
360  'Perf-Mac-Clang-MacMini6.2-GPU-IntelHD4000-x86_64-Debug-CommandBuffer',
361  'Perf-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Release',
362  'Perf-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind',
363  ('Perf-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind' +
364  '_AbandonGpuContext'),
365  'Perf-Ubuntu16-Clang-NUC6i5SYK-GPU-IntelIris540-x86_64-Debug-Vulkan',
366  'Perf-Ubuntu16-Clang-NUC6i5SYK-GPU-IntelIris540-x86_64-Release',
367  'Perf-Win10-MSVC-AlphaR2-GPU-RadeonR9M470X-x86_64-Release-ANGLE',
368  'Perf-Win10-MSVC-NUC6i5SYK-GPU-IntelIris540-x86_64-Release-ANGLE',
369  'Perf-Win10-MSVC-NUC6i5SYK-GPU-IntelIris540-x86_64-Release-Vulkan',
370  'Perf-Win10-MSVC-ShuttleC-GPU-GTX960-x86_64-Release-ANGLE',
371  'Perf-Win2k8-MSVC-GCE-CPU-AVX2-x86_64-Debug',
372  'Perf-Win2k8-MSVC-GCE-CPU-AVX2-x86_64-Release',
373  'Perf-iOS-Clang-iPadMini4-GPU-GX6450-arm-Release'
374]
375
376
377def GenTests(api):
378  for builder in TEST_BUILDERS:
379    test = (
380      api.test(builder) +
381      api.properties(buildername=builder,
382                     revision='abc123',
383                     path_config='kitchen',
384                     swarm_out_dir='[SWARM_OUT_DIR]') +
385      api.path.exists(
386          api.path['start_dir'].join('skia'),
387          api.path['start_dir'].join('skia', 'infra', 'bots', 'assets',
388                                     'skimage', 'VERSION'),
389          api.path['start_dir'].join('skia', 'infra', 'bots', 'assets',
390                                     'skp', 'VERSION'),
391          api.path['start_dir'].join('tmp', 'uninteresting_hashes.txt')
392      ) +
393      api.step_data('get swarming bot id',
394          stdout=api.raw_io.output('skia-bot-123')) +
395      api.step_data('get swarming task id',
396          stdout=api.raw_io.output('123456'))
397    )
398    if 'Win' in builder:
399      test += api.platform('win', 64)
400
401    if 'Chromecast' in builder:
402      test += api.step_data(
403          'read chromecast ip',
404          stdout=api.raw_io.output('192.168.1.2:5555'))
405
406    if 'ChromeOS' in builder:
407      test += api.step_data(
408          'read chromeos ip',
409          stdout=api.raw_io.output('{"user_ip":"foo@127.0.0.1"}'))
410
411    yield test
412
413  builder = 'Perf-Win10-MSVC-ShuttleB-GPU-IntelHD4600-x86_64-Release'
414  yield (
415    api.test('trybot') +
416    api.properties(buildername=builder,
417                   revision='abc123',
418                   path_config='kitchen',
419                   swarm_out_dir='[SWARM_OUT_DIR]') +
420    api.properties(patch_storage='gerrit') +
421    api.properties.tryserver(
422          buildername=builder,
423          gerrit_project='skia',
424          gerrit_url='https://skia-review.googlesource.com/',
425      )+
426    api.path.exists(
427        api.path['start_dir'].join('skia'),
428        api.path['start_dir'].join('skia', 'infra', 'bots', 'assets',
429                                     'skimage', 'VERSION'),
430        api.path['start_dir'].join('skia', 'infra', 'bots', 'assets',
431                                     'skp', 'VERSION'),
432        api.path['start_dir'].join('skia', 'infra', 'bots', 'assets',
433                                     'svg', 'VERSION'),
434        api.path['start_dir'].join('tmp', 'uninteresting_hashes.txt')
435    )
436  )
437
438  builder = 'Perf-Android-Clang-NexusPlayer-CPU-SSE4-x86-Debug-Android'
439  yield (
440    api.test('failed_push') +
441    api.properties(buildername=builder,
442                   revision='abc123',
443                   path_config='kitchen',
444                   swarm_out_dir='[SWARM_OUT_DIR]') +
445    api.path.exists(
446        api.path['start_dir'].join('skia'),
447        api.path['start_dir'].join('skia', 'infra', 'bots', 'assets',
448                                     'skimage', 'VERSION'),
449        api.path['start_dir'].join('skia', 'infra', 'bots', 'assets',
450                                     'skp', 'VERSION'),
451        api.path['start_dir'].join('skia', 'infra', 'bots', 'assets',
452                                     'svg', 'VERSION'),
453        api.path['start_dir'].join('tmp', 'uninteresting_hashes.txt')
454    ) +
455    api.step_data('push [START_DIR]/skia/resources/* '+
456                  '/sdcard/revenge_of_the_skiabot/resources', retcode=1)
457  )
458