-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Emit a performance warning when redefining specially optimized methods #10532
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
Conversation
I would suggest to replace Also |
5f3308b
to
7382b48
Compare
@eregon done. |
7382b48
to
1e3e17a
Compare
1e3e17a
to
0da9907
Compare
This makes it easier to notice a dependency is causing interpreter or JIT deoptimization. ```ruby Warning[:performance] = true class String def freeze super end end ``` ``` ./test.rb:4: warning: Redefining 'String#freeze' disable multiple interpreter and JIT optimizations ```
0da9907
to
8dcae03
Compare
@byroot |
Ah sorry, I went a bit too fast indeed. Here's the ticket and |
Thank you! |
These should not be tested as part of normal behavioral tests for these methods. This performance warning is specific to CRuby's way of optimizing and other implementations may not have the same limitation. Having these tests be done alongside normal behavioral testing means all implementations must warn for redefinition regardless of whether performance optimizations are affected. These tests are also not a core behavior of any of these methods, and are a side effect of one implementation. They should be tested separately. |
These are CRuby tests, it shouldn't be surprising they test CRuby-specific details. FWIW TruffleRuby has very similar warnings although for a slightly different set of methods:
The whole file actually only makes sense if these methods are intrinsified. Otherwise there would be no reason to test redefining more than one example method. |
JRuby does not patch tests from MRI. We run them as is without modification and submit patches back when there are MRI specific expectations such as using RubyVM or testing for MRI specific behavior. Is this warning now considered specified Ruby behavior? If so, should it not be tested in ruby/spec? If it is not specified behavior, why is it tested alongside the ability to redefine these operators, which is specified behavior? This test has been running in JRuby's test suite for many years. Adding this MRI-specific expectation caused it to start failing. |
This makes it easier to notice a dependency is causing interpreter or JIT deoptimization.