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
YJIT: Add RubyVM::YJIT.enable #8705
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
The PR looks good and simplifies a lot of things 👍
This is the only part I'm not sure about. It's not fully clear what the Ruby description is going to print. Does it only print +YJIT if YJIT is enabled, which can happen later during execution?
I feel like ideally, the description should tell us that this is a YJIT-capable build of CRuby, so maybe it should say something like
+YJIT (enabled)
or+YJIT (disabled)
? Otherwise, as a simpler solution, we could just always have +YJIT, and people would have to queryRubyVM::YJIT::enabled?
if they want to know if YJIT is enabled or not.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.
Correct.
This PR doesn't change the format. If disabled, that part is "". If enabled, that part is "+YJIT", "+YJIT dev", "+YJIT dev_nodebug", or "+YJIT stats". The whole point of this PR's design is to avoid confusion, so I wouldn't introduce "+YJIT (disabled)" (also that state is in fact the same as just running the interpreter).
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.
The thing that may be confusing is that the "+YJIT" is going to appear only when YJIT is enabled, which is going to happen much later if YJIT is enabled in software. You won't see it if you run
ruby -v
.That's why I think YJIT enabled and YJIT disabled make sense to report. It lets us know we have a YJIT-capable build of CRuby.
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.
I should have asked this first: what problem do you want to solve with this? Does it really require
RUBY_DESCRIPTION
to have+YJIT
? If you're concerned about possibly breakingRubyVM::YJIT.enable
when Ruby is not built with--enable-yjit
and troubleshooting it is hard, for example, can we just tell that it's not built with--enable-yjit
whenRubyVM::YJIT.enable
is called? If you want to quickly check if it's built with--enable-yjit
, why not just runruby --yjit -v
?In CRuby, we generally present build configurations in
RbConfig::CONFIG
instead ofRUBY_DESCRIPTION
.RbConfig::CONFIG["YJIT_SUPPORT"]
is"yes"
or"no"
. Can we use that information inRubyVM::YJIT
APIs or warning/error messages to deal with the problem? Would you like to introduceRubyVM::YJIT.supported?
to wrap it?To me, what seems more confusing to end users is "+YJIT (disabled)". "+YJIT" seems to say YJIT is enabled, but "(disabled)" also says it's disabled. "+YJIT (disabled)" seems just as confusing as "YJIT is enabled but paused".
I think the "+XXX" format is generally used when it's actually enabled, not when it's capable of doing it. For example, JRuby prints
+indy
and+jit
when the flags are passed, and doesn't print+indy (disabled)
or+jit (disabled)
when built with that support but disabled.Similarly, today's CRuby prints
+MN
whenRUBY_MN_THREADS=1
is given, and doesn't print+MN (disabled)
just by the fact thatUSE_MN_THREADS
macro is 1 when it's disabled. It seems inconsistent in CRuby alone too.One last note, changing the format of
RUBY_DESCRIPTION
for the YJIT-disabled mode might need discussions on bugs.ruby-lang.org and Matz's approval unlikeRubyVM::YJIT
-closed changes like the current diff. I would rather merge this first without breaking compatibility to make sure we land this feature in Ruby 3.3, and then spend time discussing the format ofRUBY_DESCRIPTION
, which is less important than addingRubyVM::YJIT.enable
in 3.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.
I think it would be useful to know if we're running a YJIT-capable version of Ruby when doing
ruby -v
, that would be the use case, but I get that you don't want to break convention with other flags shown in the Ruby description.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.
I've always wanted a quick way to check if
--enable-shared
because it does slow down the interpreter and macOS and ruby-build unfortunately turn it on by default. I wishruby -v
printed it, so I guess I get your use case.I would still want something less confusing than
+YJIT (disable)
, though. If there's no concise way to communicate it inruby -v
, maybe we could makeruby -vv
more verbose and let it print important build configurations likeYJIT_SUPPORT
andENABLE_SHARED
. Either way, we'd need a ticket to introduce such changes. Until then,ruby -v --yjit
seems like a good enough compromise.