Commit 7ab22ee2 authored by Eric Stevenson's avatar Eric Stevenson Committed by Commit Bot

resource_sizes.py: Don't list static initializers by default.

Running tools/linux/dump-static-initializers.py is very slow on Android
so skip running it by default.

This should help with the backlog of pending builds on Android perf
builders. We only report the number of files with static initializers
on bots and we don't store the list of static initializers anywhere so
it isn't very helpful to print them at all.

Bug: 726718
Change-Id: I73628c101f138e9c8dc9347bceb813a979b55f6c
Reviewed-on: https://chromium-review.googlesource.com/529268Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Commit-Queue: Eric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#478386}
parent b56f5252
......@@ -593,7 +593,7 @@ def _AnnotatePakResources():
def _PrintStaticInitializersCountFromApk(apk_filename, tools_prefix,
chartjson=None):
dump_sis, chartjson=None):
with zipfile.ZipFile(apk_filename) as z:
so_files = [f for f in z.infolist()
if f.filename.endswith('.so') and f.file_size > 0]
......@@ -610,7 +610,8 @@ def _PrintStaticInitializersCountFromApk(apk_filename, tools_prefix,
unstripped_path = os.path.join(out_dir, 'lib.unstripped', lib_name)
if os.path.exists(unstripped_path):
si_count += _PrintStaticInitializersCount(
apk_filename, so_info.filename, unstripped_path, tools_prefix)
apk_filename, so_info.filename, unstripped_path, tools_prefix,
dump_sis)
else:
raise Exception('Unstripped .so not found. Looked here: %s',
unstripped_path)
......@@ -619,16 +620,16 @@ def _PrintStaticInitializersCountFromApk(apk_filename, tools_prefix,
def _PrintStaticInitializersCount(apk_path, apk_so_name, so_with_symbols_path,
tools_prefix):
tools_prefix, dump_sis):
"""Counts the number of static initializers in the given shared library.
Additionally, files for which static initializers were found are printed
on the standard output.
Args:
apk_path: Path to the apk.
apk_so_name: Name of the so.
so_with_symbols_path: Path to the unstripped libchrome.so file.
tools_prefix: Prefix for arch-specific version of binary utility tools.
dump_sis: Whether or not to run dump-static-initializers.py and print
the list of static initializers to stdout.
Returns:
The number of static initializers found.
"""
......@@ -639,14 +640,17 @@ def _PrintStaticInitializersCount(apk_path, apk_so_name, so_with_symbols_path,
with Unzip(apk_path, filename=apk_so_name) as unzipped_so:
_VerifyLibBuildIdsMatch(tools_prefix, unzipped_so, so_with_symbols_path)
readelf_si_count = CountStaticInitializers(unzipped_so, tools_prefix)
sis, dump_si_count = GetStaticInitializers(so_with_symbols_path, tools_prefix)
print ('Found %s files with static initializers using readelf\n'
'Found %s files with static initializers using '
'dump-static-initializers') % (readelf_si_count, dump_si_count)
print '\n'.join(sis)
if dump_sis:
sis, dump_si_count = GetStaticInitializers(
so_with_symbols_path, tools_prefix)
print ('Found %s files with static initializers using readelf\n'
'Found %s files with static initializers using '
'dump-static-initializers') % (readelf_si_count, dump_si_count)
print '\n'.join(sis)
return readelf_si_count
def _FormatBytes(byts):
"""Pretty-print a number of bytes."""
if byts > 2**20.0:
......@@ -738,9 +742,9 @@ def main():
argparser.add_argument('--no-output-dir', action='store_true',
help='Skip all measurements that rely on having '
'output-dir')
argparser.add_argument('--no-static-initializer-check', action='store_false',
dest='static_initializer_check', default=True,
help='Skip checking for static initializers')
argparser.add_argument('--dump-static-initializers', action='store_true',
help='Run dump-static-initializers.py to get the list'
'of static initializers (slow).')
argparser.add_argument('-d', '--device',
help='Dummy option for perf runner.')
argparser.add_argument('--estimate-patch-size', action='store_true',
......@@ -777,9 +781,9 @@ def main():
args.reference_apk_bucket, chartjson=chartjson)
if not args.no_output_dir:
PrintPakAnalysis(args.apk, args.min_pak_resource_size)
if args.static_initializer_check:
_PrintStaticInitializersCountFromApk(
args.apk, tools_prefix, chartjson=chartjson)
_PrintStaticInitializersCountFromApk(
args.apk, tools_prefix, args.dump_static_initializers,
chartjson=chartjson)
if chartjson:
results_path = os.path.join(args.output_dir, 'results-chart.json')
logging.critical('Dumping json to %s', results_path)
......
......@@ -161,9 +161,7 @@ class ResourceSizesDiff(BaseDiff):
cmd = [self._RESOURCE_SIZES_PATH, apk_path,'--output-dir', archive_dir,
'--no-output-dir', '--chartjson']
if self._slow_options:
cmd += ['--estimate-patch-size']
else:
cmd += ['--no-static-initializer-check']
cmd += ['--estimate-patch-size', '--dump-static-initializers']
_RunCmd(cmd)
with open(chartjson_file) as f:
chartjson = json.load(f)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment