Commit 0f6c3c25 authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

SuperSize: Also ignore |extra| size in central directory

As well as in normalized_apk_size.

We should ignore it in the central directory for the same reason as we
ignore it in the local file headers (it causes noise).

We use zipalign when is_official_build=true, so this change is more
just for completeness.

Bug: 1130754
Change-Id: Ic564321f2a477592010352d1afde4552fc7cb6d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2426550
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarSamuel Huang <huangs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810266}
parent 5f07f9d3
......@@ -315,8 +315,13 @@ def _DoApkAnalysis(apk_filename, apks_path, tool_prefix, out_dir, report_func):
with zipfile.ZipFile(apk_filename, 'r') as apk:
apk_contents = apk.infolist()
# Account for zipalign overhead that exists in local file header.
zipalign_overhead = sum(
_ReadZipInfoExtraFieldLength(apk, i) for i in apk_contents)
# Account for zipalign overhead that exists in central directory header.
# Happens when python aligns entries in apkbuilder.py, but does not
# exist when using Android's zipalign. E.g. for bundle .apks files.
zipalign_overhead += sum(len(i.extra) for i in apk_contents)
sdk_version, skip_extract_lib = _ParseManifestAttributes(apk_filename)
......
......@@ -1264,7 +1264,12 @@ def _ParseApkOtherSymbols(section_ranges, apk_path, apk_so_path,
with zipfile.ZipFile(apk_path) as z:
for zip_info in z.infolist():
zip_info_total += zip_info.compress_size
# Account for zipalign overhead that exists in local file header.
zipalign_total += zip_util.ReadZipInfoExtraFieldLength(z, zip_info)
# Account for zipalign overhead that exists in central directory header.
# Happens when python aligns entries in apkbuilder.py, but does not
# exist when using Android's zipalign. E.g. for bundle .apks files.
zipalign_total += len(zip_info.extra)
# Skip main shared library, pak, and dex files as they are accounted for.
if (zip_info.filename == apk_so_path
or zip_info.filename.endswith('.pak')):
......
......@@ -10,7 +10,7 @@ gn_args=var1=true var2="foo"
linker_name=gold
map_file_name=../../../test.map
tool_prefix=tools/binary_size/libsupersize/testdata/mock_toolchain/
zipalign_padding=16
zipalign_padding=32
Section .text: has 100.0% of 35982248 bytes accounted for from 22 symbols. 0 bytes are unaccounted for.
* Padding accounts for 13808 bytes (0.0%)
* 16 have source paths. Accounts for 73986 bytes (0.2%).
......@@ -75,8 +75,8 @@ Section .pak.nontranslated: has 100.0% of 737 bytes accounted for from 3 symbols
* 0 have source paths. Accounts for 0 bytes (0.0%).
* 0 have a component assigned. Accounts for 0 bytes (0.0%).
* 0 symbols have shared ownership.
Section .other: has 100.0% of 95595813 bytes accounted for from 27 symbols. 0 bytes are unaccounted for.
* Padding accounts for 33903415 bytes (35.5%)
Section .other: has 100.0% of 95595797 bytes accounted for from 27 symbols. 0 bytes are unaccounted for.
* Padding accounts for 33903399 bytes (35.5%)
* 3 have source paths. Accounts for 5243904 bytes (5.5%).
* 1 have a component assigned. Accounts for 1048576 bytes (1.1%).
* 22 placeholders exist (symbols that start with **). Accounts for 56448494 bytes (59.0%).
......@@ -306,7 +306,7 @@ Section .other: has 100.0% of 95595813 bytes accounted for from 27 symbols. 0 by
.other@0(size_without_padding=436,padding=0,full_name=** ELF Section: .shstrtab,object_path=,source_path=,flags={},num_aliases=1,component=)
.other@0(size_without_padding=34841854,padding=0,full_name=** ELF Section: .strtab,object_path=,source_path=,flags={},num_aliases=1,component=)
.other@0(size_without_padding=17166112,padding=0,full_name=** ELF Section: .symtab,object_path=,source_path=,flags={},num_aliases=1,component=)
.other@0(size_without_padding=0,padding=780,full_name=Overhead: APK file,object_path=,source_path=,flags={},num_aliases=1,component=)
.other@0(size_without_padding=0,padding=764,full_name=Overhead: APK file,object_path=,source_path=,flags={},num_aliases=1,component=)
.other@0(size_without_padding=0,padding=33902635,full_name=Overhead: ELF file,object_path=,source_path=,flags={},num_aliases=1,component=)
.other@0(size_without_padding=1048576,padding=0,full_name=assets/icudtl.dat,object_path=,source_path=third_party/icu/android/icudtl.dat,flags={},num_aliases=1,component=Internal>Android)
.other@0(size_without_padding=1024,padding=0,full_name=res/drawable-v13/test.xml,object_path=,source_path=chrome/android/res/drawable/test.xml,flags={},num_aliases=1,component=)
......
......@@ -11,7 +11,7 @@ gn_args=var1=true var2="foo"
linker_name=gold
map_file_name=../../../test.map
tool_prefix=tools/binary_size/libsupersize/testdata/mock_toolchain/
zipalign_padding=16
zipalign_padding=32
Section .text: has 100.0% of 35982248 bytes accounted for from 22 symbols. 0 bytes are unaccounted for.
* Padding accounts for 13808 bytes (0.0%)
* 16 have source paths. Accounts for 73986 bytes (0.2%).
......@@ -76,8 +76,8 @@ Section .pak.nontranslated: has 100.0% of 737 bytes accounted for from 3 symbols
* 0 have source paths. Accounts for 0 bytes (0.0%).
* 0 have a component assigned. Accounts for 0 bytes (0.0%).
* 0 symbols have shared ownership.
Section .other: has 100.0% of 95595813 bytes accounted for from 27 symbols. 0 bytes are unaccounted for.
* Padding accounts for 33903415 bytes (35.5%)
Section .other: has 100.0% of 95595797 bytes accounted for from 27 symbols. 0 bytes are unaccounted for.
* Padding accounts for 33903399 bytes (35.5%)
* 3 have source paths. Accounts for 5243904 bytes (5.5%).
* 1 have a component assigned. Accounts for 1048576 bytes (1.1%).
* 22 placeholders exist (symbols that start with **). Accounts for 56448494 bytes (59.0%).
......@@ -307,7 +307,7 @@ Section .other: has 100.0% of 95595813 bytes accounted for from 27 symbols. 0 by
.other@0(size_without_padding=436,padding=0,full_name=** ELF Section: .shstrtab,object_path=,source_path=,flags={},num_aliases=1,component=)
.other@0(size_without_padding=34841854,padding=0,full_name=** ELF Section: .strtab,object_path=,source_path=,flags={},num_aliases=1,component=)
.other@0(size_without_padding=17166112,padding=0,full_name=** ELF Section: .symtab,object_path=,source_path=,flags={},num_aliases=1,component=)
.other@0(size_without_padding=0,padding=780,full_name=Overhead: APK file,object_path=,source_path=,flags={},num_aliases=1,component=)
.other@0(size_without_padding=0,padding=764,full_name=Overhead: APK file,object_path=,source_path=,flags={},num_aliases=1,component=)
.other@0(size_without_padding=0,padding=33902635,full_name=Overhead: ELF file,object_path=,source_path=,flags={},num_aliases=1,component=)
.other@0(size_without_padding=1048576,padding=0,full_name=assets/icudtl.dat,object_path=,source_path=third_party/icu/android/icudtl.dat,flags={},num_aliases=1,component=Internal>Android)
.other@0(size_without_padding=1024,padding=0,full_name=res/drawable-v13/test.xml,object_path=,source_path=chrome/android/res/drawable/test.xml,flags={},num_aliases=1,component=)
......
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