0

android-binary-size: Measure TrichromeLibrary64.apk

Reports the total size change for high-end arm64 builds.
Does not provide a symbol breakdown for fear it being too slow.

Bug: 41492030
Change-Id: I2e7ba50959d5535ad1ee6b800e2feaa740ef7b92
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5345332
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Haiyang Pan <hypan@google.com>
Cr-Commit-Position: refs/heads/main@{#1269262}
This commit is contained in:
Andrew Grieve
2024-03-06 22:06:40 +00:00
committed by Chromium LUCI CQ
parent a0fd45a02b
commit 3874484a2e
3 changed files with 47 additions and 19 deletions

@ -31,10 +31,10 @@ The bot provides analysis using:
### Binary Size Increase
- **What:** Checks that [normalized apk size] increases by no more than 16kb.
- **Why:** While we hope that binary size impact of all commits are looked at
to ensure they make sense, this check is to ensure they are looked at for
larger than average commits.
- **What:** Checks that [normalized apk size] increases by no more than 16kb on
arm32, and 64kb on high-end arm64.
- **Why:** To ensure that larger-than-average size changes are understood and
intentional.
[normalized apk size]: /docs/speed/binary_size/metrics.md#normalized-apk-size

@ -134,18 +134,14 @@ def main():
files_to_copy.append(args.size_config_json)
_copy_files_to_staging_dir(files_to_copy, make_staging_path)
config_32 = config['to_resource_sizes_py']
_generate_resource_sizes(config_32, make_chromium_output_path,
make_staging_path, 'resource_sizes_32.json')
config_64 = config.get('to_resource_sizes_py_64')
if config_64:
_generate_resource_sizes(config_64, make_chromium_output_path,
make_staging_path, 'resource_sizes_64.json')
config_32 = config['to_resource_sizes_py']
_generate_resource_sizes(config_32, make_chromium_output_path,
make_staging_path, 'resource_sizes_32.json')
# TODO(41492030). Remove copy.
shutil.copy(make_staging_path('resource_sizes_32.json'),
make_staging_path('results-chart.json'))
_generate_supersize_archive(supersize_input_file, make_chromium_output_path,
make_staging_path)

@ -44,6 +44,7 @@ import models
import native_disassembly
_RESOURCE_SIZES_LOG = 'resource_sizes_log'
_RESOURCE_SIZES_64_LOG = 'resource_sizes_64_log'
_BASE_RESOURCE_SIZES_LOG = 'base_resource_sizes_log'
_MUTABLE_CONSTANTS_LOG = 'mutable_contstants_log'
_FOR_TESTING_LOG = 'for_test_log'
@ -156,7 +157,8 @@ def _CreateMethodCountDelta(symbols, max_increase):
def _CreateResourceSizesDelta(before_dir, after_dir, max_increase):
sizes_diff = diagnose_bloat.ResourceSizesDiff()
sizes_diff = diagnose_bloat.ResourceSizesDiff(
filename='resource_sizes_32.json')
sizes_diff.ProduceDiff(before_dir, after_dir)
return sizes_diff.Summary(), _SizeDelta('Normalized APK Size', 'bytes',
@ -165,7 +167,8 @@ def _CreateResourceSizesDelta(before_dir, after_dir, max_increase):
def _CreateBaseModuleResourceSizesDelta(before_dir, after_dir, max_increase):
sizes_diff = diagnose_bloat.ResourceSizesDiff(include_sections=['base'])
sizes_diff = diagnose_bloat.ResourceSizesDiff(
filename='resource_sizes_32.json', include_sections=['base'])
sizes_diff.ProduceDiff(before_dir, after_dir)
return sizes_diff.DetailedResults(), _SizeDelta(
@ -173,6 +176,17 @@ def _CreateBaseModuleResourceSizesDelta(before_dir, after_dir, max_increase):
sizes_diff.CombinedSizeChangeForSection('base'))
def _CreateResourceSizes64Delta(before_dir, after_dir, max_increase):
sizes_diff = diagnose_bloat.ResourceSizesDiff(
filename='resource_sizes_64.json')
sizes_diff.ProduceDiff(before_dir, after_dir)
# Allow 4x growth of arm64 before blocking CLs.
return sizes_diff.Summary(), _SizeDelta('Normalized APK Size (arm64)',
'bytes', max_increase * 4,
sizes_diff.summary_stat.value)
def _CreateSupersizeDiff(before_size_path, after_size_path, review_subject,
review_url):
before = archive.LoadAndPostProcessSizeInfo(before_size_path)
@ -276,13 +290,14 @@ def _GenerateBinarySizePluginDetails(metrics):
'large_improvement': delta.IsLargeImprovement(),
}
if log_name == _RESOURCE_SIZES_LOG:
listing['name'] = 'Android Binary Size'
binary_size_listings.insert(0, listing)
continue
# The main 'binary size' delta is always shown even if unchanged.
if delta.actual == 0:
listing['name'] = 'Android Binary Size (arm32)'
elif log_name == _RESOURCE_SIZES_64_LOG:
listing['name'] = 'Android Binary Size (high-end arm64)'
elif delta.actual == 0:
# The above two deltas are always shown, even if unchanged.
continue
binary_size_listings.append(listing)
binary_size_listings.sort(key=lambda x: x['name'])
binary_size_extras = [
{
@ -430,6 +445,15 @@ def main():
size_deltas.add(base_resource_sizes_delta)
metrics.add((base_resource_sizes_delta, _BASE_RESOURCE_SIZES_LOG))
config_64 = config.get('to_resource_sizes_py_64')
if config_64:
logging.info('Creating 64-bit sizes diff')
resource_sizes_64_lines, resource_sizes_64_delta = (
_CreateResourceSizes64Delta(args.before_dir, args.after_dir,
max_size_increase))
size_deltas.add(resource_sizes_64_delta)
metrics.add((resource_sizes_64_delta, _RESOURCE_SIZES_64_LOG))
logging.info('Adding disassembly to dex symbols')
dex_disassembly.AddDisassembly(delta_size_info, before_path_resolver,
after_path_resolver)
@ -465,7 +489,7 @@ To understand what those checks are and how to pass them, see:
summary = '<br>' + checks_text.replace('\n', '<br>')
links_json = [
{
'name': 'Binary Size Details',
'name': 'Binary Size Details (arm32)',
'lines': resource_sizes_lines + see_docs_lines,
'log_name': _RESOURCE_SIZES_LOG,
},
@ -498,6 +522,14 @@ To understand what those checks are and how to pass them, see:
'url': _HTML_REPORT_URL,
},
]
if config_64:
links_json[2:2] = [
{
'name': 'Binary Size Details (arm64)',
'lines': resource_sizes_64_lines + see_docs_lines,
'log_name': _RESOURCE_SIZES_64_LOG,
},
]
# Remove empty diffs (Mutable Constants, Dex Method, ...).
links_json = [o for o in links_json if o.get('lines') or o.get('url')]