Performance improvements#15003
Merged
brandonkelly merged 15 commits into5.2from May 20, 2024
Merged
Conversation
Gets called a lot, so worth the microoptimization
Avoids 100 element count queries per structure index page
This reverts commit 86e196c.
# Conflicts: # src/helpers/Assets.php
fixes EagerLoadingTest, which programmatically removes a custom field and expects getCustomFields() to reflect that
[ci skip]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improves system performance in a few ways:
FieldLayout::getCustomFields()now memoizes the results. (Only applies when returning all custom fields; not just visible ones based on conditions.)ArrayHelper::index()withinElementQuery::_loopInCustomFields()due to high call count.Field::getValueSql()now memoizes the result, based on the$keypassed in.withCustomFieldselement query param, which can be set tofalseto omit custom fields from the query’s params and resulting elements. Useful for high-frequency queries that don’t need to factor in custom fields, like getting each element’s total descendants on a Structure section’s index.trigger()call in a$this->hasEventHandlers()/Event::hasHandlers()condition, reducing unnecessary event object instantiations.