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

Reducing the size of compiled extensions #130

Closed
vais opened this issue Oct 10, 2018 · 4 comments
Closed

Reducing the size of compiled extensions #130

vais opened this issue Oct 10, 2018 · 4 comments

Comments

@vais
Copy link
Contributor

vais commented Oct 10, 2018

What problems are you experiencing?

I've just noticed that the size of compiled extensions (.so files) jumped an order of magnitude going from ruby 2.3.3 to 2.4.4. This seems to be caused by this change in rbconfig.rb:

-  CONFIG["debugflags"] = "-g"
+  CONFIG["debugflags"] = "-ggdb3"

Reverting this change makes .so files an order of magnitude smaller.

With CONFIG["debugflags"] = "-ggdb3" we get this:

C:\>ruby -e "puts Dir['C:/Ruby/rubyinstaller-2.4.4-1-x86/lib/ruby/gems/2.4.0/extensions/**/*.so'].map{|f| %(#{File.size(f)} #{File.basename(f)})}"
294682 jaro_winkler_ext.so
334430 puma_http11.so
475743 tiny_tds.so
459139 wdm_ext.so

With CONFIG["debugflags"] = "-g" we get this:

gem pristine --all --extensions
C:\>ruby -e "puts Dir['C:/Ruby/rubyinstaller-2.4.4-1-x86/lib/ruby/gems/2.4.0/extensions/**/*.so'].map{|f| %(#{File.size(f)} #{File.basename(f)})}"
20992 jaro_winkler_ext.so
38400 puma_http11.so
62464 tiny_tds.so
53248 wdm_ext.so

Should debugflags be changed in rubyinstaller2, or does this have to be done upstream? I'm concerned that getting this into Ruby trunk may be much more cumbersome given multiple platforms etc...

@MSP-Greg
Copy link
Contributor

Is this do to CONFIG["debugflags"] or to strip not being used? I've got the same hash value, but the stripped puma file I have is approx. 45k...

@vais
Copy link
Contributor Author

vais commented Oct 11, 2018

@MSP-Greg I am not aware of strip (how to use it or what it does). I'm simply setting CONFIG["debugflags"] back to -g (as it was in Ruby 2.3 days), and this alone cuts down the size of the .so files by a factor of 10. (Actually, the factor of 10 part is a little misleading - it's more like there is a static overhead of about 250 KB that gets cut, but since most files are small, this 250 KB overhead results in a factor of 10 difference.)

@MSP-Greg
Copy link
Contributor

@vais

  1. strip can remove the info that using ggdb3 as a debug flag creates. See Ruby configure.ac:641

  2. I believe the files included with RI2 builds have been 'reduced' in size. The setting only affects compiling of extension gems.

  3. Unlikely that many Windows users will be using a gcc debugger. It could be removed from RbConfig with a patch.

@vais
Copy link
Contributor Author

vais commented Oct 11, 2018

@MSP-Greg Thanks! Regarding point 3, I agree but not sure how to patch rbconfig.rb in the context of rubyinstaller2. Is there an example of something like this already being done in this project that I could use as a starting point to make a PR? (I.e. some other files in Ruby distribution getting patched/overwritten?)

larskanis added a commit to oneclick/rubyinstaller2-packages that referenced this issue Oct 18, 2018
larskanis added a commit to oneclick/rubyinstaller2-packages that referenced this issue Oct 18, 2018
larskanis added a commit to oneclick/rubyinstaller2-packages that referenced this issue Oct 20, 2018
This is regarding oneclick/rubyinstaller2#130
Changing the debugflags didn't have an effect to the binary size.
larskanis added a commit to oneclick/rubyinstaller2-packages that referenced this issue Oct 20, 2018
This is regarding oneclick/rubyinstaller2#130
Changing the debugflags didn't have an effect to the binary size.
larskanis added a commit to oneclick/rubyinstaller2-packages that referenced this issue Oct 20, 2018
This is regarding oneclick/rubyinstaller2#130
Changing the debugflags didn't have an effect to the binary size.
xmas7 pushed a commit to RubyOnWorld/installer2-packages that referenced this issue Sep 28, 2022
xmas7 pushed a commit to RubyOnWorld/installer2-packages that referenced this issue Sep 28, 2022
xmas7 pushed a commit to RubyOnWorld/installer2-packages that referenced this issue Sep 28, 2022
xmas7 pushed a commit to RubyOnWorld/installer2-packages that referenced this issue Sep 28, 2022
This is regarding oneclick/rubyinstaller2#130
Changing the debugflags didn't have an effect to the binary size.
xmas7 pushed a commit to RubyOnWorld/installer2-packages that referenced this issue Sep 28, 2022
This is regarding oneclick/rubyinstaller2#130
Changing the debugflags didn't have an effect to the binary size.
xmas7 pushed a commit to RubyOnWorld/installer2-packages that referenced this issue Sep 28, 2022
This is regarding oneclick/rubyinstaller2#130
Changing the debugflags didn't have an effect to the binary size.
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

No branches or pull requests

2 participants