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

Refactor the standard role editor to optimize its performance #50871

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bl-nero
Copy link
Contributor

@bl-nero bl-nero commented Jan 8, 2025

This change makes every role editor section render separately, not affecting other sections. This allows us to scale to a large number of access rules and resource sections without causing UI lag.

The optimization is achieved by UI component property memoization. In order to do it, we switch from managing the standard editor state using useState() to useReducer(). The state and action dispatcher are created with a new useStandardModel() function. This allows us to pass around a stable dispatcher reference instead of individual callbacks, which at some level had to depend on some top-level state.

Another change required to support memoization in the rendering phase is memoizing partial validation results.

The optimizations were verified using the React profiler and making sure that changing one section doesn't cause rendering others.

No user-visible changes expected, apart from a snappier UI (best tested with a 6x CPU throttling, if you have a beast of a machine).

This change makes every role editor section render separately, not
affecting other sections. This is achieved by property memoization. In
order to do it, we switch from managing the standard editor state using
`useState()` to `useReducer()`. The state and action dispatcher are
created with a new `useStandardModel()` function.

Another change required to support memoization in the rendering phase is
memoizing partial validation results.
@bl-nero bl-nero added the no-changelog Indicates that a PR does not require a changelog entry label Jan 8, 2025
@github-actions github-actions bot requested review from gzdunek and kimlisa January 8, 2025 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v17 no-changelog Indicates that a PR does not require a changelog entry size/md ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant