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

[Ruby] build: make exported symbol files platform-specific #31970

Merged
merged 1 commit into from
Dec 22, 2022

Conversation

apolcyn
Copy link
Contributor

@apolcyn apolcyn commented Dec 22, 2022

This is an alternative to #31151, and should fix #30976.

The idea of this PR is to use separate export files depending on whether or not we expect ruby_abi_version to be defined (i.e. depending on whether or not we're using ruby 3.2+).

I lean towards this PR over #31151 because it maintains the current symbol-stripping behavior:

Mainly, it looks like #31151 will cause a size increase of an uncompressed grpc_c.so file on linux from ~8MB to ~11MB due to the extra symbols. Compressed size correspondingly increases from ~3MB to ~4MB.

The latest pre-compiled linux gem, grpc-1.50.0-x86_64-linux.gem, is ~21MB. So the size increase might be noticeable.

cc @peterzhu2118

@apolcyn apolcyn added the release notes: yes Indicates if PR needs to be in release notes label Dec 22, 2022
@johnnyshields
Copy link
Contributor

@apolcyn looks good to me!

@apolcyn apolcyn enabled auto-merge (squash) December 22, 2022 21:47
@apolcyn apolcyn merged commit 05c5083 into grpc:master Dec 22, 2022
@@ -1,2 +1 @@
_Init_grpc_c
_rb_tr_abi_version
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem correct as it will break the gem on TruffleRuby if I read the PR correctly. TruffleRuby has rb_tr_abi_version before RUBY_VERSION 3.2, specifically it's 3.0 in the 22.3 release currently for TruffleRuby and it already had it before that. We can consider TruffleRuby always had this symbol, versions before are not supported anymore.

@eregon
Copy link
Contributor

eregon commented Dec 22, 2022

IMHO #31151 is much safer, future proof and a lot simpler. A 1MB increase for the existing 23MB precompiled gem seems minor.

@peterzhu2118
Copy link
Contributor

I agree with @eregon. There isn't really much benefits to stripping symbols (I don't think most users of the gem are too worried about the binary size) and having different behaviour depending on the Ruby version will make it difficult to maintain, especially if CI doesn't test the different Ruby versions.

@johnnyshields
Copy link
Contributor

I agree with @eregon and @peterzhu2118

@apolcyn
Copy link
Contributor Author

apolcyn commented Dec 29, 2022

This doesn't seem correct as it will break the gem on TruffleRuby if I read the PR correctly. TruffleRuby has rb_tr_abi_version before RUBY_VERSION 3.2, specifically it's 3.0 in the 22.3 release currently for TruffleRuby and it already had it before that. We can consider TruffleRuby always had this symbol, versions before are not supported anymore.

I've opened #31995 to try to unbreak TruffleRuby.

IMHO #31151 is much safer, future proof and a lot simpler. A 1MB increase for the existing 23MB precompiled gem seems minor.

I agree that #31151 is simpler, but the actual package size for pre-compiled gems will be multiplied by the ~4 supported ruby versions of each gem (there's a separate native library for each ruby version). I.e., total size increase should be closer to ~4MB.

Overall, I agree that the size increase in itself is probably not too bad. But I also don't think that these export files add too much complexity at the moment. I'm open to revisit this down the road if we find more problems stemming from these, but I'd prefer to avoid a size regression for now if it's easy enough. For example, one option is to remove symbol-stripping only from TruffleRuby.

I agree with @eregon. There isn't really much benefits to stripping symbols (I don't think most users of the gem are too worried about the binary size) and having different behaviour depending on the Ruby version will make it difficult to maintain, especially if CI doesn't test the different Ruby versions.

We do have tests for to-be-published gems that they'll work on each supported ruby version. We'll add such tests for 3.2 as a part of adding 3.2 support. I'm also adding some better test coverage for different ruby versions in #31991.

I don't know of data to side one way or the other, and a size increase will naturally affect downloads, storage, etc., so I'd just like to err on the side of caution here if it's easy enough. There's some evidence that package size is an issue for users in #28627.

@stanhu
Copy link
Contributor

stanhu commented Dec 30, 2022

@apolcyn @eregon It seems that _ruby_abi_version appears to be defined only for development builds for Ruby. It seems we may want to check RUBY_PATCHLEVEL: redis-rb/redis-client#58 (comment).

@stanhu
Copy link
Contributor

stanhu commented Dec 30, 2022

Submitted #31997 to fix this.

@eregon
Copy link
Contributor

eregon commented Dec 30, 2022

I've opened #31995 to try to unbreak TruffleRuby.

Thank you.

Overall, I agree that the size increase in itself is probably not too bad. But I also don't think that these export files add too much complexity at the moment. I'm open to revisit this down the road if we find more problems stemming from these, but I'd prefer to avoid a size regression for now if it's easy enough. For example, one option is to remove symbol-stripping only from TruffleRuby.

I think it's getting significant in complexity and the perfect example is #31970 (comment) i.e. yet another brittle check which might change in the future (e.g. I'm not sure why CRuby doesn't include the symbol on releases, it feels like it should be safer and detect bad gem homes, it might change).
Also TruffleRuby might rename that ABI symbol at some point, e.g. to unify it with CRuby (but ensure distinct versions schemes or some prefix in the value).

There's some evidence that package size is an issue for users in #28627.

That's a different order of magnitude (13.8 MB vs 1018MB), that issue is about size and experience if compiled from source IIUC, a couple MB extra is not a big deal compared to 1GB.

@eregon
Copy link
Contributor

eregon commented Dec 30, 2022

FYI I've filed https://bugs.ruby-lang.org/issues/19289 on the Ruby side to see how we could improve things related to rb_abi_version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
imported Specifies if the PR has been imported to the internal repository lang/ruby release notes: yes Indicates if PR needs to be in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Undefined symbol _ruby_abi_version regression with Xcode 13 -> 14
6 participants