Skip to content

Performance regression in WP 6.1 for theme.json processing #44772

@aristath

Description

@aristath

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:

Screenshot 2022-10-07 at 11 15 06 AM

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:

  1. I use the https://github.com/WordPress/wordpress-develop repo, but I think the same would apply for this one. Edit the .env file. Set LOCAL_PHP_XDEBUG=true, and LOCAL_PHP_XDEBUG_MODE=develop,debug,profile.
  2. Download or clone https://github.com/jokkedk/webgrind locally. I do it in wp-content/plugins/webgrind but all that matters is you put it somewhere you can access it from a URL.
  3. start wp-env normally. Xdebug will now be available and profiling will run. Which also means that page-loads will be significantly slower due to all the profiling happening in the background.
  4. Visit your site, login, then refresh the frontend a few times. Doing multiple runs will allow you to get some more stats and you can ensure that the stats you see later are not a fluke but consistent between all your page-loads.
  5. Visit the URL where you copied webgrind, and examine the results. In my case that's on 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

  • WordPress trunk
  • No plugins activated
  • Happens with and without the Gutenberg plugin active

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Type] BugAn existing feature does not function as intended[Type] PerformanceRelated to performance efforts[Type] RegressionRelated to a regression in the latest release

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions