Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce chrome.dll size by careful use of static_library
Linking with a source_set tells the linker to pull in all of the code and data from the specified object files, and then discard those that can be proved to be unnecessary. This can cause extraneous global variables and code to be retained, which has led to a regression in the size of chrome.dll in gn builds, compared to gyp builds. This change avoids linking in three arrays from ffmpeg. All of these arrays have multiple instances, each half the size of the previous, so the listed sizes below should all be doubled. The necessary changes were tracked down by using dia2dump to find large global variables and then running a python script to find the chain of object files that caused these global to be pulled in. The arrays are: ff_cos_65536_fixed - 64 KB, fixed by a previous ffmpeg change which enables these fixes. ff_sin_65536 - 128 KiB is defined in ffmpeg's rdft.c. Pulled in by: - service_worker_network_provider.obj, through //content/child:child - render_frame_observer.obj, through //content/public/renderer:renderer_sources - render_widget_mus_connection.obj, //content/renderer/mus:mus - resource_converter.obj, through //content/renderer:renderer ff_cos_65536 - 128 KiB is defined in ffmpeg's fft_template.c which is #included by fft_float.c. Pulled in by: - audio_video_metadata_extractor.obj and media_file_checker.obj, through //media/base:base Changing ffmpeg and the five source_set targets to static_library targets (conditionally in some cases) means that these arrays no longer get pulled in. The expected in-memory savings in the .data section are (64+128+128)*2 KiB = 640 KiB. Actual savings were 718 KiB. This does not affect file size. In addition this saved 288 KiB of code in the .text section, and shrunk the read-only data section, for a 301 KiB file-size savings. Before: size of chrome.dll is 38.808576 MB name: mem size , disk size .text: 30.999296 MB .rdata: 6.007834 MB .data: 1.447656 MB, 0.270336 MB After: size of chrome.dll is 38.499840 MB name: mem size , disk size .text: 30.704163 MB .rdata: 6.006906 MB .data: 0.712680 MB, 0.270336 MB Measurements were done on 32-bit official builds from hash b8c16c8. Still some more work to be done. BUG=624274 Review-Url: https://codereview.chromium.org/2163823002 Cr-Commit-Position: refs/heads/master@{#406611}
- Loading branch information