[wp-trac] [WordPress Trac] #64538: memoize wp_normalize_path

WordPress Trac noreply at wordpress.org
Fri Mar 6 20:04:47 UTC 2026


#64538: memoize wp_normalize_path
---------------------------------------------+--------------------------
 Reporter:  josephscott                      |       Owner:  dmsnell
     Type:  defect (bug)                     |      Status:  closed
 Priority:  normal                           |   Milestone:  7.0
Component:  General                          |     Version:  3.9
 Severity:  normal                           |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests commit  |     Focuses:  performance
---------------------------------------------+--------------------------
Changes (by dmsnell):

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


Comment:

 In [changeset:"61857" 61857]:
 {{{
 #!CommitTicketReference repository="" revision="61857"
 Functions: Memoize `wp_normalize_path()`.

 `wp_normalize_path()` is called thousands of times on a given request.
 This patch adds memoization via a function-local static variable. This
 reduces the call count to the underlying `wp_is_stream()` function, and
 measured in testing around a 66% cache hit rate.

 In testing, for a site making 4000 calls to `wp_normalize_path()`, this
 patch led to a reduction in runtime from 1.4 ms to 0.4 ms on the test
 computer. While small, this time occurs early in the hotpath of the
 loading WordPress.

 Developed in: https://github.com/WordPress/wordpress-develop/pull/10770
 Discussed in: https://core.trac.wordpress.org/ticket/64538

 Props dmsnell, josephscott, mreishus, westonruter.
 Fixes #64538.
 }}}

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


More information about the wp-trac mailing list