-
Notifications
You must be signed in to change notification settings - Fork 442
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
fix: reduce UnboundMethod objects by memoizing initialize_parameters #1868
fix: reduce UnboundMethod objects by memoizing initialize_parameters #1868
Conversation
@rainerborene can you please add your change to the changelog while waiting on a review |
64c1929
to
f5d3a40
Compare
I'm a bit unsure if adding memorization here can have unwanted effects. Mind chiming in @camertron? |
Cool, thanks for looking into this @rainerborene :) The only issue I can think of would be if the |
I'm on leave right now @Spone, would you or another maintainer be able to look into the Vale CI failure and merge this? |
Yes I will, thanks for your input! |
I thought a bit more about this, and I'm now convinced the memoization probably won't affect detecting collection parameters. Any component that renders a collection should already have defined the collection parameter in its initializer. Virtually any monkeypatch or redefinition of the |
755df13
to
1d48d29
Compare
…iewComponent#1868) Co-authored-by: Cameron Dutro <[email protected]>
…iewComponent#1868) Co-authored-by: Cameron Dutro <[email protected]>
I have just discovered a simple optimization on
ViewComponent::Base
that can reduceUnboundMethod
objects allocation. I have removed other objects from this memory allocation report comparison to keep things simple and clear. These are the results in one of our main Rails endpoints.Before:
After:
If you want to test this patch yourself, just do this on your
ApplicationComponent
: