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] Improve AssetFolderPolicy performance #10868

Merged
merged 2 commits into from
Oct 1, 2024

Conversation

jesseleite
Copy link
Member

In our AssetFolderPolicy, we are currently performing a whole bunch of redundant ability checks, which really slows down performance in super large asset containers.

For example, this ability check is done in our AssetFolderPolicy:

CleanShot 2024-09-30 at 19 56 06

But then right after that, you can see we loop over every asset in the folder:

CleanShot 2024-09-30 at 19 57 03

Which essentially just does the same ability check within AssetPolicy:

CleanShot 2024-09-30 at 19 58 13

This PR changes improves performance by only looping over each asset if a custom AssetPolicy class is registered. If a custom policy is registered, there is likely extra logic that run to be checked on an asset-by-asset basis, so we'll do the more thorough check only in those scenarios.

Fixes #9710

@jesseleite jesseleite changed the title [5.x] Remove redundant policy checks to improve AssetFolderPolicy performance [5.x] Improve AssetFolderPolicy performance Oct 1, 2024
@jesseleite jesseleite marked this pull request as ready for review October 1, 2024 00:10
@jesseleite jesseleite requested a review from jasonvarga October 1, 2024 00:10
@jasonvarga jasonvarga merged commit e2477b6 into 5.x Oct 1, 2024
18 checks passed
@jasonvarga jasonvarga deleted the improve-asset-folder-policy-performance branch October 1, 2024 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance Issue in Statamic CMS Admin Dashboard's Asset Library for Non-Super Admin Roles
3 participants