docs/speed/binary_size/binary_size_explainer.md
This document explains the overhead of each kind of binary size, where "overhead" is the performance cost of existing (e.g. does not include the overhead of loading an image, just the overhead of an image existing). This document focuses on Android, but several types of size are the same on other platforms.
*** note See optimization_advice.md for ideas on how to reduce size.
[TOC]
//tools/binary_size/supersize archive on a release
build to create a .size file, and upload it to the viewer.Googlers - see go/chromebinarysizematters for more links to studies.
Chrome is currently not under any hard growth limits, but to mitigate unnecessary bloat of this shared resource, everyone should ensure that reasonable diligence is taken to minimize growth.
Android WebView is used by the majority of Android apps, so overhead (other than clean memory) introduced into WebView has a multiplicative effect on the OS. See android_build_instructions.md for how packaging of Chrome / WebView changes by OS version.
Chrome ships as an Android App Bundle, and consists of several APK splits.
Here we define some terms used to describe overhead.
Clean Memory:
mmap().Dirty Memory:
Machine instructions.
String literals, global constants, etc.
Read-only data that must be adjusted based on the base load address of the executable.
Global non-const variables.
UI Images, chrome:// pages, UI strings, etc.
Java bytecode in the DEX file format, stored in classes.dex, classes2.dex,
... When Android installs Chrome, this bytecode is turned into machine code and
stored as .odex & .vdex files. The size of these files depends on the OS
version and dex compilation profile. Generally, they are 1x the size of
uncompressed .dex on Android Go, and 4x the size of uncompressed .dex on
other devices.
When changing .java code, the change in method count is
shown in code reviews. The count is the number of method
references added/removed after optimization. Which methods are added/removed
can be seen in the "APK Breakdown" link by checking "Method Count Mode".
Method count is a useful thing to look at because:
All files within res/, as well as individual entries with res/values files
contribute to this file. It consists of a string table, plus one 2D array
for each resource type (strings, drawable, etc). The overhead (not included
actual data) for each table is: # [unique configs] * # of resources * sizeof(entry).
Files that are packaged within the res/ directory of the .apk. These also
have an entry within resources.arsc that maps to them from a resource ID.
ICU data, V8 snapshot, etc.