[wp-trac] [WordPress Trac] #56975: Replace the internal `WP_Theme_JSON_Resolver::theme_has_support()` with a public function

WordPress Trac noreply at wordpress.org
Fri Jan 20 07:33:13 UTC 2023


#56975: Replace the internal `WP_Theme_JSON_Resolver::theme_has_support()` with a
public function
-------------------------------------------------+-------------------------
 Reporter:  oandregal                            |       Owner:
                                                 |  hellofromTonya
     Type:  enhancement                          |      Status:  reopened
 Priority:  normal                               |   Milestone:  6.2
Component:  Themes                               |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  dev-feedback gutenberg-merge has-    |     Focuses:
  patch has-unit-tests has-testing-info          |  performance
-------------------------------------------------+-------------------------

Comment (by flixos90):

 I am also leaning towards the noop option, however given @Otto42's
 feedback I wanted to see what the real performance impact of this caching
 is. So I did a quick test, making 20 requests and recording median
 performance metrics.

 Results are in this spreadsheet:
 https://docs.google.com/spreadsheets/d/1lTw0d4iyNJ91Jg0Ru3RXCMvSASRaV5vFIsWIkgOjBTU/edit

 TLDR: The function itself is indeed relevant for performance. It is a
 single function in WordPress core that, because it is called so often (137
 times), makes for **more than 1% of overall WordPress load time**. 1%
 seems little, but for a single simple-looking function, it is quite a lot.

 That said, it looks like caching did not help with performance at all
 based on this data. It seems the overhead of cache lookup is somewhat
 comparable to the filesystem checks. And this is even without `object-
 cache.php`, so no external connection that would potentially be a problem.
 So for real performance impact, **caching does not appear to help**.

 Please review. My current advise based on this would be to discard this
 effort entirely. What I think would make more sense is to try to reduce
 the excessive number of calls to `wp_theme_has_theme_json()` or find other
 ways to simplify.

 I created a Gist with how I got the data, may be useful for other similar
 quick performance tests too:
 https://gist.github.com/felixarntz/de5c697a1a16c2b892634b70216eb6c7

 Curious what you think @hellofromTonya @azaozz @spacedmonkey @oandregal.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56975#comment:65>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list