-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Performance regression in WP 6.1 for theme.json
processing
#44772
Comments
I'm trying to understand why cc @getdave, if I'm not mistaken that was added in the |
We merged two recent PRs in
The rationale for this is that the theme.json classes are now used before all the blocks are registered (aka get template data, etc.), hence, the caching wasn't working as expected. See #44434 and #44619 I'd like to have a better understanding of a baseline before/after these PRs to see what's the impact and whether it's something we need to act for 6.1 or can do later. |
Update: It looks like this commit is the culprit: WordPress/wordpress-develop@a937892 Props @ockham and @oandregal for pointing me to that direction 👍 |
Thank you for tracking this down, @aristath. I had left a comment on the originating PR with some suggestions for more caching: WordPress/wordpress-develop#3408 (comment). Maybe applying these could mitigate the issue? Unfortunately, I'll only have limited availability myself until Tuesday. Pinging @oandregal @andrewserong @ajlende @talldan @glendaviesnz who were involved in the original research for assistance 😅 |
Ah, that might not cut the mustard 😕 (I had missed these two comments: #44772 (comment) and #44772 (comment).) |
Posting 2 screenshots with the stats with and without that commit. With the commit applied: When reverting the commit: The times shown there are all in milliseconds, and keep in mind that Xdebug + profiling slow down the site a lot. However, the differences are an indication of the commit's impact. |
Thank you Ari! @oandregal Can we cache |
I've started to implement and track some improvements in WordPress/wordpress-develop#3418 |
WP_Theme_JSON::remove_keys_not_in_schema
theme.json
processing
The current state of WordPress/wordpress-develop#3418 |
I did some profiling with blackfire. These are the results. Can't think of a good reason why the method I believe this line is the issue.
|
Sorry for late reply I've been AFK. Based on my comment here it looks as though the method already existed as I was having to work around it by adding pseudo selectors to the schema so they didn't get stripped by this method. |
A significant performance regression was added late in WP 6.1 beta cycle when some of the existing caching for `theme.json` processing was removed. The rationale for removing the caching was this code was now used before all the blocks are registered (aka get template data, etc.) and resulted in stale cache that created issues (see [WordPress/gutenberg#44434 Gutenberg Issue 44434] and [WordPress/gutenberg#44619 Gutenberg Issue 44619]). The changes were limited to only reads from the file system. However, it introduced a big impact in performance. This commit adds caching and checks for blocks with different origins. How? It add caching for the calculated data for core, theme, and user based on the blocks that are registered. If the blocks haven't changed since the last time they were calculated for the origin, the cached data is returned. Otherwise, the data is recalculated and cached. Essentially, this brings back the previous cache, but refreshing it when the blocks change. It partially adds unit tests for these changes. Additional tests will be added. References: * [WordPress/gutenberg#44772 Performance regression in WP 6.1 for theme.json processing] Follow-up to [54251], [54399]. Props aristath, oandregal, bernhard-reiter, spacedmonkey, hellofromTonya. See #56467. git-svn-id: https://develop.svn.wordpress.org/trunk@54493 602fd350-edb4-49c9-b593-d223f7449a82
A significant performance regression was added late in WP 6.1 beta cycle when some of the existing caching for `theme.json` processing was removed. The rationale for removing the caching was this code was now used before all the blocks are registered (aka get template data, etc.) and resulted in stale cache that created issues (see [WordPress/gutenberg#44434 Gutenberg Issue 44434] and [WordPress/gutenberg#44619 Gutenberg Issue 44619]). The changes were limited to only reads from the file system. However, it introduced a big impact in performance. This commit adds caching and checks for blocks with different origins. How? It add caching for the calculated data for core, theme, and user based on the blocks that are registered. If the blocks haven't changed since the last time they were calculated for the origin, the cached data is returned. Otherwise, the data is recalculated and cached. Essentially, this brings back the previous cache, but refreshing it when the blocks change. It partially adds unit tests for these changes. Additional tests will be added. References: * [WordPress/gutenberg#44772 Performance regression in WP 6.1 for theme.json processing] Follow-up to [54251], [54399]. Props aristath, oandregal, bernhard-reiter, spacedmonkey, hellofromTonya. See #56467. Built from https://develop.svn.wordpress.org/trunk@54493 git-svn-id: http://core.svn.wordpress.org/trunk@54052 1a063a9b-81f0-0310-95a4-ce76da25c4cd
A significant performance regression was added late in WP 6.1 beta cycle when some of the existing caching for `theme.json` processing was removed. The rationale for removing the caching was this code was now used before all the blocks are registered (aka get template data, etc.) and resulted in stale cache that created issues (see [WordPress/gutenberg#44434 Gutenberg Issue 44434] and [WordPress/gutenberg#44619 Gutenberg Issue 44619]). The changes were limited to only reads from the file system. However, it introduced a big impact in performance. This commit adds caching and checks for blocks with different origins. How? It add caching for the calculated data for core, theme, and user based on the blocks that are registered. If the blocks haven't changed since the last time they were calculated for the origin, the cached data is returned. Otherwise, the data is recalculated and cached. Essentially, this brings back the previous cache, but refreshing it when the blocks change. It partially adds unit tests for these changes. Additional tests will be added. References: * [WordPress/gutenberg#44772 Performance regression in WP 6.1 for theme.json processing] Follow-up to [54251], [54399]. Props aristath, oandregal, bernhard-reiter, spacedmonkey, hellofromTonya. See #56467. Built from https://develop.svn.wordpress.org/trunk@54493 git-svn-id: https://core.svn.wordpress.org/trunk@54052 1a063a9b-81f0-0310-95a4-ce76da25c4cd
WordPress/wordpress-develop#3418 has landed bringing numbers back to 6.0 baseline. I'm still investigating this to squeeze more ms and have prepared WordPress/wordpress-develop#3441 as a modest improvement from 6.0 numbers. |
Since the issue was addressed in Core, I'll go ahead and close this one. |
A significant performance regression was added late in WP 6.1 beta cycle when some of the existing caching for `theme.json` processing was removed. The rationale for removing the caching was this code was now used before all the blocks are registered (aka get template data, etc.) and resulted in stale cache that created issues (see [WordPress/gutenberg#44434 Gutenberg Issue 44434] and [WordPress/gutenberg#44619 Gutenberg Issue 44619]). The changes were limited to only reads from the file system. However, it introduced a big impact in performance. This commit adds caching and checks for blocks with different origins. How? It add caching for the calculated data for core, theme, and user based on the blocks that are registered. If the blocks haven't changed since the last time they were calculated for the origin, the cached data is returned. Otherwise, the data is recalculated and cached. Essentially, this brings back the previous cache, but refreshing it when the blocks change. It partially adds unit tests for these changes. Additional tests will be added. References: * [WordPress/gutenberg#44772 Performance regression in WP 6.1 for theme.json processing] Follow-up to [54251], [54399]. Props aristath, oandregal, bernhard-reiter, spacedmonkey, hellofromTonya. See #56467. git-svn-id: https://develop.svn.wordpress.org/trunk@54493 602fd350-edb4-49c9-b593-d223f7449a82
Description
I'm currently trying to improve performance in WP-Core, and the thing that currently stands out as a bottleneck is the
WP_Theme_JSON::remove_keys_not_in_schema
method.Posting a screenshot of a webgrind analysis below:
WP_Theme_JSON::remove_keys_not_in_schema
runs 38228 times, and consumes 14.36% of resources/server-time.Step-by-step reproduction instructions
I'll just post instructions on how I setup
webgrind
on my localhost using wp-env, so hopefully others can also test and debug performance issues:.env
file. SetLOCAL_PHP_XDEBUG=true
, andLOCAL_PHP_XDEBUG_MODE=develop,debug,profile
.wp-content/plugins/webgrind
but all that matters is you put it somewhere you can access it from a URL.http://localhost:8889/wp-content/plugins/webgrind/
but it will vary depending on where you copied the files etc.Screenshots, screen recording, code snippet
No response
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: