Improve Site Defaults performance with many sites#624
Merged
Conversation
`SiteDefaults::origins()` rebuilt the addon settings from disk (YAML parse + Antlers over every stored value) on every call, and it's called once per site while building the page. On installs with many sites this made the Site Defaults page take 30s+ to load. Memoize the getter with Blink::once, matching how `get()` is already cached, and invalidate it alongside the existing cache when origins are saved. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`LocalizedSiteDefaults::augmented()` ran two full blueprint augmentation passes on every call with no memoization, which is repeated per-item in the sitemap, reporting and GraphQL paths. Wrap it in Blink::once per locale, matching the section defaults equivalent, and invalidate it when defaults are saved. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
This pull request fixes performance issues with Site Defaults that get noticeably worse as the number of configured sites grows — the Site Defaults page in the Control Panel could take 30 seconds or more to load, and there was a slowdown on the front-end during metadata retrieval.
This was happening because
SiteDefaults::origins()rebuilt the addon settings from disk on every call (a YAML parse plus running Antlers over every stored value), and it's called once per site while building the page, so the work scaled roughly with the square of the site count.LocalizedSiteDefaults::augmented()had a similar issue, running two full blueprint augmentation passes on every call with no memoization.This PR fixes it by memoizing both with
Blink::once— matching howSiteDefaults::get()and the section defaults equivalent are already cached — and invalidating the caches when defaults are saved.