[wp-trac] [WordPress Trac] #39210: switch_to_locale() unloads all plugin and theme translations

WordPress Trac noreply at wordpress.org
Thu Oct 20 00:48:17 UTC 2022


#39210: switch_to_locale() unloads all plugin and theme translations
-------------------------------------------------+-------------------------
 Reporter:  gchtr                                |       Owner:  ocean90
     Type:  defect (bug)                         |      Status:  reopened
 Priority:  normal                               |   Milestone:  6.1
Component:  I18N                                 |     Version:  4.7
 Severity:  normal                               |  Resolution:
 Keywords:  has-unit-tests has-patch needs-dev-  |     Focuses:
  note                                           |
-------------------------------------------------+-------------------------
Changes (by flixos90):

 * status:  closed => reopened
 * resolution:  fixed =>


Comment:

 Unfortunately, it appears that this change has introduced a major
 performance regression. A few days ago I conducted a performance analysis
 comparing 6.1-RC1 (and yesterday RC2) to the latest 6.0 release, finding a
 regression of ~10% slower WordPress execution on average.

 Myself and several other folks have since looked at possible causes for
 the regression, and earlier today @spacedmonkey messaged me, suggesting
 that the changes for loading the textdomain from here are a major part of
 the problem.

 I looked into it further and they indeed are:
 * When using the en_US locale, `load_textdomain()` is (unnecessarily)
 called a ton of times (107 times in WP 6.1-RC2 vs 3 times in WP 6.0.3).
 * The regression makes a en_US site with WP 6.1-RC2 load **~9.4% slower**
 than with WP 6.0.3 (151.3ms vs 138.2ms). This makes it likely the only
 notable cause for the regression.
 * Using a hacked version of WP 6.1-RC2 with the relevant code bits
 replaced with the 6.0.3 code, performance for an en_US site is back to the
 levels from 6.0.3.
 * The regression is only present on en_US sites. For sites that use a
 locale that typically has translation files present, performance remains
 basically as before.
 * The problem is caused by the changes to
 `_load_textdomain_just_in_time()`, which uses the new
 `WP_Textdomain_Registry` class.

 Due to this notable regression, I propose to revert [53874] for now and
 resolve the underlying problem for WordPress 6.2. Since the problem only
 occurs for en_US sites, there's a good chance this issue should not
 present a major complexity to address. Of course, if there is a simple
 fix, we could try to get it into RC3 - the main point is that we either
 need to fix this right away or revert before the 6.1 stable launch.

 I will also upload a screenshot of the spreadsheet where I collected the
 data that led to this conclusion.

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


More information about the wp-trac mailing list