Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow opting-out of CustomDebugStringConvertible to reduce binary size #1245

Closed
bubski opened this issue May 2, 2022 · 4 comments · Fixed by #1246
Closed

Allow opting-out of CustomDebugStringConvertible to reduce binary size #1245

bubski opened this issue May 2, 2022 · 4 comments · Fixed by #1246

Comments

@bubski
Copy link

bubski commented May 2, 2022

This observation comes from researching #1204.

It appears that CustomDebugStringConvertible's contribution to the binary size adds up and is not insignificant.
A quick check shows that removing it from Message, SimpleExtensionMap, AnyExtensionField would save us ~800kB.

For context, our project has around 1000 message definitions.
This was a modified version 1.17.0,
compiled with -Osize,
Xcode 13.2.1 13C100, Swift 5.5.2, Big Sur

Since conforming to CustomDebugStringConvertible does not seem essential, perhaps it could could be tied to a compilation flag?
I'd like to hear some initial feedback @thomasvl before getting into details.

@thomasvl
Copy link
Collaborator

thomasvl commented May 2, 2022

This sounds sorta like another take on #1240.

With respect to compilation flags - those seems like they never work in practice with build systems - i.e. - how does one make that work (at scale) with SwiftPM/CocoaPods/etc.

TVL

@dflems
Copy link
Contributor

dflems commented May 6, 2022

@thomasvl: The DEBUG compilation condition seems fairly universal among build systems:

  • CocoaPods adds DEBUG to swift compilation conditions under debug in the generated Xcode project (link)
  • SwiftPM adds -DDEBUG to all compiles in the debug configuration (link)
  • rules_swift adds it for dbg and fastbuild configs (link)

CustomDebugStringConvertible is meant for debugging so I think it would make sense to cut it out for release builds.

@thomasvl
Copy link
Collaborator

thomasvl commented May 9, 2022

Yes, DEBUG would be less of an issue, I was taking the initial comment to be something developers directly controlled.

@dflems
Copy link
Contributor

dflems commented May 9, 2022

@thomasvl Took a crack at it here: #1246

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants