1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activemodel/lib/active_model
Ryuta Kamizono 0adcec4954 PERF: Avoid extra delegation to LazyAttributeHash
The extra delegation to `LazyAttributeHash` has non-negligible overhead.

Avoiding that delegation makes attributes access about 45% faster for
readonly (non-mutation) usage.

https://gist.github.com/kamipo/4002c96a02859d8fe6503e26d7be4ad8

Before:

```
IPS
Warming up --------------------------------------
    attribute access     1.000  i/100ms
Calculating -------------------------------------
    attribute access      3.444  (± 0.0%) i/s -     18.000  in   5.259030s
MEMORY
Calculating -------------------------------------
    attribute access    38.902M memsize (     0.000  retained)
                       350.044k objects (     0.000  retained)
                        15.000  strings (     0.000  retained)
```

After (with `immutable_strings_by_default = true`):

```
IPS
Warming up --------------------------------------
    attribute access     1.000  i/100ms
Calculating -------------------------------------
    attribute access      5.066  (±19.7%) i/s -     25.000  in   5.024650s
MEMORY
Calculating -------------------------------------
    attribute access    27.382M memsize (     0.000  retained)
                       160.044k objects (     0.000  retained)
                        15.000  strings (     0.000  retained)
```
2020-06-15 09:26:24 +09:00
..
attribute
attribute_set PERF: Avoid extra delegation to LazyAttributeHash 2020-06-15 09:26:24 +09:00
locale
serializers Improve doc for :root option in as_json() [ci skip] 2019-05-13 15:35:50 +05:30
type Fix string type cast with boolean serialization for MySQL 2020-06-13 07:50:12 +09:00
validations Reject signed hexadecimal numbers while validating numericality 2020-04-22 12:15:57 +00:00
attribute.rb PERF: 35% faster attributes for readonly usage 2020-06-13 16:01:08 +09:00
attribute_assignment.rb Change safe guard to check for each_pair instead of stringify_keys 2020-02-07 11:36:35 -05:00
attribute_methods.rb undef_method can take varargs 2020-05-08 23:58:01 +09:00
attribute_mutation_tracker.rb
attribute_set.rb PERF: Avoid extra delegation to LazyAttributeHash 2020-06-15 09:26:24 +09:00
attributes.rb PERF: 15% faster attribute access 2020-06-05 09:12:21 +09:00
callbacks.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
conversion.rb
dirty.rb Promote clear_attribute_change as attribute methods 2020-06-04 04:17:17 +09:00
error.rb Make inspect look more like regular Object#inspect 2020-05-29 21:53:35 +02:00
errors.rb Reference updated errors attribute names method in deprecation warning 2020-04-22 09:08:42 -07:00
forbidden_attributes_protection.rb
gem_version.rb Start Rails 6.1 development 2019-04-24 15:57:14 -04:00
lint.rb
model.rb
naming.rb Passing in a Hash instance as kwargs parameters requires the "double splat" prefix 2019-09-04 12:45:27 +09:00
nested_error.rb Document on ActiveModel::Errors changes 2020-01-14 23:55:09 +08:00
railtie.rb Move the ActiveModel:Errors#full_message method to the Error class: 2019-07-16 14:28:38 +02:00
secure_password.rb Use try only when we're unsure if the receiver would respond_to the method 2019-08-01 17:58:00 +09:00
serialization.rb Optimise serializable_hash when options are empty 2020-05-22 00:04:31 +01:00
translation.rb Passing in a Hash instance as kwargs parameters requires the "double splat" prefix 2019-09-04 12:45:27 +09:00
type.rb
validations.rb Prefer no allocation start/end_with? over String#[] == 2020-05-29 10:20:13 +09:00
validator.rb update from PR #36222 2020-02-12 13:31:43 -05:00
version.rb