Bug #34938
don't re-evaluate TemplateInputs on every loop iteration
Description
When iterating over a big list of hosts (with load_hosts().each_record do |host|
or similar), it is rather expensive to call input()
inside the loop, as that hits the database every time.
For example, rendering the Ansible Inventory report with 3500 hosts, hits the DB with 35000 TemplateInput Loads (10× per host!).
Associated revisions
History
#1
Updated by The Foreman Bot 10 months ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/9223 added
#2
Updated by The Foreman Bot 10 months ago
- Fixed in Releases 3.4.0 added
#3
Updated by Evgeni Golov 10 months ago
- Status changed from Ready For Testing to Closed
Applied in changeset foreman|28d7b3c3a7c5679112a12b121ee1f8dea25adeb0.
Fixes #34938 - don't re-evaluate input() values on each host
poor laptop benchmark: with 3500 hosts, generating an Ansible inventory
took 200 seconds before, and 160 seconds after this patch.