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

Reduce calls to FacterDB #123

Open
ekohl opened this issue Nov 9, 2020 · 0 comments
Open

Reduce calls to FacterDB #123

ekohl opened this issue Nov 9, 2020 · 0 comments

Comments

@ekohl
Copy link
Member

ekohl commented Nov 9, 2020

While #122 greatly reduces the expensive calls to on_supported_os, there are still a lot of calls to FacterDB. Some hot code is here:

https://github.com/mcanevet/rspec-puppet-facts/blob/c2987a1b6cd7a9ab104aed8aa7ff61e28ce29cce/lib/rspec-puppet-facts.rb#L115-L141

Effectively for every filter (which is a tuple of OS and release) it does a call to FacterDB to get facts. If there is not an exact match for the requested Facter version it does another. Then once is has collected all this information, it does one last call to FacterDB to get all the data. Note that this last call is effectively redundant because for every iteration the facts for that filter were already retrieved.

This gives us a worst case complexity of 2n+1 where n is the number of supported OS releases.

The most obvious workaround is to record new facts for every facter release. This would reduce it down to n+1 complexity. However, that means the FacterDB itself will grow which may result in other scaling problems.

Perhaps FacterDB could expose a richer API to allow more effective queries. For example, a lambda to filter a fact. This is not supported by jgrep, but something to think about.

Another consideration is to just query without a facterversion filter and then filter out any unwanted results. Then concat those results.

This was referenced Nov 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant