Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

dLobatog
Copy link
Member

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

@GregSutcliffe
Copy link
Member

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)

Copy link
Member

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...

@dLobatog
Copy link
Member Author

@witlessbird 's fix showed an speed improvement of 5-10%, so I updated the pull request

@dmitri-d
Copy link
Member

@elobato Thanks for spending your time on profiling this!

@GregSutcliffe
Copy link
Member

@elobato great stuff, thanks! @skottler, tests pass, merge at will :)

@skottler
Copy link

@elobato can you please squash the commits?

Witlessbird's fix to reduce database lookups and do Ruby hash lookups instead
@dLobatog
Copy link
Member Author

@skottler done!

@skottler
Copy link

Thanks @elobato!

Committed in 991cd8a. I'm going to leave this open for @domcleal to cherry-pick into 1.2.

@domcleal domcleal closed this May 20, 2013
next if db_facts.include?(fact_name.name)
value = facts[fact_name.name]
facts.each do |name, value|
next if db_facts.include?(name)
Copy link
Member

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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants