-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
Cache various lookups with Dry::Core::Cache #97
Conversation
@solnic I decided not to use
In my opinion the
I guess would be nice to update the docs as well 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great!! 🎉 🎉
@timriley LGTM, it's already a great start. We should be able to make it at least equally fast eventually. I'll take another look at perf improvements once I get a chance. |
@solnic cool, will do. FWIW I just moved some of the caching a little earlier, with It's worth recognising that we're certainly doing a lot more in the dry-view side of this benchmark versus action view, at least in how we're preparing the scope for the template, e.g. checking for exposure dependencies, wrapping up values in parts, finding classes, etc., so this isn't truly an apples-for-apples comparison. Perhaps a better one would be e.g. using Draper to decorate every ivar in the Rails controller before it's passed to the template. |
One more thing, MRI 2.6.0 has various optimizations that we benefit from, so here are the results running MRI 2.6.0.rc2:
As you can see, the difference is meaningless, this probably means dry-view can easily become faster on future MRIs. |
e178d41
to
257c720
Compare
257c720
to
339b595
Compare
That is correct. OTOH it is a legit scenario, and a very common one, so it's probably worth having such a basic benchmark. To balance this better adding a more advanced scenario would be great too! |
This PR uses
Dry::Core::Cache
to cache a few lookups that could otherwise be costly:@GustavoCaso I hope you don't mind me going ahead with this, I wanted to play around with what we could cache. And I figured we should use our existing caching helper from dry-core.
Before this change, we were ~5.5x slower than ActionController.
After this change, we're ~1.8x slower:
Here's the latest profile diagram (run using Hotch and a new script I checked into the repo):
bundle exec ruby benchmarks/profile_controller.rb
So no more low hanging fruit, as far as I can tell? Would definitely appreciate any thoughts on taking things from here. 👋 @GustavoCaso @solnic