-
Notifications
You must be signed in to change notification settings - Fork 17
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
Performance issue when decorator files are loaded multiple times #28
Comments
@patcoll Have you considered using the lower-level class DocumentSingleResourceObjectDecorator < Roar::Decorator
include Roar::JSON::JSONAPI::Mixin
type :articles
property :id
attributes do
property :title
end
end FWIW I'm not completely happy with the API design as it stands. I'd be open to an alternative to using a dynamic module for configuration. |
@myabc thanks for pointed out to |
Thanks a lot @apotonick and @myabc, looking forward to see what was causing the problem and the real fix. Have a great day. |
Complete Description of Issue
When files containing classes that inherit from
Roar::Decorator
and use theinclude Roar::JSON::JSONAPI.resource
declaration are dynamically reloaded, there is a performance degradation. As the number of reloads goes up, the performance degradation seems to increase as well.Steps to reproduce
Simulate dynamic reloading by running the
Kernel::load
method multiple with the same file. Again, that file should contain a class that inherits fromRoar::Decorator
and uses theinclude Roar::JSON::JSONAPI.resource
declaration, like so:(In our case, we use
trailblazer
androar-jsonapi
within Rails, and the performance slowdown initially showed up in our development environment. We were able to reproduce the problem without Rails being involved, both in this repo and with a minimal benchmark test case in #29.)Expected behavior
The time to reload the file with the class in it should exhibit constant-time performance characteristics.
Translation: It should just load quickly and move on.
Actual behavior
Every time the same file is reloaded, there appears to be a significant performance degradation.
Translation: It slows down significantly while loading, causing further use of the class to be delayed.
System configuration
Roar version: 1.1.0
Roar-JSONAPI version: 0.0.3
The text was updated successfully, but these errors were encountered: