Skip to content

fix(rbac): improve edit/create role page performance - #10346

Open
karthikjeeyar wants to merge 5 commits into
backstage:mainfrom
karthikjeeyar:fix/rbac-ui-performance
Open

fix(rbac): improve edit/create role page performance#10346
karthikjeeyar wants to merge 5 commits into
backstage:mainfrom
karthikjeeyar:fix/rbac-ui-performance

Conversation

@karthikjeeyar

@karthikjeeyar karthikjeeyar commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Hey, I just made a Pull Request!

Improves RBAC create/edit role page performance.

Summary

  • Replace upfront loading of all catalog users/groups with server-side search (searchMembers) fetching only the members assigned to a role (getMembersByRefs)
  • Add debounced search (300ms) to the users/groups dropdown with first 100 entities loaded by default
  • Fetch only required fields when resolving member references, with batching (2000 per request)
  • Change getMembers() calls to getMembers(1, 1) for authentication checks (eg: to enable edit button in role page) instead of fetching all entities

Screenshots:

Before fix

Issues Screenshots
Stuck in loading phase edit_page_stuck_in_loading
Unresponsive browser Unresponsive
Edit button in role edit page disabled for a very long time. Edit_button_disabled

After fix

RBAC_Page_Performance_fixed.mov

How to test

  1. Add the following to your app-config.yaml under catalog.locations:

    - type: url
      target: https://github.com/karthikjeeyar/DevRepo/blob/master/load-testing/5k-org-entities.yaml
      rules:
        - allow: [User, Group]

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message. (more info)

Signed-off-by: Karthik <karthik.jk11@gmail.com>
Signed-off-by: Karthik <karthik.jk11@gmail.com>
@karthikjeeyar
karthikjeeyar force-pushed the fix/rbac-ui-performance branch from 6b01305 to 8e8132a Compare August 18, 2026 05:03
@backstage-goalie

backstage-goalie Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage-community/plugin-rbac workspaces/rbac/plugins/rbac patch v2.1.1

@its-mitesh-kumar its-mitesh-kumar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@karthikjeeyar With searchMembers hard-coded to limit=100 and a catalog of 5K+ users, if more than 100 users match a term like "dev-", the user only sees the first 100 with no way to reach the rest. For better UX, we can think of adding a "Load more" button at the bottom of the dropdown that fetches the next 100 using offset-based pagination. We can also do it as follow up PR not a blocker for this PR.
@ShiranHi @tobiastal what's your thought on this ?

@karthikjeeyar

Copy link
Copy Markdown
Contributor Author

Yes, I noticed this limitation earlier as well. There is currently a cap of 100 items in the dropdown, and I agree there is room for improvement here, like Load more option.

I intentionally haven’t included that in this PR because it would be a new feature and I’d like to keep this change focused so that it can be safely backported. We can address the Load more experience as a follow-up PR based on UX inputs.

Comment thread workspaces/rbac/plugins/rbac/src/hooks/useMembers.ts Outdated
Comment thread workspaces/rbac/plugins/rbac/src/components/CreateRole/AddMembersForm.tsx Outdated

@its-mitesh-kumar its-mitesh-kumar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verified it with 5k+ users the crash issue has gone. PR can be merged once we addressed the above comments.

S_.2026-08-19.at.2.09.38.PM.mov

@its-mitesh-kumar

Copy link
Copy Markdown
Contributor

@karthikjeeyar The memberRefs memo depends on [role], but role gets a new object reference every time roleRetry() fires from the polling interval (every 10s). Even when memberReferences content hasn't changed, memberRefs produces a new array reference, which triggers useAsyncRetry to re-call getMembersByRefs — an unnecessary network call every poll cycle.

I'd like if we can stabilize memberRefs with a deep/shallow compare so the downstream fetch only fires when the actual refs change. Since memberRefs is a flat string[], a simple element-wise comparison would work — either via a small useStableArray hook or useDeepCompareEffect from react-use (already a dependency).

@karthikjeeyar
karthikjeeyar force-pushed the fix/rbac-ui-performance branch from fc7a214 to be25a32 Compare August 19, 2026 09:50
Comment thread workspaces/rbac/plugins/rbac/src/hooks/useSelectedMembers.ts Outdated
Signed-off-by: Karthik <karthik.jk11@gmail.com>
@karthikjeeyar
karthikjeeyar force-pushed the fix/rbac-ui-performance branch from be25a32 to f3688c0 Compare August 19, 2026 10:01
@sanketpathak

Copy link
Copy Markdown
Contributor

@karthikjeeyar I'm getting slight lag of 1-1.5 seconds. I've added 270 users in create role page and if I try to add or remove added users, there is delay in click. Is this expected?

Screen.Recording.2026-08-19.at.4.35.34.PM.mov

Comment thread workspaces/rbac/plugins/rbac/src/hooks/useMembers.ts Outdated
Comment thread workspaces/rbac/plugins/rbac/src/hooks/useMembers.ts Outdated
Comment thread workspaces/rbac/plugins/rbac/src/hooks/useMembers.ts
Signed-off-by: Karthik <karthik.jk11@gmail.com>
@karthikjeeyar

Copy link
Copy Markdown
Contributor Author

@sanketpathak Good catch on the selection lag with a large number of members. The issue was already present, but hadn't been identified previously. All the auto-complete callback were re-created everytime and list item was not using a unique key.

I've now memoized the autocomplete callbacks and fixed duplicate React keys, which addresses the underlying causes of the lag. PTAL

Fix_dropdown_selection_issue.mov

Signed-off-by: Karthik <karthik.jk11@gmail.com>
@karthikjeeyar
karthikjeeyar force-pushed the fix/rbac-ui-performance branch from c710b4d to 6c00b46 Compare August 19, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants