[wp-trac] [WordPress Trac] #58196: Improve performance of `_get_block_templates_paths`
WordPress Trac
noreply at wordpress.org
Fri Apr 28 22:10:16 UTC 2023
#58196: Improve performance of `_get_block_templates_paths`
-----------------------------------------+------------------------------
Reporter: spacedmonkey | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Themes | Version: 5.9
Severity: normal | Resolution:
Keywords: has-patch reporter-feedback | Focuses: performance
-----------------------------------------+------------------------------
Changes (by joemcgill):
* keywords: has-patch => has-patch reporter-feedback
Comment:
Thanks @spacedmonkey. I'm not able to reproduce conditions where this
function is profiling with the type of performance concerns you mentioned.
Can you share more details about you've got your profiling setup
configured to observe these results so I can try to reproduce?
I've done several profiling runs using the current `trunk` branch and am
generally seeing that this function is called 5 times on the homepage of
the twenty twenty-three theme with very little impact to overall
performance (<1% inclusive wall time). Additionally, in some of my runs,
this is only being called once, which would indicate that there is some
upstream caching somewhere that sometimes avoids the codepath that makes
the extra calls by avoiding the initial call to `resolve_block_template()`
that is responsible for all but one call to this function (the other being
triggered from `build_template_part_block_instance_variations()`
eventually). I'd like to do some more digging to see why this is.
Regardless, the approach you're suggesting to save the results of the
recursive lookup to a static variable makes sense to me, since this should
only need to be calculated once per page run. I'd rather avoid trying to
create a standalone helper function for this unless we're planning to use
it in more places to do more performant recursive lookups like this.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58196#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list