Add BuildStats job for Mini

Bug: skia:
Change-Id: Ibb47179315d191af5023039212e4c9b5e784bb75
Reviewed-on: https://skia-review.googlesource.com/c/160765
Reviewed-by: Eric Boren <borenet@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
Kevin Lubick 2018-10-09 13:31:33 -04:00
parent 46acf9dac3
commit 6ca0d8a767
14 changed files with 566 additions and 8 deletions

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,26 @@
#!/usr/bin/env python
#
# Copyright 2017 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Common vars used by scripts in this directory."""
import os
import sys
FILE_DIR = os.path.dirname(os.path.abspath(__file__))
INFRA_BOTS_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir, os.pardir))
sys.path.insert(0, INFRA_BOTS_DIR)
from assets import assets
ASSET_NAME = os.path.basename(FILE_DIR)
def run(cmd):
"""Run a command, eg. "upload" or "download". """
assets.main([cmd, ASSET_NAME] + sys.argv[1:])

View File

@ -0,0 +1,42 @@
#!/usr/bin/env python
#
# Copyright 2017 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Create Bloaty as a Linux executable."""
import argparse
import os
import subprocess
import shutil
import utils
REPO = 'https://github.com/google/bloaty'
TAG = 'v1.0'
def create_asset(target_dir):
with utils.tmp_dir():
# Check out bloaty
subprocess.check_call(['git', 'clone', '--depth', '1', '-b', TAG,
'--single-branch', REPO])
os.chdir('bloaty')
# Build bloaty
subprocess.check_call(['cmake', '.'])
subprocess.check_call(['make', '-j'])
shutil.move('./bloaty', target_dir)
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--target_dir', '-t', required=True)
args = parser.parse_args()
create_asset(args.target_dir)
if __name__ == '__main__':
main()

View File

@ -0,0 +1,42 @@
#!/usr/bin/env python
#
# Copyright 2017 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Create the asset and upload it."""
import argparse
import common
import os
import subprocess
import sys
import utils
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--gsutil')
args = parser.parse_args()
with utils.tmp_dir():
cwd = os.getcwd()
create_script = os.path.join(common.FILE_DIR, 'create.py')
upload_script = os.path.join(common.FILE_DIR, 'upload.py')
try:
subprocess.check_call(['python', create_script, '-t', cwd])
cmd = ['python', upload_script, '-t', cwd]
if args.gsutil:
cmd.extend(['--gsutil', args.gsutil])
subprocess.check_call(cmd)
except subprocess.CalledProcessError:
# Trap exceptions to avoid printing two stacktraces.
sys.exit(1)
if __name__ == '__main__':
main()

View File

@ -0,0 +1,16 @@
#!/usr/bin/env python
#
# Copyright 2017 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Download the current version of the asset."""
import common
if __name__ == '__main__':
common.run('download')

View File

@ -0,0 +1,16 @@
#!/usr/bin/env python
#
# Copyright 2017 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Upload a new version of the asset."""
import common
if __name__ == '__main__':
common.run('upload')

View File

@ -0,0 +1,87 @@
# Copyright 2018 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.
"""Writes a Perf-formated json file with stats about the given cpp file."""
import csv
import json
import os
import re
import subprocess
import sys
def main():
input_file = sys.argv[1]
out_dir = sys.argv[2]
keystr = sys.argv[3]
propstr = sys.argv[4]
bloaty_path = sys.argv[5]
results = {
'key': { },
'results': { }
}
props = propstr.split(' ')
for i in range(0, len(props), 2):
results[props[i]] = props[i+1]
keys = keystr.split(' ')
for i in range(0, len(keys), 2):
results['key'][keys[i]] = keys[i+1]
# Human "readable" overview as an FYI.
print ('Note that template instantiations are grouped together, '
'thus the elided types.')
print subprocess.check_output([bloaty_path, input_file,
'-d', 'sections,shortsymbols', '-n', '200'])
print ' '
sections = subprocess.check_output([bloaty_path, input_file, '-d',
'sections', '-n', '0', '--csv'])
name = os.path.basename(input_file)
r = {
# Use the default config as stats about the whole binary
'default' : {
'total_size_bytes': os.path.getsize(input_file)
},
}
# report section by section data. Sections are like .text, .data, etc.
for section_row in sections.strip().split('\n'):
# Follows schema sections,vmsize,filesize
parts = section_row.split(',')
if len(parts) < 3 or parts[0] == 'sections':
# If we see section, that's the table header
continue
section = parts[0]
# part[1] is "VM Size", part[2] is "File Size". From the bloaty docs:
# The "VM SIZE" column tells you how much space the binary will take
# when it is loaded into memory. The "FILE SIZE" column tells you about
# how much space the binary is taking on disk.
vmsize = parts[1] # In bytes
filesize = parts[2] # In bytes
section = re.sub('[^0-9a-zA-Z_]', '_', section)
r['section'+section] = {
'in_file_size_bytes': int(filesize),
'vm_size_bytes': int(vmsize),
}
results['results'][name] = r
# Make debugging easier
print json.dumps(results, indent=2)
with open(os.path.join(out_dir, name+'.json'), 'w') as output:
output.write(json.dumps(results, indent=2))
if '__main__' == __name__:
main()

View File

@ -974,6 +974,7 @@ func infra(b *specs.TasksCfgBuilder, name string) string {
func buildstats(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string) string {
task := kitchenTask(name, "compute_buildstats", "swarm_recipe.isolate", "", swarmDimensions(parts), nil, OUTPUT_PERF)
task.Dependencies = append(task.Dependencies, compileTaskName)
task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("bloaty"))
b.MustAddTask(name, task)
// Always upload the results (just don't run the task otherwise.)

View File

@ -112,6 +112,7 @@
"BuildStats-Debian9-EMCC-asmjs-Release-PathKit",
"BuildStats-Debian9-EMCC-wasm-Release-CanvasKit",
"BuildStats-Debian9-EMCC-wasm-Release-PathKit",
"BuildStats-Debian9-Clang-x86_64-Release-Mini",
"Calmbench-Debian9-Clang-GCE-CPU-AVX2-x86_64-Release-All",
"Calmbench-Ubuntu17-Clang-Golo-GPU-QuadroP400-x86_64-Release-All",
"Housekeeper-Nightly-Bookmaker",

View File

@ -162,7 +162,7 @@
"cmd": [
"python",
"-u",
"[START_DIR]/cache/work/skia/infra/bots/buildstats_web.py",
"[START_DIR]/cache/work/skia/infra/bots/buildstats/buildstats_web.py",
"[START_DIR]/build/pathkit.wasm",
"[START_DIR]/[SWARM_OUT_DIR]",
"compiler EMCC configuration Release extra_config PathKit os Debian9 target_arch wasm",
@ -199,7 +199,7 @@
"cmd": [
"python",
"-u",
"[START_DIR]/cache/work/skia/infra/bots/buildstats_web.py",
"[START_DIR]/cache/work/skia/infra/bots/buildstats/buildstats_web.py",
"[START_DIR]/build/pathkit.js",
"[START_DIR]/[SWARM_OUT_DIR]",
"compiler EMCC configuration Release extra_config PathKit os Debian9 target_arch wasm",
@ -236,7 +236,7 @@
"cmd": [
"python",
"-u",
"[START_DIR]/cache/work/skia/infra/bots/buildstats_web.py",
"[START_DIR]/cache/work/skia/infra/bots/buildstats/buildstats_web.py",
"[START_DIR]/build/pathkit.js.mem",
"[START_DIR]/[SWARM_OUT_DIR]",
"compiler EMCC configuration Release extra_config PathKit os Debian9 target_arch wasm",
@ -249,6 +249,44 @@
},
"name": "Analyze [START_DIR]/build/pathkit.js.mem"
},
{
"cmd": [
"python",
"-u",
"RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
"--json-output",
"/path/to/tmp/json",
"glob",
"[START_DIR]/build",
"*.so"
],
"cwd": "[START_DIR]/build",
"infra_step": true,
"name": "find built libraries",
"stdout": "/path/to/tmp/",
"~followup_annotations": [
"@@@STEP_LOG_LINE@glob@[START_DIR]/build/libskia.so@@@",
"@@@STEP_LOG_END@glob@@@"
]
},
{
"cmd": [
"python",
"-u",
"[START_DIR]/cache/work/skia/infra/bots/buildstats/buildstats_cpp.py",
"[START_DIR]/build/libskia.so",
"[START_DIR]/[SWARM_OUT_DIR]",
"compiler EMCC configuration Release extra_config PathKit os Debian9 target_arch wasm",
"gitHash abc123 swarming_bot_id skia-bot-123 swarming_task_id 123456abc",
"[START_DIR]/bloaty/bloaty"
],
"cwd": "[START_DIR]/cache/work/skia",
"env": {
"CHROME_HEADLESS": "1",
"PATH": "<PATH>:RECIPE_PACKAGE_REPO[depot_tools]"
},
"name": "Analyze [START_DIR]/build/libskia.so"
},
{
"name": "$result",
"recipe_result": null,

View File

@ -206,7 +206,7 @@
"cmd": [
"python",
"-u",
"[START_DIR]/cache/work/skia/infra/bots/buildstats_web.py",
"[START_DIR]/cache/work/skia/infra/bots/buildstats/buildstats_web.py",
"[START_DIR]/build/pathkit.wasm",
"[START_DIR]/[SWARM_OUT_DIR]",
"compiler EMCC configuration Release extra_config PathKit os Debian9 target_arch wasm",
@ -243,7 +243,7 @@
"cmd": [
"python",
"-u",
"[START_DIR]/cache/work/skia/infra/bots/buildstats_web.py",
"[START_DIR]/cache/work/skia/infra/bots/buildstats/buildstats_web.py",
"[START_DIR]/build/pathkit.js",
"[START_DIR]/[SWARM_OUT_DIR]",
"compiler EMCC configuration Release extra_config PathKit os Debian9 target_arch wasm",
@ -280,7 +280,7 @@
"cmd": [
"python",
"-u",
"[START_DIR]/cache/work/skia/infra/bots/buildstats_web.py",
"[START_DIR]/cache/work/skia/infra/bots/buildstats/buildstats_web.py",
"[START_DIR]/build/pathkit.js.mem",
"[START_DIR]/[SWARM_OUT_DIR]",
"compiler EMCC configuration Release extra_config PathKit os Debian9 target_arch wasm",
@ -293,6 +293,44 @@
},
"name": "Analyze [START_DIR]/build/pathkit.js.mem"
},
{
"cmd": [
"python",
"-u",
"RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
"--json-output",
"/path/to/tmp/json",
"glob",
"[START_DIR]/build",
"*.so"
],
"cwd": "[START_DIR]/build",
"infra_step": true,
"name": "find built libraries",
"stdout": "/path/to/tmp/",
"~followup_annotations": [
"@@@STEP_LOG_LINE@glob@[START_DIR]/build/libskia.so@@@",
"@@@STEP_LOG_END@glob@@@"
]
},
{
"cmd": [
"python",
"-u",
"[START_DIR]/cache/work/skia/infra/bots/buildstats/buildstats_cpp.py",
"[START_DIR]/build/libskia.so",
"[START_DIR]/[SWARM_OUT_DIR]",
"compiler EMCC configuration Release extra_config PathKit os Debian9 target_arch wasm",
"gitHash abc123 swarming_bot_id skia-bot-123 swarming_task_id 123456abc issue 456789 patchset 12 patch_storage gerrit",
"[START_DIR]/bloaty/bloaty"
],
"cwd": "[START_DIR]/cache/work/skia",
"env": {
"CHROME_HEADLESS": "1",
"PATH": "<PATH>:RECIPE_PACKAGE_REPO[depot_tools]"
},
"name": "Analyze [START_DIR]/build/libskia.so"
},
{
"name": "$result",
"recipe_result": null,

View File

@ -29,12 +29,14 @@ def RunSteps(api):
api.file.ensure_directory('mkdirs out_dir', out_dir, mode=0777)
analyzed = 0
with api.context(cwd=bin_dir):
files = api.file.glob_paths(
'find WASM binaries',
bin_dir,
'*.wasm',
test_data=['pathkit.wasm'])
analyzed += len(files)
if len(files):
analyze_web_file(api, checkout_root, out_dir, files)
@ -43,6 +45,7 @@ def RunSteps(api):
bin_dir,
'*.js',
test_data=['pathkit.js'])
analyzed += len(files)
if len(files):
analyze_web_file(api, checkout_root, out_dir, files)
@ -51,9 +54,21 @@ def RunSteps(api):
bin_dir,
'*.js.mem',
test_data=['pathkit.js.mem'])
analyzed += len(files)
if len(files):
analyze_web_file(api, checkout_root, out_dir, files)
files = api.file.glob_paths(
'find built libraries',
bin_dir,
'*.so',
test_data=['libskia.so'])
analyzed += len(files)
if len(files):
analyze_cpp_lib(api, checkout_root, out_dir, files)
if not analyzed: # pragma: nocover
raise Exception('No files were analyzed!')
def keys_and_props(api):
keys = []
@ -86,9 +101,24 @@ def analyze_web_file(api, checkout_root, out_dir, files):
for f in files:
skia_dir = checkout_root.join('skia')
with api.context(cwd=skia_dir):
script = skia_dir.join('infra', 'bots', 'buildstats_web.py')
script = skia_dir.join('infra', 'bots', 'buildstats',
'buildstats_web.py')
api.run(api.python, 'Analyze %s' % f, script=script,
args=[f, out_dir, keystr, propstr])
args=[f, out_dir, keystr, propstr])
# Get the raw size and a few metrics from bloaty
def analyze_cpp_lib(api, checkout_root, out_dir, files):
(keystr, propstr) = keys_and_props(api)
bloaty_exe = api.path['start_dir'].join('bloaty', 'bloaty')
for f in files:
skia_dir = checkout_root.join('skia')
with api.context(cwd=skia_dir):
script = skia_dir.join('infra', 'bots', 'buildstats',
'buildstats_cpp.py')
api.run(api.python, 'Analyze %s' % f, script=script,
args=[f, out_dir, keystr, propstr, bloaty_exe])
def GenTests(api):

View File

@ -554,6 +554,11 @@
"Build-Win-MSVC-x86_64-Release-Vulkan"
]
},
"BuildStats-Debian9-Clang-x86_64-Release-Mini": {
"tasks": [
"Upload-BuildStats-Debian9-Clang-x86_64-Release-Mini"
]
},
"BuildStats-Debian9-EMCC-asmjs-Release-PathKit": {
"tasks": [
"Upload-BuildStats-Debian9-EMCC-asmjs-Release-PathKit"
@ -17178,6 +17183,107 @@
],
"service_account": "skia-external-compile-tasks@skia-swarming-bots.iam.gserviceaccount.com"
},
"BuildStats-Debian9-Clang-x86_64-Release-Mini": {
"caches": [
{
"name": "vpython",
"path": "cache/vpython"
}
],
"cipd_packages": [
{
"name": "infra/tools/luci/kitchen/${platform}",
"path": ".",
"version": "git_revision:546aae39f1fb9dce9add528e2011afa574535ecd"
},
{
"name": "infra/tools/luci-auth/${platform}",
"path": "cipd_bin_packages",
"version": "git_revision:e1abc57be62d198b5c2f487bfb2fa2d2eb0e867c"
},
{
"name": "infra/tools/luci/vpython/${platform}",
"path": "cipd_bin_packages",
"version": "git_revision:b6cdec8586c9f8d3d728b1bc0bd4331330ba66fc"
},
{
"name": "skia/bots/bloaty",
"path": "bloaty",
"version": "version:0"
}
],
"command": [
"./kitchen${EXECUTABLE_SUFFIX}",
"cook",
"-checkout-dir",
"recipe_bundle",
"-mode",
"swarming",
"-luci-system-account",
"system",
"-cache-dir",
"cache",
"-temp-dir",
"tmp",
"-known-gerrit-host",
"android.googlesource.com",
"-known-gerrit-host",
"boringssl.googlesource.com",
"-known-gerrit-host",
"chromium.googlesource.com",
"-known-gerrit-host",
"dart.googlesource.com",
"-known-gerrit-host",
"fuchsia.googlesource.com",
"-known-gerrit-host",
"go.googlesource.com",
"-known-gerrit-host",
"llvm.googlesource.com",
"-known-gerrit-host",
"skia.googlesource.com",
"-known-gerrit-host",
"webrtc.googlesource.com",
"-output-result-json",
"${ISOLATED_OUTDIR}/build_result_filename",
"-workdir",
".",
"-recipe",
"compute_buildstats",
"-properties",
"{\"$kitchen\":{\"devshell\":true,\"git_auth\":true},\"buildbucket_build_id\":\"<(BUILDBUCKET_BUILD_ID)\",\"buildername\":\"BuildStats-Debian9-Clang-x86_64-Release-Mini\",\"patch_issue\":\"<(ISSUE)\",\"patch_ref\":\"<(PATCH_REF)\",\"patch_repo\":\"<(PATCH_REPO)\",\"patch_set\":\"<(PATCHSET)\",\"patch_storage\":\"<(PATCH_STORAGE)\",\"repository\":\"<(REPO)\",\"revision\":\"<(REVISION)\",\"swarm_out_dir\":\"perf\"}",
"-logdog-annotation-url",
"logdog://logs.chromium.org/skia/<(TASK_ID)/+/annotations"
],
"dependencies": [
"Housekeeper-PerCommit-BundleRecipes",
"Build-Debian9-Clang-x86_64-Release-Mini"
],
"dimensions": [
"cpu:x86-64-Haswell_GCE",
"gpu:none",
"machine_type:n1-highcpu-64",
"os:Debian-9.4",
"pool:Skia"
],
"env_prefixes": {
"PATH": [
"cipd_bin_packages",
"cipd_bin_packages/bin"
],
"VPYTHON_VIRTUALENV_ROOT": [
"cache/vpython"
]
},
"execution_timeout_ns": 3600000000000,
"extra_tags": {
"log_location": "logdog://logs.chromium.org/skia/<(TASK_ID)/+/annotations"
},
"io_timeout_ns": 3600000000000,
"isolate": "swarm_recipe.isolate",
"outputs": [
"perf"
]
},
"BuildStats-Debian9-EMCC-asmjs-Release-PathKit": {
"caches": [
{
@ -17200,6 +17306,11 @@
"name": "infra/tools/luci/vpython/${platform}",
"path": "cipd_bin_packages",
"version": "git_revision:b6cdec8586c9f8d3d728b1bc0bd4331330ba66fc"
},
{
"name": "skia/bots/bloaty",
"path": "bloaty",
"version": "version:0"
}
],
"command": [
@ -17296,6 +17407,11 @@
"name": "infra/tools/luci/vpython/${platform}",
"path": "cipd_bin_packages",
"version": "git_revision:b6cdec8586c9f8d3d728b1bc0bd4331330ba66fc"
},
{
"name": "skia/bots/bloaty",
"path": "bloaty",
"version": "version:0"
}
],
"command": [
@ -17392,6 +17508,11 @@
"name": "infra/tools/luci/vpython/${platform}",
"path": "cipd_bin_packages",
"version": "git_revision:b6cdec8586c9f8d3d728b1bc0bd4331330ba66fc"
},
{
"name": "skia/bots/bloaty",
"path": "bloaty",
"version": "version:0"
}
],
"command": [
@ -68419,6 +68540,105 @@
"isolate": "swarm_recipe.isolate",
"service_account": "skia-external-binary-uploader@skia-swarming-bots.iam.gserviceaccount.com"
},
"Upload-BuildStats-Debian9-Clang-x86_64-Release-Mini": {
"caches": [
{
"name": "vpython",
"path": "cache/vpython"
}
],
"cipd_packages": [
{
"name": "infra/tools/luci/kitchen/${platform}",
"path": ".",
"version": "git_revision:546aae39f1fb9dce9add528e2011afa574535ecd"
},
{
"name": "infra/tools/luci-auth/${platform}",
"path": "cipd_bin_packages",
"version": "git_revision:e1abc57be62d198b5c2f487bfb2fa2d2eb0e867c"
},
{
"name": "infra/tools/luci/vpython/${platform}",
"path": "cipd_bin_packages",
"version": "git_revision:b6cdec8586c9f8d3d728b1bc0bd4331330ba66fc"
},
{
"name": "infra/gsutil",
"path": "cipd_bin_packages",
"version": "version:4.28"
}
],
"command": [
"./kitchen${EXECUTABLE_SUFFIX}",
"cook",
"-checkout-dir",
"recipe_bundle",
"-mode",
"swarming",
"-luci-system-account",
"system",
"-cache-dir",
"cache",
"-temp-dir",
"tmp",
"-known-gerrit-host",
"android.googlesource.com",
"-known-gerrit-host",
"boringssl.googlesource.com",
"-known-gerrit-host",
"chromium.googlesource.com",
"-known-gerrit-host",
"dart.googlesource.com",
"-known-gerrit-host",
"fuchsia.googlesource.com",
"-known-gerrit-host",
"go.googlesource.com",
"-known-gerrit-host",
"llvm.googlesource.com",
"-known-gerrit-host",
"skia.googlesource.com",
"-known-gerrit-host",
"webrtc.googlesource.com",
"-output-result-json",
"${ISOLATED_OUTDIR}/build_result_filename",
"-workdir",
".",
"-recipe",
"upload_buildstats_results",
"-properties",
"{\"$kitchen\":{\"devshell\":true,\"git_auth\":true},\"buildbucket_build_id\":\"<(BUILDBUCKET_BUILD_ID)\",\"buildername\":\"BuildStats-Debian9-Clang-x86_64-Release-Mini\",\"gs_bucket\":\"skia-perf\",\"patch_issue\":\"<(ISSUE)\",\"patch_ref\":\"<(PATCH_REF)\",\"patch_repo\":\"<(PATCH_REPO)\",\"patch_set\":\"<(PATCHSET)\",\"patch_storage\":\"<(PATCH_STORAGE)\",\"repository\":\"<(REPO)\",\"revision\":\"<(REVISION)\",\"swarm_out_dir\":\"output_ignored\"}",
"-logdog-annotation-url",
"logdog://logs.chromium.org/skia/<(TASK_ID)/+/annotations"
],
"dependencies": [
"Housekeeper-PerCommit-BundleRecipes",
"BuildStats-Debian9-Clang-x86_64-Release-Mini"
],
"dimensions": [
"cpu:x86-64-Haswell_GCE",
"gpu:none",
"machine_type:n1-highmem-2",
"os:Debian-9.4",
"pool:Skia"
],
"env_prefixes": {
"PATH": [
"cipd_bin_packages",
"cipd_bin_packages/bin"
],
"VPYTHON_VIRTUALENV_ROOT": [
"cache/vpython"
]
},
"execution_timeout_ns": 3600000000000,
"extra_tags": {
"log_location": "logdog://logs.chromium.org/skia/<(TASK_ID)/+/annotations"
},
"io_timeout_ns": 3600000000000,
"isolate": "swarm_recipe.isolate",
"service_account": "skia-external-nano-uploader@skia-swarming-bots.iam.gserviceaccount.com"
},
"Upload-BuildStats-Debian9-EMCC-asmjs-Release-PathKit": {
"caches": [
{