Navigation: minimize the number of innerblocks renders#58506
Closed
Navigation: minimize the number of innerblocks renders#58506
Conversation
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
oandregal
commented
Jan 31, 2024
| foreach ( $inner_blocks as $inner_block ) { | ||
| $inner_block_content = $inner_block->render(); | ||
| $p = new WP_HTML_Tag_Processor( $inner_block_content ); | ||
| $inner_blocks_content = static::get_inner_blocks_content( $inner_blocks ); |
Member
Author
There was a problem hiding this comment.
What we need to do is making suer inner blocks only render once for the navigation block. These are not the changes we need, but it helps demonstrate the impact.
Options:
- Refactor the code for the inner blocks to be rendered once at
WP_Navigation_Block_Renderer::render. - Cache the inner blocks rendering.
I'd very much prefer 1, given this code is new, and so we can make any modifications to it. Once it's in core we won't. Caching moves the issue from time to memory.
Member
Author
|
Closing in favor of #58513 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NOT TO MERGE.
What?
This PR is an experiment to minimize the number of
$inner_blocksrenders in the navigation block.Why?
The initial package update for 6.5 took a performance hit. Part of it was due to the navigation block render refactor at #55605. That PR increased from 1 to 6 the number of times its inner blocks rendered, causing a cascade of other updates, degrading performance.
WP_Block->renderSee also some kcachegrind visualizations:
I'm also sharing the cachegrind-logs.zip for people to inspect by their own. qcachegrind (macos) or kcachegrind (linux) can be used to open and inspect the files (see images in table).
How?
TBD.
The test case here just demonstrate how this is an issue, but it's not the proper implementation.
Testing Instructions
TBD.
The performance tests in Gutenberg won't report any performance impact, the same #55605 didn't. The reason is that the test data doesn't cover the navigation block appropriately. The core performance tests cover more ground for the navigation block.
These changes are ported to core via the
@wordpress/block-librarypackage. How can we test the changes in this PR in core?