-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unify shapes of ActiveModel::Attributes
`if defined?(@ivar)` a performance anti-pattern in Ruby 3.2+ even more so with YJIT. This pattern cause the object shape to be inconsistent which slow downs instance variable access. ``` ruby 3.2.1 (2023-02-08 revision 31819e82c8) [arm64-darwin22] #value (orig): 1811240.2 i/s #value (opt): 2045238.9 i/s - 1.13x faster ``` ``` ruby 3.2.1 (2023-02-08 revision 31819e82c8) +YJIT [arm64-darwin22] #value (orig): 4379180.3 i/s #value (opt): 6347280.7 i/s - 1.45x faster ``` Benchmark: https://gist.github.com/casperisfine/872f0a486b5ccdf90d9feb830c76d9ad
- Loading branch information
Showing
2 changed files
with
119 additions
and
40 deletions.
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