Skip to content
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

[5.x] Simplify collection and cache getComputedCallbacks on Entry instances #9642

Merged
merged 7 commits into from
Apr 1, 2024
Merged

[5.x] Simplify collection and cache getComputedCallbacks on Entry instances #9642

merged 7 commits into from
Apr 1, 2024

Conversation

JohnathonKoster
Copy link
Contributor

@JohnathonKoster JohnathonKoster commented Mar 3, 2024

This PR moves the getter/setter logic for collection into the Entry class itself instead of using getter/setter. Additionally, it caches the results of getComputedCallbacks on the instance itself. These two methods are called very frequently, and removing the extra closures/new object instances helps over many thousands of entries.

Note for local testing: if you pull this in, you will likely need a php please stache:clear

While the Blink call for collection is unfortunate, its still an improvement over the repeated getter/setter calls in this method due to how many times it is called. Cache invalidation complexity here is not worth it at this time
@JohnathonKoster JohnathonKoster mentioned this pull request Mar 3, 2024
37 tasks
@JohnathonKoster JohnathonKoster marked this pull request as draft March 3, 2024 00:34
@JohnathonKoster JohnathonKoster changed the title [4.x] Simplify collection and cache getComputedCallbacks on Entry instances [5.x] Simplify collection and cache getComputedCallbacks on Entry instances Mar 3, 2024
@JohnathonKoster JohnathonKoster marked this pull request as ready for review March 3, 2024 00:39
@duncanmcclean duncanmcclean changed the base branch from 4.x to master March 4, 2024 10:08
@jasonvarga
Copy link
Member

On a page with a 5-item nav and 3 entries being listed, this results in Collection::getComputedCallbacks() calls dropping from 127 times down to 11. 👍

@jasonvarga jasonvarga merged commit ba96445 into statamic:master Apr 1, 2024
16 checks passed
@jasonvarga jasonvarga deleted the cache-collection-on-entry branch April 1, 2024 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants