-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Perf: Avoid rich-text binding subscription if block does not have bindings #72496
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
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: +12 B (0%) Total Size: 2.21 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in 6258aaa. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/18719927200
|
|
Nice to see more folks looking into performance :) @ellatrix might be a good person to review when it comes to RichText. Although my guess is that this part is over optimized already, I'd love to find wins there. |
|
Nice exploration, @jeryj! One of the bottlenecks that @ellatrix and @jsnajdr discovered when doing optimization is number of store subscriptions, especially to the Redux stores have an O(n) subscription setup. N selected components means N subscriber callbacks and selectors run on every dispatch. |
|
What's the performance gain on average on how many runs? |
|
I can check after beta 1, if I forget, ping me :) |
114db5d to
5f22dbe
Compare
5f22dbe to
b4f6a77
Compare
b4f6a77 to
6258aaa
Compare
|
@ellatrix Just ran this once on GitHub CLI, but it's reliably way down locally too. The improvement removes the inserter hover is down 29% and type is down ~ 13%
|
|
Wait, weren't the code changes here before about a different file (format types), or was that a different PR? |
|
And yes, we shouldn't add separate block editor subscription to rich text... so that makes sense. Could you get a review from whoever added these changes to test? |
It was probably this one. I've been playing around with different things trying to figure out the best optimizations, so those were all reverted in favor of removing this subscription.
Yup - on it. Reviews requested from @ockham and @cbravobernal. |
Mamaduka
left a comment
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, @jeryj!
The optimization makes sense. @cbravobernal did something similar last week #72351.
I'll defer on final approval to @cbravobernal and @ockham.
cbravobernal
left a comment
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.
Makes totally sense. LGTM.
…72496) Co-authored-by: jeryj <[email protected]> Co-authored-by: youknowriad <[email protected]> Co-authored-by: Mamaduka <[email protected]> Co-authored-by: cbravobernal <[email protected]> Co-authored-by: ellatrix <[email protected]>
|
I just cherry-picked this PR to the wp/6.9 branch to get it included in the next release: 6fcd212 |
|
Thanks folks! And apologies for the performance hit I introduced inadvertently 🙈 |

What?
Closes
In #71820 a subscription was added to all RichText components even if there is no block bindings. This caused the inserterHover and type metrics to go up:
#72351 helped address it, but it doesn't seem like the performance improved as significantly as hoped as it did not remove the RichText subscription.
Why?
Any improvements we can make here impact the whole experience.
Excessive subscriptions degrade performance, so we should reduce subscriptions if possible.
How?
Check for the presence of bindable attributes from the PrivateContext instead of settings, so we don't need to add a new subscription. This returns the inserterHover performance metric back to the baseline before #71820.
The current potential win is an early return to avoid adding unnecessary subscriptions for rich-text bindings:
Testing Instructions
There should be no functional changes from trunk.
Testing Instructions for Keyboard
Screenshots or screencast