Project

General

Profile

Bug #34938

don't re-evaluate TemplateInputs on every loop iteration

Added by Evgeni Golov 10 months ago. Updated 10 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Reporting
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Fixed in Releases:
Found in Releases:
Red Hat JIRA:

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

Revision 28d7b3c3 (diff)
Added by Evgeni Golov 10 months ago

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.

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

Also available in: Atom PDF