Feature #36696
closed
Improve performance of adding or removing members of a group
Added by James H over 2 years ago.
Updated over 2 years ago.
Description
In situations where groups are applied to hundreds of projects (with or without subprojects, with or without inherit members), adding or removing a user from the group takes VERY LONG (more than 5-10 minutes).
Would like to request:
- Better querying optimization?
- Bulk edit capability
1. not sure how because I do not know how it queries. maybe something like consolidate multiple queries into fewer big queries?
2. When looking at the "users" tab under Groups, have a checkmark selection and "Apply All" button at the bottom for actions applied for multiple users at once. This way it can try to optimize the query for that?
Files
or maybe make it a background job similar to like #36691
I wrote a patch that speeds up the adding of a group member. In my test environment with 500+ projects, I got a speedup of about 30%.
Before:
Completed 200 OK in 1674ms (Views: 10.3ms | ActiveRecord: 275.6ms | Allocations: 924861)
Completed 200 OK in 1691ms (Views: 2.7ms | ActiveRecord: 278.2ms | Allocations: 921060)
Completed 200 OK in 1734ms (Views: 2.1ms | ActiveRecord: 294.0ms | Allocations: 921192)
Completed 200 OK in 1928ms (Views: 3.0ms | ActiveRecord: 305.9ms | Allocations: 921065)
Completed 200 OK in 1655ms (Views: 2.7ms | ActiveRecord: 277.6ms | Allocations: 921057)
After:
Completed 200 OK in 1309ms (Views: 4.1ms | ActiveRecord: 185.9ms | Allocations: 754306)
Completed 200 OK in 1264ms (Views: 2.1ms | ActiveRecord: 169.1ms | Allocations: 745979)
Completed 200 OK in 1392ms (Views: 2.7ms | ActiveRecord: 184.0ms | Allocations: 745980)
Completed 200 OK in 1299ms (Views: 2.1ms | ActiveRecord: 173.2ms | Allocations: 746013)
Completed 200 OK in 1256ms (Views: 2.1ms | ActiveRecord: 168.8ms | Allocations: 745976)
Updated the patch. Now it also improves the speed of removing a group member. The speedup of GroupsController#remove_user is about 20% in my test environment.
Before:
Completed 200 OK in 1555ms (Views: 8.9ms | ActiveRecord: 281.5ms | Allocations: 951235)
Completed 200 OK in 1605ms (Views: 2.3ms | ActiveRecord: 295.5ms | Allocations: 947796)
Completed 200 OK in 1551ms (Views: 2.7ms | ActiveRecord: 290.3ms | Allocations: 947743)
Completed 200 OK in 1566ms (Views: 3.6ms | ActiveRecord: 289.5ms | Allocations: 947744)
Completed 200 OK in 1610ms (Views: 2.7ms | ActiveRecord: 300.5ms | Allocations: 947749)
After:
Completed 200 OK in 1247ms (Views: 4.6ms | ActiveRecord: 221.6ms | Allocations: 732887)
Completed 200 OK in 1364ms (Views: 2.1ms | ActiveRecord: 248.6ms | Allocations: 729979)
Completed 200 OK in 1255ms (Views: 2.1ms | ActiveRecord: 231.0ms | Allocations: 730074)
Completed 200 OK in 1399ms (Views: 2.0ms | ActiveRecord: 261.1ms | Allocations: 729955)
Completed 200 OK in 1285ms (Views: 2.2ms | ActiveRecord: 232.4ms | Allocations: 729953)
That was quick, thank you for your efforts!
- Subject changed from Group members - query optimization & bulk edit to Improve performance of adding or removing members of a group
- Category changed from Groups to Performance
- Target version set to 5.0.0
Setting the target version to 5.0.0.
- Status changed from New to Closed
- Assignee set to Go MAEDA
- Resolution set to Fixed
- Related to Patch #36730: Replace Member.find_or_new with ActiveRecord's find_or_initialize_by added
Also available in: Atom
PDF