Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[all] Build all release builds with -Os #8253

Merged
merged 1 commit into from
Mar 3, 2017
Merged

[all] Build all release builds with -Os #8253

merged 1 commit into from
Mar 3, 2017

Conversation

jfirebaugh
Copy link
Contributor

Refs #8035.

@jfirebaugh jfirebaugh requested a review from kkaefer March 2, 2017 05:53
@jfirebaugh
Copy link
Contributor Author

Bloaty output on linux:

john@john-VirtualBox:~/mapbox-gl-native$ ../bloaty/bloaty -d compileunits build-os/linux-x86_64/Release/mbgl-glfw -- build-g/linux-x86_64/Release/mbgl-glfw 
     VM SIZE                                                                   FILE SIZE
 ++++++++++++++ GROWING                                                     ++++++++++++++
  +4.7%     +20 ../../../src/mbgl/style/layers/custom_layer.cpp                 +20  +4.7%
  +1.9%      +9 ../../../platform/default/webp_reader.cpp                        +9  +1.9%

 -------------- SHRINKING                                                   --------------
 -54.2%  -688Ki [Other]                                                      -673Ki -53.8%
 -40.4%  -122Ki ../../../src/mbgl/style/parser.cpp                           -122Ki -40.4%
 -48.2% -41.2Ki ../../../src/mbgl/style/layers/symbol_layer.cpp             -41.2Ki -48.2%
 -42.0% -41.1Ki ../../../src/clipper/clipper.cpp                            -41.1Ki -42.0%
 -68.8% -40.0Ki ../../../platform/glfw/glfw_view.cpp                        -40.0Ki -68.8%
 -77.5% -39.9Ki ../../../src/mbgl/tile/vector_tile.cpp                      -39.9Ki -77.5%
 -89.9% -38.9Ki ../../../src/mbgl/style/layers/raster_layer.cpp             -38.9Ki -89.9%
 -90.6% -38.9Ki ../../../src/mbgl/style/group_by_layout.cpp                 -38.9Ki -90.6%
 -74.8% -38.0Ki ../../../src/mbgl/sprite/sprite_parser.cpp                  -38.0Ki -74.8%
 -61.5% -33.6Ki ../../../src/mbgl/renderer/painter_background.cpp           -31.2Ki -59.7%
 -41.7% -31.8Ki ../../../src/mbgl/annotation/annotation_manager.cpp         -31.8Ki -41.7%
 -41.8% -30.7Ki ../../../src/mbgl/layout/symbol_layout.cpp                  -30.7Ki -41.8%
 -94.3% -30.6Ki ../../../src/mbgl/style/layers/raster_layer_impl.cpp        -30.6Ki -94.3%
 -70.0% -29.9Ki ../../../src/mbgl/tile/geometry_tile_worker.cpp             -29.9Ki -70.0%
 -92.0% -27.5Ki ../../../src/mbgl/annotation/fill_annotation_impl.cpp       -27.5Ki -92.0%
 -43.5% -26.3Ki ../../../src/mbgl/annotation/shape_annotation_impl.cpp      -26.3Ki -43.5%
 -73.6% -26.0Ki ../../../platform/default/mbgl/storage/offline_download.cpp -26.0Ki -73.6%
 -80.3% -26.0Ki ../../../src/mbgl/style/layers/background_layer.cpp         -26.0Ki -80.3%
 -48.9% -25.7Ki ../../../src/mbgl/style/layers/circle_layer.cpp             -25.7Ki -49.3%
 -55.4% -25.2Ki ../../../src/mbgl/renderer/circle_bucket.cpp                -25.2Ki -55.4%
 -50.2% -24.4Ki ../../../src/mbgl/style/layers/line_layer.cpp               -24.4Ki -50.2%

 -+-+-+-+-+-+-+ MIXED                                                       +-+-+-+-+-+-+-
  +5.5%  +202Ki [None]                                                      -26.0Mi -20.7%

 -19.4% -1.19Mi TOTAL                                                       -27.3Mi -21.4%

@kkaefer
Copy link
Member

kkaefer commented Mar 2, 2017

We've been using -Os before on Android too, and our binary size chart also noted a massive increase for it. Why do you think this would improve the situation on these platforms?

@jfirebaugh
Copy link
Contributor Author

Right, Android was already using -Os, so it won't help there, but it will help linux, macOS, and iOS. This PR is just the first low-hanging fruit I noticed for #8035.

@friedbunny
Copy link
Contributor

friedbunny commented Mar 2, 2017

Assuming the command line builds for iOS and macOS respect the GCC_OPTIMIZATION_LEVEL setting in their respective Xcode projects, they’re both also already set to -Os.

@kkaefer
Copy link
Member

kkaefer commented Mar 2, 2017

Assuming the command line builds for iOS and macOS respect the GCC_OPTIMIZATION_LEVEL setting in their respective Xcode projects, they’re both also already set to -Os.

They do; we're using xcodebuild, which uses the Xcode project and its settings.

@jfirebaugh
Copy link
Contributor Author

Assuming the command line builds for iOS and macOS respect the GCC_OPTIMIZATION_LEVEL setting in their respective Xcode projects, they’re both also already set to -Os.

They might use -Os for the code that's included in the checked-in Xcode projects, but they currently use -O3 for mbgl-core, since that's built from a cmake-generated project. (I verified by removing | xcpretty.)

Here's a before/after bloaty comparison for macOS:

     VM SIZE                               FILE SIZE
 ++++++++++++++ GROWING                 ++++++++++++++
   +16% +9.04Ki __TEXT,__unwind_info    +9.04Ki   +16%
  +0.1%    +128 __TEXT,__const             +128  +0.1%
  +0.1%    +125 __TEXT,__cstring           +125  +0.1%
  +0.6%     +16 __DATA,__bss                  0  [ = ]

 -------------- SHRINKING               --------------
 -19.2%  -614Ki __TEXT,__text            -614Ki -19.2%
  -4.9% -14.9Ki __TEXT,__gcc_except_tab -14.9Ki  -4.9%
  -4.4% -7.56Ki [None]                  -5.32Ki  -3.0%
  -1.5%     -32 __DATA,__got                -32  -1.5%

 -14.7%  -628Ki TOTAL                    -625Ki -14.7%

And iOS:

     VM SIZE                               FILE SIZE
 ++++++++++++++ GROWING                 ++++++++++++++
 +10.0% +6.00Ki __TEXT,__unwind_info    +6.00Ki +10.0%
  +0.1%    +176 __TEXT,__const             +176  +0.1%
  +0.6%     +16 __DATA,__bss                  0  [ = ]

 -------------- SHRINKING               --------------
  -0.1%    -994 [None]                  -3.41Mi  -5.9%
 -19.7%  -655Ki __TEXT,__text            -655Ki -19.7%
  -5.9% -19.5Ki __TEXT,__gcc_except_tab -19.5Ki  -5.9%
  -0.7%     -32 __DATA,__got                -32  -0.7%
  -0.0%     -10 __TEXT,__cstring            -10  -0.0%

 -12.8%  -669Ki TOTAL                   -4.06Mi  -6.5%

So 10-20% size savings across the board (except for Android).

@friedbunny friedbunny added build Core The cross-platform C++ core, aka mbgl labels Mar 3, 2017
@jfirebaugh jfirebaugh merged commit 8742dc8 into master Mar 3, 2017
@jfirebaugh jfirebaugh deleted the optimize-size branch March 3, 2017 00:32
@springmeyer
Copy link
Contributor

So 10-20% size savings across the board (except for Android).

Great improvement. Is there any performance cost to this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
build Core The cross-platform C++ core, aka mbgl
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants