I'm seeing a similar problem on 2.4.0. When editing a location or an organisation with >35k hosts and >6k hostgroups, Foreman freezes the browser tab and the application becomes unusable.
Looking at the developer tools, I can see that all the server side requests finish fine and that there's nothing on the JS console (which is dead). The Firefox process associated to the tab is consuming CPU all the time and the UI is totally clogged (forever?). I'm attaching a screenshot right after the problem starts to happen.
Unfortunately I can't use performance logging because when the issue triggers even the developer console dies.
On the other hand, when I edit an empty location living in the same Foreman instance things work.
From IRC (#theforeman@Libera.Chat):
<nacho> tbrisker: it must be hostgroups, then. Hostgroup.all.count => 6132. [14:05]
<tbrisker> nacho: i suppose so :) [14:06]
<nacho> tbrisker: haven't opened the ticket yet, would you rather if I added input to #24907?
<tbrisker> nacho: sure, better than having duplicate issues
<tbrisker> nacho: sad thing is it will likely require replacing the multiselect implementation to properly fix :\
<tbrisker> nacho: i think you could comment out lines 40 and 81 in /usr/share/foreman/app/views/taxonomies/_form.html.erb
if you don't want to manage hostgroups from that form as a workaround [14:08]
<tbrisker> nacho: but i would test that on a non-prod system first to make sure it doesn't break everything :)
<nacho> tbrisker: our instance running 2.4.0 is staging with a one-month old clone of the production DB; I can patch,
no problem. [14:11]
<nacho> tbrisker: okay so I'll add stuff to that ticket and try that suggested patch :) [14:12]
As a workaround I'll try to get rid of the hostgroup selector to see if that helps.