-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Query the actively loaded GC module #11872
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e98cc3d
to
8b616ae
Compare
8b616ae
to
604c1db
Compare
This comment has been minimized.
This comment has been minimized.
f4e9902
to
13ea2f1
Compare
peterzhu2118
reviewed
Nov 7, 2024
e63db7e
to
a4d9c2b
Compare
b0f6b94
to
36eab5c
Compare
And a default and readonly key to the GC.config hash that names the current GC implementation. This is provided by each implementation by the API function rb_gc_impl_active_gc_name
This will add +MOD_GC to the version string and Ruby description when Ruby is compiled with shared gc support. When shared GC support is compiled in and a GC module has been loaded using RUBY_GC_LIBRARY, the version string will include the name of the currently active GC as reported by the rb_gc_active_gc_name function in the form +MOD_GC[gc_name] [Feature #20794]
This avoids the need to malloc, and reduces the complexity of truncating the long string for display in RUBY_DESCRIPTION. The developer of a GC implementation should be responsible for giving it a succinct name.
Instead of silently ignoring the key, we should raise to clearly tell the user that this key is read-only.
36eab5c
to
bc28f03
Compare
nobu
reviewed
Nov 15, 2024
// Assume the active GC name can not be longer than 20 chars | ||
// so that we don't have to use strlen and remove the static | ||
// qualifier from desc. | ||
+ RB_GC_MAX_NAME_LEN + 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is 3, []
and what?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds information about the currently loaded GC module to
RUBY_DESCRIPTION
and hence the output ofruby -v
when--with-shared-gc
is enabled at compile time.Additionally, when a shared GC module is loaded with
RUBY_GC_LIBRARY
the reported name of the GC library will also be displayed inRUBY_DESCRIPTION
.This PR also introduces a readonly
GC.config
key calledimplementation
to expose this information to Ruby. It can be in three states:GC.config[:implementation] => "default"
GC.config[:implementation] => "default"
RUBY_GC_LIBRARY
:GC.config[:implementation] => "gc_name"
The intention of this PR is to give users of the modular GC system, GC developers, and Ruby users better tooling to introspect the state of the currently CG. It will also make writing tests that work accurately with different GC configurations easier.