New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Block Template persistent cache- transient + object cache. #6369
base: trunk
Are you sure you want to change the base?
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @kt-12. When running some profiling data on this approach, I'm not seeing much benefit to adding a cache at this point in the execution process.
Comparing runs of _build_block_template_result_from_file()
with and without this cache in place, there is a marginal improvement and seems like the need to query the DB for these transients offsets any benefit in avoiding the file_get_contents()
calls. In fact, this function is only responsible for ~1% of the overall execution time of the TT4 homepage without additional caching, so I'm not sure there is a benefit in adding caching here.
_build_block_template_result_from_file()
get_block_templates()
However, its parent function, get_block_templates()
, does seem to be present a bigger opportunity for improvement, as it's profiling at 5% of iwt for the same requests. Of that time, most of the cost seems to from _get_block_templates_files()
, with most of that processing eventually happening in wp_get_theme_data_custom_templates()
when the WP_Theme_JSON_Resolver::get_theme_data()
parses the customTemplates
property from the WP_Theme_JSON
data provided by the theme.
I think we could consider adding a cache to either _get_block_templates_files()
or wp_get_theme_data_custom_templates()
to have bigger impact—at least until we are able to handle some/all of https://core.trac.wordpress.org/ticket/57789.
I was investigating the performance opportunity |
Trac ticket: https://core.trac.wordpress.org/ticket/59600
Tested Performance for Memcache version on Trunk and PR - Trunk median was 114.6 and PR median was 113
I also tested the transient version on Trunk and PR but could see a downgrade of around 5 ms.
However, I am not confident about the result as I could see drastic performance fluctuation and had to do the test several rounds to get a convincing stable result.
This Pull Request is for code review only. Please keep all other discussions in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.