Skip to content
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

Cache parse of block in block patterns #5421

Draft
wants to merge 9 commits into
base: trunk
Choose a base branch
from

Conversation

spacedmonkey
Copy link
Member

Trac ticket: https://core.trac.wordpress.org/ticket/59541


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@spacedmonkey spacedmonkey requested review from ockham and gziolo October 6, 2023 14:56
@gziolo
Copy link
Member

gziolo commented Oct 6, 2023

In my testing #5399, I also extracted the logic for updating the content of the pattern to a new method. I was validating other refactoring, though. So, both PRs separately could potentially improve performance.

@ockham
Copy link
Contributor

ockham commented Oct 9, 2023

This is a promising approach 🤔 Maybe I closed the ticket too early 😅 (although arguably, this PR does something different than what the ticket says, so it might be worth filing a new one).

Let's maybe run some numbers on this one, and rebase it once @gziolo's #5399 lands (in order to use the extracted parsing and hooked blocks insertion logic).

return array_values( $patterns );
}

protected function get_parse_blocks( $pattern ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick, we might want a different name for the method, as it not only parses the content but also (conditionally) inserts hooked blocks, and returns re-serialized markup.

(Per #5421 (comment), we might just use pepare_content from #5399 as name.)

@felixarntz
Copy link
Member

@spacedmonkey Now that #5399 has been committed, there is a merge conflict here. Could you please address it?

Curious to run benchmarks on this once it's up to date with latest trunk.

@spacedmonkey
Copy link
Member Author

@spacedmonkey Now that #5399 has been committed, there is a merge conflict here. Could you please address it?

Curious to run benchmarks on this once it's up to date with latest trunk.

I will provide benchmarks tomorrow.

@spacedmonkey
Copy link
Member Author

So after some testing, it seems like there is little performance benefit from this change now. All the performance benefit seems to have been committed in #5399.

This PR might be useful for times where there the same pattern is used multiple times on a page. Not in all the example themes I found, I could not find an example where it did this. I am also worried that the filters would not run if this result was cached.

I still think there is something here, but it needs more work and is unlikely to make it's way into core in this release. Closing for now.

@gziolo
Copy link
Member

gziolo commented Oct 10, 2023

I see that the ticket got reopened. It would be great to run the benchmarks again with the latest trunk. Related Slack comment with a better context (accessing the link might require registration at https://make.wordpress.org/chat/):
https://wordpress.slack.com/archives/C02RQBWTW/p1696950609355169?thread_ts=1696880738.627909&cid=C02RQBWTW .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants