-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent creation of unnecessary fieldset #2370
base: 0-10-stable
Are you sure you want to change the base?
Prevent creation of unnecessary fieldset #2370
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_inflections
was taking a long time.ActiveSupport::Inflector#apply_inflections
is a method executed byString#singularize
andString#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
fields
orfieldset
, Fieldset is created andfields_for
is 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