[wp-trac] [WordPress Trac] #51678: [5.6 Beta] Performance regression with i10n changes when translations files are not present

WordPress Trac noreply at wordpress.org
Fri Oct 30 13:36:50 UTC 2020


#51678: [5.6 Beta] Performance regression with i10n changes when translations files
are not present
--------------------------+-----------------------------
 Reporter:  vedjain       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 In WooCommerce's internal autmated performance testing, we are seeing
 performance degradations in all paths where any plugin is loaded whose
 translation file is not present. Root cause seems to in #49236, where we
 added some changes and introduced WP_Textdomain_Registry to store text
 domains and their language directory paths.

 Looks like, if translation file is not present for a domain, we hit the
 [https://core.trac.wordpress.org/browser/trunk/src/wp-
 includes/l10n.php?rev=49236#L742 is_readable] on every l10n call. While
 cached internally, it seems like this call is still slow on many hosts and
 it will be good to add additional caching around it.

 Adding line `$wp_textdomain_registry->set( $domain, false );` inside `if (
 ! is_readable( $mofile ) )` block restores the performance on our test
 sites, and I'd recommend that we commit this change, because:

 1. It's unlikely that the result of `is_readable( $mofile )` will ever
 change during the context of a request, so it should be fine to cache this
 result in `wp_textdomain_registry`.

 2. Setting it to false here will cause an early return inside
 `_load_textdomain_just_in_time`, thereby  reducing calls to `is_readaable`
 eventually.

 3. As far as I can see, this still preserves the original fix intended in
 #49326.

 4. We were in fact caching the output of this call previous to #49326.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/51678>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list