Performance degradation in role selection needs investigation and optimization.
The issue reports slow performance when selecting/deselecting roles in the User Doctype, especially noticeable with large numbers of roles. The problem requires performance profiling and optimization of the role selection mechanism. The regression since v15.87.0 suggests this may involve recent changes in the codebase.
Select All and Unselect All buttons in User Doctype to select Role become slow as the number of roles increases.
For better systems with 16 GB RAM, it takes around 500 roles to see the slowness, but for 4GB systems, even for 200 roles, which is a reasonable amount of roles, it is extremely slow (takes around 5-10s).
The thing is, for the older version that I used to use, v15.87.0, it is fast even for similar number of users.
Output of bench version
doppio 0.0.1
frappe 15.103.0
insights 3.2.18
lms 2.48.0
import frappe
count = 0
for i in range(1, 500):
role_name = f"BUG_TEST_USER_{i:03d}"
if not frappe.db.exists("Role", role_name):
frappe.get_doc({"doctype": "Role", "role_name": role_name}).insert(ignore_permissions=True)
count += 1
frappe.db.commit()
print(f"Created {count} roles")
roles = frappe.get_all("Role", filters={"name": ["like", "BUG_TEST_USER_%"]}, pluck="name")
for role in roles:
try:
frappe.delete_doc("Role", role, ignore_permissions=True)
except Exception:
print("Skipping", role)
continue
frappe.db.commit()
print(f"Deleted {len(roles)} test roles.")
Takes around 5 seconds to select/deselect all roles.
Should be immediate.
MacOS, M3 Bare Metal Setup
https://github.com/user-attachments/assets/f4738b29-cd83-4c13-a331-39cb7f347f8d
Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!