Closed CAMOBAP closed 2 years ago
@maxirmx can you help check? Thanks!
I will look at it
Is there a potential to reduce the size of express_parser.so for Ruby 3.0, 3.1?
There is some difference between ruby 2.x
and ruby 3.x
that causes linker to behave differently.
Furthermore, it happens on redhat-like distributions only (expressir employs rake-compiler-dock that uses manylinux image to create native gems). If I build on Ubuntu, 2.7 version is 21 Mb as well
I can look at it further but I was not able to develop any plan yet.
Is there a potential to reduce the size of express_parser.so for Ruby 3.0, 3.1?
There is some difference between
ruby 2.x
andruby 3.x
that causes linker to behave differently. Furthermore, it happens on redhat-like distributions only (expressir employs rake-compiler-dock that uses manylinux image to create native gems). If I build on Ubuntu, 2.7 version is 21 Mb as wellI can look at it further but I was not able to develop any plan yet.
BTW how do you think about the second question? I just checked several gems and neither of them implements such behavior. Maybe there are some obvious reasons why it's not possible?
If this is not possible maybe we can conditionally remove unnecessary binaries. For example if we install expressir gem for Ruby 3.1, can we remove 2.7 and 3.0 variants?
Expressir
employs rake-compiler-dock
to create native extensionsRake-compiler-dock
links libruby
statically (I do not understand why, probably to ensure stable environment)libruby
is linked statically a separate binary is required for each Ruby API version
Please refer to nokogiri
that also employs rake-compiler-dock
and has 4 binaries packagedWe can probably develop bundler plugin that will remove all extra binaries not only for expressir but for other gems as well
I have to say that there is something wrong with expressir linkage. It is not only this size issue but also Alpine issues (#106)
Other gems built with rake-compiler-dock
are glibc-neutral. This is the positive side of static linking.
Thanks @maxirmx for the continued investigation!
It looks like we can have only two versions of the library packed - 2.x and 3.x Ruby 2.7 cannot load 3.x library and 3.0 and 3.1 appear to be the same. It will save 21Mb. @CAMOBAP does it make sense ?
I found the difference in compilation 2.x vs 3.x
I believe I will be able to create a version where both 2.x and 3.x files will be ~ 7.5 Mb
Thank you @maxirmx !
Intro
During the investigation of docker image size in the scope of https://github.com/metanorma/metanorma-docker/issues/147 I have found that size of
express_parser.so
for Ruby 3.0, 3.1 (21 MB) is 3 times more thanexpress_parser.so
for Ruby 2.7 (7.2 MB)Questions
express_parser.so
for Ruby 3.0, 3.1?expressir
gem for Ruby 3.1, can we remove 2.7 and 3.0 variants?