Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(747)

Unified Diff: scripts/slave/recipes/perf/ct_top1k_rr_perf.py

Issue 1423993007: CT Perf recipe to run benchmarks on the top 1k sites using swarming (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build@master
Patch Set: Use isolate and swarming recipes Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: scripts/slave/recipes/perf/ct_top1k_rr_perf.py
diff --git a/scripts/slave/recipes/perf/ct_top1k_rr_perf.py b/scripts/slave/recipes/perf/ct_top1k_rr_perf.py
new file mode 100644
index 0000000000000000000000000000000000000000..cba3c7fa8ec9a823bc812b3390f5ae75e2d5f975
--- /dev/null
+++ b/scripts/slave/recipes/perf/ct_top1k_rr_perf.py
@@ -0,0 +1,109 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+DEPS = [
+ 'archive',
+ 'ct_swarming',
+ 'file',
+ 'properties',
+ 'step',
+ 'time',
+]
+
+
+CT_PAGE_TYPE = '1k'
+CT_BINARY = 'run_chromium_perf_swarming'
+CT_ISOLATE_TEMPLATE = 'ct_top1k.isolate.tmpl'
+
+# Number of slaves to shard CT runs to.
+# TODO(rmistry): Change the below to 100 when ready to run the full top 1k.
+CT_NUM_SLAVES = 2
+
+
+def _DownloadAndExtractBinary(api):
+ """Downloads the binary from the revision passed to the recipe."""
+ api.archive.download_and_unzip_build(
+ step_name='Download and Extract Binary',
+ target='Release',
+ build_url=None, # This is a required parameter, but has no effect.
+ build_archive_url=api.properties['parent_build_archive_url'])
+
+
+def RunSteps(api):
+ # Figure out which benchmark to use.
+ buildername = api.properties['buildername']
+ if 'Repaint' in buildername:
+ benchmark = 'repaint'
+ elif 'RR' in buildername:
+ benchmark = 'rasterize_and_record_micro'
+ else:
+ raise Exception('Do not recognise the buildername %s.' % buildername)
+
+ # Checkout chromium and swarming.
+ api.ct_swarming.checkout_dependencies()
+
+ # Download the prebuilt chromium binary.
+ _DownloadAndExtractBinary(api)
+
+ # Download Cluster Telemetry binary.
+ api.ct_swarming.download_CT_binary(CT_BINARY)
+
+ # Record how long the step took in swarming tasks.
+ swarming_start_time = api.time.time()
+
+ for slave_num in range(1, CT_NUM_SLAVES + 1):
+ slave_dir = api.ct_swarming.downloads_dir.join('slave%s' % slave_num)
+
+ # Download page sets and archives.
+ api.ct_swarming.download_page_artifacts(CT_PAGE_TYPE, slave_num, slave_dir)
M-A Ruel 2015/11/12 17:33:41 IMHO You shouldn't pass an arbitrary path, the pat
rmistry 2015/11/13 14:59:58 Done. Not returning the path because the downloads
+
+ # TODO(rmistry): Remove the entire below section after crrev.com/1410353007
+ # is submitted.
+ api.file.copy(
+ 'copy %s' % CT_ISOLATE_TEMPLATE,
+ '/repos/chromium/src/chrome/%s' % CT_ISOLATE_TEMPLATE,
+ api.ct_swarming.chromium_src_dir.join('chrome', CT_ISOLATE_TEMPLATE))
+ for f in ['run_ct_top1k.py', 'path_util.py']:
+ api.file.copy(
+ 'copy %s' % f,
+ '/repos/chromium/src/content/test/ct/%s' % f,
+ api.ct_swarming.chromium_src_dir.join('content', 'test', 'ct', f))
+
+ # Create this slave's isolate file from the CT_ISOLATE_TEMPLATE.
+ isolate_dir = api.ct_swarming.chromium_src_dir.join('chrome')
+ isolate_template_path = isolate_dir.join(CT_ISOLATE_TEMPLATE)
+ generated_isolate_path = isolate_dir.join(
+ 'slave%s.ct_top1k.isolate' % slave_num)
+ with open(str(generated_isolate_path), 'wb') as fout:
+ with open(str(isolate_template_path), 'rb') as fin:
+ for line in fin:
+ fout.write(line.replace('[[SLAVE_NUM]]', str(slave_num))
+ .replace('[[MASTER]]', api.properties['mastername'])
+ .replace('[[BUILDER]]', api.properties['buildername'])
+ .replace('[[GIT_HASH]]',
+ api.properties['git_revision'])
+ .replace('[[BENCHMARK]]', benchmark))
+
+ # Create the slave's isolated.gen.json file to use for batcharchiving.
+ api.ct_swarming.create_isolated_gen_json(
+ generated_isolate_path, isolate_dir, 'linux', slave_num)
+
+ # Batcharchive everything on the isolate server for efficiency.
+ api.ct_swarming.batcharchive(CT_NUM_SLAVES)
+ swarm_hashes = (
+ api.step.active_result.presentation.properties['swarm_hashes']).values()
+
+ # Trigger all swarming tasks.
+ api.ct_swarming.trigger_swarming_tasks(
+ swarm_hashes, task_name_prefix='ct-1k-task',
+ dimensions={'os': 'Ubuntu', 'gpu': '10de'})
+
+ # Now collect all tasks.
+ api.ct_swarming.collect_swarming_tasks()
+
+ api.ct_swarming.cleanup()
+
+ print ('Running isolating, triggering and collecting swarming tasks took a '
+ 'total of %s seconds') % (api.time.time() - swarming_start_time)

Powered by Google App Engine
This is Rietveld 408576698