[ruby-core:117523] [Ruby master Feature#20429] Emit a performance warning when specially optimized core methods are redefined

Issue #20429 has been reported by byroot (Jean Boussier). ---------------------------------------- Feature #20429: Emit a performance warning when specially optimized core methods are redefined https://bugs.ruby-lang.org/issues/20429 * Author: byroot (Jean Boussier) * Status: Open ---------------------------------------- MRI has a number of core methods with special handling in the interpreter and both JITs that if they are redefined negatively impact Ruby performance. The methods currently are (I may be missing a few): - `Integer`: `#+`, `#-`, `#*`, `#/`, `#%`, `#<`, `#>`, `#<=`, `#>=` - `Float`: `#+`, `#-`, `#*`, `#/`, `#<`, `#>`, `#<=`, `#>=` - `String`: `#freeze`, `#size`, `#length`, `#empty?`, `#+`, `#succ`, `#%`, `#-@` - `Array`: `#size`, `#length`, `#empty?`, `#hash` - `Array`: `#size`, `#length`, `#empty?`, `#[]`, `#[]=` -- https://bugs.ruby-lang.org/

Issue #20429 has been updated by Eregon (Benoit Daloze). +1, great idea. I will likely do the same in TruffleRuby (there is already a way to find out via `--engine.TraceAssumptions` but that's more general and less user-friendly). ---------------------------------------- Feature #20429: Emit a performance warning when specially optimized core methods are redefined https://bugs.ruby-lang.org/issues/20429#change-107919 * Author: byroot (Jean Boussier) * Status: Open ---------------------------------------- MRI has a number of core methods with special handling in the interpreter and both JITs that if they are redefined negatively impact Ruby performance. The methods currently are (I may be missing a few): - `Integer`: `#+`, `#-`, `#*`, `#/`, `#%`, `#<`, `#>`, `#<=`, `#>=` - `Float`: `#+`, `#-`, `#*`, `#/`, `#<`, `#>`, `#<=`, `#>=` - `String`: `#freeze`, `#size`, `#length`, `#empty?`, `#+`, `#succ`, `#%`, `#-@` - `Array`: `#size`, `#length`, `#empty?`, `#hash` - `Array`: `#size`, `#length`, `#empty?`, `#[]`, `#[]=` Noticing that a dependency do redefine one of these methods can be non-trivial, so I'd like to emit a `:performance` warning when it happens. I can't really think of much reasons to redefine these aside from fun hacks, so I believe discouraging it would be valuable. Patch: https://github.com/ruby/ruby/pull/10532 -- https://bugs.ruby-lang.org/

Issue #20429 has been updated by matz (Yukihiro Matsumoto). Sounds reasonable. Accepted. Matz. ---------------------------------------- Feature #20429: Emit a performance warning when specially optimized core methods are redefined https://bugs.ruby-lang.org/issues/20429#change-107944 * Author: byroot (Jean Boussier) * Status: Open ---------------------------------------- MRI has a number of core methods with special handling in the interpreter and both JITs that if they are redefined negatively impact Ruby performance. The methods currently are (I may be missing a few): - `Integer`: `#+`, `#-`, `#*`, `#/`, `#%`, `#<`, `#>`, `#<=`, `#>=` - `Float`: `#+`, `#-`, `#*`, `#/`, `#<`, `#>`, `#<=`, `#>=` - `String`: `#freeze`, `#size`, `#length`, `#empty?`, `#+`, `#succ`, `#%`, `#-@` - `Array`: `#size`, `#length`, `#empty?`, `#hash` - `Hash`: `#size`, `#length`, `#empty?`, `#[]`, `#[]=` Noticing that a dependency do redefine one of these methods can be non-trivial, so I'd like to emit a `:performance` warning when it happens. I can't really think of much reasons to redefine these aside from fun hacks, so I believe discouraging it would be valuable. Patch: https://github.com/ruby/ruby/pull/10532 -- https://bugs.ruby-lang.org/
participants (3)
-
byroot (Jean Boussier)
-
Eregon (Benoit Daloze)
-
matz (Yukihiro Matsumoto)