Add Bloaty (with demangling) for wasm BuildStats

The bloaty here was compiled with this patch:
https://github.com/google/bloaty/pull/149

Hopefully that lands upstream and we can track master again.

This adds BuildStats.+Debug because we need symbols
to get sensical data. Bloaty's WASM support is experimental
and currently doesn't support having a stripped (Release)
version be profiled using the symbols of a Debug version.

This means that the buildStats for debug will be higher
than actual, but hopefully the absolute positioning will be
the same and thus the outputs useful.

Bug: skia:
Change-Id: Id7bf721843e8c52a0aae2b7e57ff95397693b3dd
Reviewed-on: https://skia-review.googlesource.com/c/163256
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
This commit is contained in:
Kevin Lubick 2018-10-18 13:35:04 -04:00 committed by Skia Commit-Bot
parent 2ba047972a
commit 8875baf99d
8 changed files with 407 additions and 26 deletions

View File

@ -1 +1 @@
0
1

View File

@ -0,0 +1,79 @@
# 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 web file."""
import json
import os
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': { }
}
magic_seperator = '#$%^&*'
print magic_seperator
print 'If you see lots of func[19] and such, go check out the debug build'
print ('Note that template instantiations are grouped together, '
'thus the elided types.')
print ('If you notice an unsymbolized "duplicate" entry, it is simply how '
'many bytes the function name itself takes up')
print subprocess.check_output([bloaty_path, input_file,
'-d', 'shortsymbols', '-n', '0'])
print magic_seperator
print 'If you see lots of func[19] and such, go check out the debug build'
print subprocess.check_output([bloaty_path, input_file,
'-d', 'fullsymbols', '-n', '0'])
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]
r = {
'total_size_bytes': os.path.getsize(input_file)
}
# Make a copy to avoid destroying the hardlinked file.
# Swarming hardlinks in the builds from isolated cache.
temp_file = input_file + '_tmp'
subprocess.check_call(['cp', input_file, temp_file])
subprocess.check_call(['gzip', temp_file])
r['gzip_size_bytes'] = os.path.getsize(temp_file + '.gz')
name = os.path.basename(input_file)
results['results'][name] = {
# We need this top level layer 'config'/slice
# Other analysis methods (e.g. libskia) might have
# slices for data on the 'code' section, etc.
'default' : r,
}
print magic_seperator
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

@ -988,16 +988,19 @@ func buildstats(b *specs.TasksCfgBuilder, name string, parts map[string]string,
task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("bloaty"))
b.MustAddTask(name, task)
// Always upload the results (just don't run the task otherwise.)
uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name)
extraProps := map[string]string{
"gs_bucket": CONFIG.GsBucketNano,
// Upload release results (for tracking in perf)
// We have some jobs that are FYI (e.g. Debug-CanvasKit)
if strings.Contains(name, "Release") {
uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name)
extraProps := map[string]string{
"gs_bucket": CONFIG.GsBucketNano,
}
uploadTask := kitchenTask(name, "upload_buildstats_results", "swarm_recipe.isolate", SERVICE_ACCOUNT_UPLOAD_NANO, linuxGceDimensions(MACHINE_TYPE_SMALL), extraProps, OUTPUT_NONE)
uploadTask.CipdPackages = append(uploadTask.CipdPackages, CIPD_PKGS_GSUTIL...)
uploadTask.Dependencies = append(uploadTask.Dependencies, name)
b.MustAddTask(uploadName, uploadTask)
return uploadName
}
uploadTask := kitchenTask(name, "upload_buildstats_results", "swarm_recipe.isolate", SERVICE_ACCOUNT_UPLOAD_NANO, linuxGceDimensions(MACHINE_TYPE_SMALL), extraProps, OUTPUT_NONE)
uploadTask.CipdPackages = append(uploadTask.CipdPackages, CIPD_PKGS_GSUTIL...)
uploadTask.Dependencies = append(uploadTask.Dependencies, name)
b.MustAddTask(uploadName, uploadTask)
return uploadName
return name
}

View File

@ -114,6 +114,8 @@
"BuildStats-Debian9-Clang-arm-Release-Flutter_Android",
"BuildStats-Debian9-Clang-x86_64-Release-Mini",
"BuildStats-Debian9-EMCC-asmjs-Release-PathKit",
"BuildStats-Debian9-EMCC-wasm-Debug-CanvasKit",
"BuildStats-Debian9-EMCC-wasm-Debug-CanvasKit_CPU",
"BuildStats-Debian9-EMCC-wasm-Release-CanvasKit",
"BuildStats-Debian9-EMCC-wasm-Release-CanvasKit_CPU",
"BuildStats-Debian9-EMCC-wasm-Release-PathKit",

View File

@ -162,18 +162,38 @@
"cmd": [
"python",
"-u",
"[START_DIR]/cache/work/skia/infra/bots/buildstats/buildstats_web.py",
"[START_DIR]/cache/work/skia/infra/bots/buildstats/buildstats_wasm.py",
"[START_DIR]/build/pathkit.wasm",
"[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"
"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/pathkit.wasm"
"name": "Analyze wasm",
"stdout": "/path/to/tmp/",
"~followup_annotations": [
"@@@STEP_LOG_LINE@bloaty_symbol_short@@@@",
"@@@STEP_LOG_LINE@bloaty_symbol_short@Report A@@@",
"@@@STEP_LOG_LINE@bloaty_symbol_short@ Total size: 50 bytes@@@",
"@@@STEP_LOG_LINE@bloaty_symbol_short@@@@",
"@@@STEP_LOG_END@bloaty_symbol_short@@@",
"@@@STEP_LOG_LINE@bloaty_symbol_full@@@@",
"@@@STEP_LOG_LINE@bloaty_symbol_full@Report B@@@",
"@@@STEP_LOG_LINE@bloaty_symbol_full@ Total size: 60 bytes@@@",
"@@@STEP_LOG_LINE@bloaty_symbol_full@@@@",
"@@@STEP_LOG_END@bloaty_symbol_full@@@",
"@@@STEP_LOG_LINE@perf_json@@@@",
"@@@STEP_LOG_LINE@perf_json@{@@@",
"@@@STEP_LOG_LINE@perf_json@ \"some\": \"json\"@@@",
"@@@STEP_LOG_LINE@perf_json@}@@@",
"@@@STEP_LOG_LINE@perf_json@@@@",
"@@@STEP_LOG_END@perf_json@@@"
]
},
{
"cmd": [

View File

@ -206,18 +206,38 @@
"cmd": [
"python",
"-u",
"[START_DIR]/cache/work/skia/infra/bots/buildstats/buildstats_web.py",
"[START_DIR]/cache/work/skia/infra/bots/buildstats/buildstats_wasm.py",
"[START_DIR]/build/pathkit.wasm",
"[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"
"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/pathkit.wasm"
"name": "Analyze wasm",
"stdout": "/path/to/tmp/",
"~followup_annotations": [
"@@@STEP_LOG_LINE@bloaty_symbol_short@@@@",
"@@@STEP_LOG_LINE@bloaty_symbol_short@Report A@@@",
"@@@STEP_LOG_LINE@bloaty_symbol_short@ Total size: 50 bytes@@@",
"@@@STEP_LOG_LINE@bloaty_symbol_short@@@@",
"@@@STEP_LOG_END@bloaty_symbol_short@@@",
"@@@STEP_LOG_LINE@bloaty_symbol_full@@@@",
"@@@STEP_LOG_LINE@bloaty_symbol_full@Report B@@@",
"@@@STEP_LOG_LINE@bloaty_symbol_full@ Total size: 60 bytes@@@",
"@@@STEP_LOG_LINE@bloaty_symbol_full@@@@",
"@@@STEP_LOG_END@bloaty_symbol_full@@@",
"@@@STEP_LOG_LINE@perf_json@@@@",
"@@@STEP_LOG_LINE@perf_json@{@@@",
"@@@STEP_LOG_LINE@perf_json@ \"some\": \"json\"@@@",
"@@@STEP_LOG_LINE@perf_json@}@@@",
"@@@STEP_LOG_LINE@perf_json@@@@",
"@@@STEP_LOG_END@perf_json@@@"
]
},
{
"cmd": [

View File

@ -38,7 +38,7 @@ def RunSteps(api):
test_data=['pathkit.wasm'])
analyzed += len(files)
if len(files):
analyze_web_file(api, checkout_root, out_dir, files)
analyze_wasm_file(api, checkout_root, out_dir, files)
files = api.file.glob_paths(
'find JS files',
@ -160,6 +160,32 @@ def analyze_flutter_lib(api, checkout_root, out_dir, files):
logs['perf_json'] = sections[5].split('\n')
# Get the size of skia in flutter and a few metrics from bloaty
def analyze_wasm_file(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_wasm.py')
step_data = api.run(api.python, 'Analyze wasm', script=script,
args=[f, out_dir, keystr, propstr, bloaty_exe],
stdout=api.raw_io.output())
if step_data and step_data.stdout:
magic_seperator = '#$%^&*'
sections = step_data.stdout.split(magic_seperator)
result = api.step.active_result
logs = result.presentation.logs
# Skip section 0 because it's everything before first print,
# which is probably the empty string.
logs['bloaty_symbol_short'] = sections[1].split('\n')
logs['bloaty_symbol_full'] = sections[2].split('\n')
logs['perf_json'] = sections[3].split('\n')
def GenTests(api):
builder = 'BuildStats-Debian9-EMCC-wasm-Release-PathKit'
yield (
@ -173,8 +199,10 @@ def GenTests(api):
stdout=api.raw_io.output('skia-bot-123')) +
api.step_data('get swarming task id',
stdout=api.raw_io.output('123456abc')) +
api.step_data('Analyze wasm',
stdout=api.raw_io.output(sample_wasm)) +
api.step_data('Analyze flutter',
stdout=api.raw_io.output(sample_output))
stdout=api.raw_io.output(sample_flutter))
)
yield (
@ -195,11 +223,26 @@ def GenTests(api):
gerrit_project='skia',
gerrit_url='https://skia-review.googlesource.com/',
) +
api.step_data('Analyze wasm',
stdout=api.raw_io.output(sample_wasm)) +
api.step_data('Analyze flutter',
stdout=api.raw_io.output(sample_output))
stdout=api.raw_io.output(sample_flutter))
)
sample_output = """
sample_wasm = """
#$%^&*
Report A
Total size: 50 bytes
#$%^&*
Report B
Total size: 60 bytes
#$%^&*
{
"some": "json"
}
"""
sample_flutter = """
#$%^&*
Report A
Total size: 50 bytes

View File

@ -580,6 +580,16 @@
"Upload-BuildStats-Debian9-EMCC-asmjs-Release-PathKit"
]
},
"BuildStats-Debian9-EMCC-wasm-Debug-CanvasKit": {
"tasks": [
"BuildStats-Debian9-EMCC-wasm-Debug-CanvasKit"
]
},
"BuildStats-Debian9-EMCC-wasm-Debug-CanvasKit_CPU": {
"tasks": [
"BuildStats-Debian9-EMCC-wasm-Debug-CanvasKit_CPU"
]
},
"BuildStats-Debian9-EMCC-wasm-Release-CanvasKit": {
"tasks": [
"Upload-BuildStats-Debian9-EMCC-wasm-Release-CanvasKit"
@ -17539,7 +17549,7 @@
{
"name": "skia/bots/bloaty",
"path": "bloaty",
"version": "version:0"
"version": "version:1"
}
],
"command": [
@ -17640,7 +17650,7 @@
{
"name": "skia/bots/bloaty",
"path": "bloaty",
"version": "version:0"
"version": "version:1"
}
],
"command": [
@ -17741,7 +17751,7 @@
{
"name": "skia/bots/bloaty",
"path": "bloaty",
"version": "version:0"
"version": "version:1"
}
],
"command": [
@ -17817,6 +17827,210 @@
"perf"
]
},
"BuildStats-Debian9-EMCC-wasm-Debug-CanvasKit": {
"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:1"
}
],
"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-EMCC-wasm-Debug-CanvasKit\",\"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-EMCC-wasm-Debug-CanvasKit"
],
"dimensions": [
"cpu:x86-64-Haswell_GCE",
"gpu:none",
"machine_type:n1-standard-16",
"os:Debian-9.4",
"pool:Skia",
"docker_installed:true"
],
"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-wasm-Debug-CanvasKit_CPU": {
"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:1"
}
],
"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-EMCC-wasm-Debug-CanvasKit_CPU\",\"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-EMCC-wasm-Debug-CanvasKit_CPU"
],
"dimensions": [
"cpu:x86-64-Haswell_GCE",
"gpu:none",
"machine_type:n1-standard-16",
"os:Debian-9.4",
"pool:Skia",
"docker_installed:true"
],
"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-wasm-Release-CanvasKit": {
"caches": [
{
@ -17843,7 +18057,7 @@
{
"name": "skia/bots/bloaty",
"path": "bloaty",
"version": "version:0"
"version": "version:1"
}
],
"command": [
@ -17945,7 +18159,7 @@
{
"name": "skia/bots/bloaty",
"path": "bloaty",
"version": "version:0"
"version": "version:1"
}
],
"command": [
@ -18047,7 +18261,7 @@
{
"name": "skia/bots/bloaty",
"path": "bloaty",
"version": "version:0"
"version": "version:1"
}
],
"command": [