New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixes #2498 FactNames are not precreated #615
Conversation
Looks good. It would be nice to avoid the find_or_create_by_name multiple lookups if possible, but this should still be merged even if we can't avoid it - its a significant increase in performance. |
@@ -85,18 +85,13 @@ def merge_facts(facts) | |||
fact_names = FactName.where(:name => facts.keys) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't look like fact_names is being used anymore...
@witlessbird 's fix showed an speed improvement of 5-10%, so I updated the pull request |
@elobato Thanks for spending your time on profiling this! |
@elobato can you please squash the commits? |
Witlessbird's fix to reduce database lookups and do Ruby hash lookups instead
@skottler done! |
next if db_facts.include?(fact_name.name) | ||
value = facts[fact_name.name] | ||
facts.each do |name, value| | ||
next if db_facts.include?(name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of comparing each run, cant we also optimize it, e.g. something in the spirit of:
(facts.keys - db_facts).each do |name|
value = facts[name]
facts.keys.dup.delete_if { |n| fact_names.map(&:name).include? n } creates a tremendous overhead on the facts import from the puppet masters, this fix simply takes the code from the original Puppet::Rails::Host. As an example, imports have gone from ~30s to ~200ms