Actions
Feature #20429
closedEmit a performance warning when specially optimized core methods are redefined
Feature #20429:
Emit a performance warning when specially optimized core methods are redefined
Status:
Closed
Assignee:
-
Target version:
-
Description
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.
Updated by byroot (Jean Boussier) over 1 year ago
- Description updated (diff)
Updated by Eregon (Benoit Daloze) over 1 year ago
+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).
Updated by byroot (Jean Boussier) over 1 year ago
- Description updated (diff)
Updated by matz (Yukihiro Matsumoto) over 1 year ago
Sounds reasonable. Accepted.
Matz.
Updated by ko1 (Koichi Sasada) over 1 year ago
- Status changed from Open to Closed
Actions