Disable replace_methods in users autocomplete
What does this MR do and why?
We only need the availability String itself so defining all the String methods onto the lazy object is a waste. https://github.com/exAspArk/batch-loader#replacing-methods for more context.
We also don't do pagination on this endpoint. So on projects with a lot of members this endpoint is very slow and consumes a lot of memory.
Sample request on GitLab.com: https://log.gprd.gitlab.net/app/discover#/doc/7092c4e2-4eb5-46f2-8305-a7da2edad090/pubsub-rails-inf-gprd-006505?id=bUpeK3wBuGSvJmprsexW
json.mem_bytes: 169,722,818
json.mem_mallocs: 1,342,345
json.mem_objects: 1,941,998
json.mem_total_bytes: 247,402,738
This was from typing @
in a gitlab-org/gitlab
MR.
Flamegraph here (for team members only): https://gitlab.com/gitlab-org/gitlab/-/autocomplete_sources/members?type=MergeRequest&type_id=68925&performance_bar=flamegraph
It shows significant amount of time spent in BatchLoader#__replace_with!
and GC. This change should improve those significantly.
I also tested locally on a group with very few users and the results are still visible.
- Before: "mem_objects":219723,"mem_bytes":36238776,"mem_mallocs":120826,"mem_total_bytes":45027696
- After: "mem_objects":194955,"mem_bytes":11581336,"mem_mallocs":95228,"mem_total_bytes":19379536
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.