Repository navigation
[6.x] Work out fieldtype config defaults once per request - #15805
Open
DanielDarrenJones wants to merge 1 commit into
Open
DanielDarrenJones wants to merge 1 commit into
DanielDarrenJones wants to merge 1 commit into
Conversation
Fieldtype::config() rebuilt the whole config (every config field's default, merged with the field's own config) as collections on each call, even when asking for a single key. Single-key reads now return the field's own value or that config field's default directly, and each default is worked out once per config fields collection, which Blink already keeps for the request. Computed defaults are still resolved on every read. HasSelectOptions looks up an option's label with a loop instead of building a filtered collection.
This branch has not been deployed
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.
Fieldtype::config($key)is called constantly while augmenting and rendering, and every call rebuilt the whole config as collections: each config field's default value, merged with the field's own config, even when asking for a single key.This changes it so that:
computed:) defaults are still resolved on every read.HasSelectOptions::getLabel()also finds the option with a loop rather than a filtered collection.Benchmark
A generated site on 6.40.0 (entries, structured collections, navs of three sizes), six warm scenarios: three sets of page renders and three nav renders. Each request runs in its own PHP process, as PHP-FPM serves it (boot not timed, opcache on), on an M1 Pro with PHP 8.5. The rendered HTML is byte-identical to stock for two different generated sites.
This change on its own is 11% faster (geometric mean over the six scenarios).
Tests
Two new tests in
FieldtypeTest:The existing
it_only_computes_default_values_for_config_fields_missing_from_the_raw_configstill passes. The full suite passes.