Remove VARIANT_INLINE
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start in include/mapbox/variant.hpp at the referenced lines and search the repository for VARIANT_INLINE uses. Remove the macro and its references, then verify that the C++11/C++14 library still builds and its existing tests pass.
Written by the indexing model from the issue text.
Description
It appears that some inadvertent changes have disabled the effect of the VARIANT_INLINE macro in debug builds on Windows and release builds on all other platforms, by commenting out the replacement text of the macro.
https://github.com/mapbox/variant/blob/256ddd55582bb7c06c342315dbacc6a42fee4b34/include/mapbox/variant.hpp#L39
https://github.com/mapbox/variant/blob/256ddd55582bb7c06c342315dbacc6a42fee4b34/include/mapbox/variant.hpp#L43
In those cases, the methods tagged with VARIANT_INLINE were inlined or not according to the default behavior of the compiler and optimization settings.
In my tests with mapbox-gl-native, removing the comments and thus restoring VARIANT_INLINE to its intended function in the release build causes a 2.5% size increase in the resulting binary (Apple clang 9, building with -Os):
VM SIZE FILE SIZE
-------------- --------------
+3.9% +116Ki __TEXT,__text +116Ki +3.9%
+283% +2.50Ki Table of Non-instructions +2.50Ki +283%
+2.2% +1.36Ki Code Signature +1.36Ki +2.2%
+11% +368 [__LINKEDIT] 0 [ = ]
+0.0% +48 __TEXT,__const +48 +0.0%
-1.2% -224 Function Start Addresses -224 -1.2%
-2.2% -1.66Ki __TEXT,__unwind_info -1.66Ki -2.2%
-56.1% -1.89Ki [__TEXT] -1.89Ki -56.7%
-2.3% -9.11Ki __TEXT,__gcc_except_tab -9.11Ki -2.3%
+2.5% +108Ki TOTAL +107Ki +2.5%
I suggest we remove the VARIANT_INLINE macro entirely, the rationale being:
- The compiler is best positioned to determine whether or not to inline these methods, based on program analysis and the developer's chosen optimization settings.
VARIANT_INLINEhas effectively been a no-op in release builds on the majority of platforms since 372d7c88fe796a138d0e578328914ac80e5a949a, and we haven't noticed any issues with that.- Restoring it to force inlining in release builds seems to increase the binary size, the opposite of the desired effect.
cc @artemp @springmeyer @lightmare
- Dominant language
- C++
- Stars
- 384
- Forks
- 96
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mapbox/variant
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 25/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100