Prevent creation of unnecessary fieldset#2370
Prevent creation of unnecessary fieldset#2370abcang wants to merge 1 commit intorails-api:0-10-stablefrom
Conversation
|
Great analysis and reporting! Reviewing code and CI |
|
The failure of the test with the combination of ruby v2.2 and rails v5.2 seems to be a bug of rails v5.2.4.1. It seems to have been fixed in the 5-2-stable branch. |
c6e5581 to
830cc2c
Compare
|
@abcang Hey Rails 5.2.4.2 was released! Can you push this AWESOME PR again? |
830cc2c to
c58ff52
Compare
|
i fear there are some issues with the travis config on 0-10-stable. the probable fix is under WIP in #2371 once that's merged, hopefully this PR can be pushed again with success |
|
hi everyone, just would like to bring this up again as we spot performance issue in lib/active_model/serializer/fieldset.rb as well our temp solution is patch and it saves about 50 ms response time!! (it was a slow api, but the improvement is significant) we also found that this PR(#2370) is actually better --- we don't need to initialize Really appreciate you attention on this ~ |
c58ff52 to
7ab98a9
Compare
…i#2370) * refactor: instance_options[:fieldset] must be nil as it's not listed in ADAPTER_OPTION_KEYS
…i#2370) * refactor: instance_options[:fieldset] must be nil as it's not listed in ADAPTER_OPTION_KEYS
…i#2370) * refactor: instance_options[:fieldset] must be nil as it's not listed in ADAPTER_OPTION_KEYS
…i#2370) * refactor: instance_options[:fieldset] must be nil as it's not listed in ADAPTER_OPTION_KEYS
…i#2370) * refactor: instance_options[:fieldset] must be nil as it's not listed in ADAPTER_OPTION_KEYS

Purpose
When I profiled a simple sample with stackprof, I found that
ActiveSupport::Inflector#apply_inflectionswas taking a long time.ActiveSupport::Inflector#apply_inflectionsis a method executed byString#singularizeandString#pluralize. And these are executed fromActiveModel::Serializer::Fieldset#fields_for.active_model_serializers/lib/active_model/serializer/fieldset.rb
Lines 14 to 16 in 2581fe0
Currently, even if there are no options for
fieldsorfieldset, Fieldset is created andfields_foris executed. Therefore, if there is no option, speed up by changing to not generate Fieldset and not executefields_for.Additional helpful information
difference of bench result