[wp-trac] [WordPress Trac] #58528: Performance issue in register_block_style_handle
WordPress Trac
noreply at wordpress.org
Tue Jun 13 12:19:33 UTC 2023
#58528: Performance issue in register_block_style_handle
--------------------------+-----------------------------
Reporter: spacedmonkey | Owner: (none)
Type: enhancement | Status: new
Priority: high | Milestone: Future Release
Component: Editor | Version: 5.8
Severity: normal | Resolution:
Keywords: has-patch | Focuses: performance
--------------------------+-----------------------------
Comment (by spacedmonkey):
@aristath @felixarntz @joemcgill
So I have been doing some discovery on this ticket. I found the issue.
realpath is being in `register_block_style_handle`, on styles that we know
do not exist. Realpath on file that do not exist, are expensive and are
not cached. In https://github.com/WordPress/wordpress-
develop/commit/716a99587c04e5b37b4ceacc3ccce6c72c842464, styles are
register for editor and fe, in a way that they are meant to register with
URL false, so developer can register inline styles.
So there are two problems in the core.
1. For core blocks we know do not have styles for FE or editor styles,
skip calling `register_block_style_handle` and just call
`wp_register_style` with false. This means no backwards compatibility
break. This avoid, the call to realpath in `register_block_style_handle`
and other logic that is not needed, as we know the exist does not exist.
2. For third party blocks we know what are doing this as well, add a
file_exist before calling realpath. This still takes up time and I/O, but
it is much faster than realpath, that does symlink lookup etc when called.
I put together PR [https://github.com/WordPress/wordpress-
develop/pull/4599 here].
Benchmarks on 5000 requests
|| || Trunk || PR ||
|| Response Time (median) || 300.03 || 283.83 ||
|| wp-load-alloptions-query (median) || 0.71 || 0.71 ||
|| wp-before-template (median) || 34.27 || 29.61 ||
|| wp-before-template-db-queries (median) || 3.14 || 3.22 ||
|| wp-template (median) || 58.85 || 59.34 ||
|| wp-total (median) || 93.45 || 89.59 ||
|| wp-template-db-queries (median) || 6.42 || 6.57 ||
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58528#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list