tree: 4e4ea88e31ddb0c59f0a68df37c732e954a0e8c9 [path history] [tgz]
  1. docs/
  2. testdata/
  3. viewer/
  4. .gitignore
  5. apk.py
  6. apkanalyzer.py
  7. apkanalyzer_test.py
  8. ar.py
  9. archive.py
  10. archive_util.py
  11. bcanalyzer.py
  12. bcanalyzer_test.py
  13. canned_queries.py
  14. console.py
  15. data_quality.py
  16. dbg.py
  17. demangle.py
  18. describe.py
  19. dex_disassembly.py
  20. dex_disassembly_test.py
  21. diff.py
  22. diff_test.py
  23. dir_metadata.py
  24. dwarfdump.py
  25. dwarfdump_test.py
  26. file_format.py
  27. function_signature.py
  28. function_signature_test.py
  29. integration_test.py
  30. json_config_parser.py
  31. linker_map_parser.py
  32. linker_map_parser_test.py
  33. main.py
  34. match_util.py
  35. match_util_test.py
  36. models.py
  37. native.py
  38. native_disassembly.py
  39. ninja_parser.py
  40. ninja_parser_test.py
  41. nm.py
  42. obj_analyzer.py
  43. pakfile.py
  44. parallel.py
  45. parallel_test.py
  46. path_util.py
  47. readelf.py
  48. README.md
  49. run_tests.py
  50. string_extract.py
  51. test_util.py
  52. zip_util.py
  53. zip_util_test.py
tools/binary_size/libsupersize/README.md

SuperSize

SuperSize is comprised of two parts:

  1. A command-line tool for creating and inspecting .size and .sizediff files,
  2. A web app for visualizing .size and .sizediff files.

For more details, see //tools/binary_size/libsupersize/docs.

Why SuperSize?

Chrome on Android needs to be as lean as possible. Having a tool that can show why binary grows & shrinks helps keep it lean.

The android-binary-size trybot uses SuperSize to show an APK Breakdown on every Chromium code review.

SuperSize is also used when creating milestone size reports (Googlers only).

Is SuperSize a Generic Tool?

No. It works only for binaries built using Chrome's custom build system. E.g.:

  • It assumes .ninja build rules are available.
  • It uses heuristic for locating .so given .apk.
  • It requires the size-info build directory to analyze .pak and .dex files.

SuperSize Usage

supersize archive

Collect size information into a .size file.

Note: Refer to diagnose_bloat.py for list of GN args to build a release binary (or just use the tool with --single).

Example Usage:

# Android:
autoninja -C out/Release chrome_public_apk
tools/binary_size/supersize archive chrome.size -f out/Release/apks/ChromePublic.apk -v

# Linux:
autoninja -C out/Release chrome
tools/binary_size/supersize archive chrome.size -f out/Release/chrome -v

supersize console

Starts a Python interpreter where you can run custom queries, or run pre-made queries from canned_queries.py.

Example Usage:

# Prints size information and exits (does not enter interactive mode).
tools/binary_size/supersize console chrome.size --query='Print(size_info)'

# Enters a Python REPL (it will print more guidance).
tools/binary_size/supersize console chrome.size

Example Session:

>>> ShowExamples()  # Get some inspiration.
...
>>> sorted = size_info.symbols.WhereInSection('t').Sorted()
>>> Print(sorted)  # Have a look at the largest symbols.
...
>>> sym = sorted.WhereNameMatches('TrellisQuantizeBlock')[0]
>>> Disassemble(sym)  # Time to learn assembly.
...
>>> help(canned_queries)
...
>>> Print(canned_queries.TemplatesByName(depth=-1))
...
>>> syms = size_info.symbols.WherePathMatches(r'skia').Sorted()
>>> Print(syms, verbose=True)  # Show full symbol names with parameter types.
...
>>> # Dump all string literals from skia files to "strings.txt".
>>> Print((t[1] for t in ReadStringLiterals(syms)), to_file='strings.txt')

supersize save_diff

Creates a .sizediff file given two .size files. A .sizediff file contains two .size files, with all unchanged symbols removed.

Example Usage:

tools/binary_size/supersize size_diff before.size after.size out.sizediff

supersize diff

A convenience command equivalent to: console before.size after.size --query='Print(Diff(size_info1, size_info2))'

Example Usage:

tools/binary_size/supersize diff before.size after.size --all