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

Use a single FacterDB.get_facts call #158

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ekohl
Copy link
Member

@ekohl ekohl commented Jul 20, 2023

The major cost is FacterDB.get_facts. Instead of calling it once for every OS version this instead calls it once with a complex filter. It then uses JGrep to simulate another smaller DB and futher query that.

In my non-scientific test this reduces the load time of puppet-example from 3.5 to 2.5 seconds.

This is VERY hacky and duplicates logic from FacterDB which it really should not do. There is also overhead of serializing to JSON, loading that back and doing symbol conversion. It may be possible to use JGrep.filter_json, but that probably fails on the symbol keys. If FacterDB.get_facts could return string keys all of that would be redundant.

@codecov
Copy link

codecov bot commented Jul 20, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -1.06 ⚠️

Comparison is base (5c92f4f) 95.20% compared to head (2314825) 94.15%.

❗ Current head 2314825 differs from pull request most recent head f7a1e25. Consider uploading reports for the commit f7a1e25 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #158      +/-   ##
==========================================
- Coverage   95.20%   94.15%   -1.06%     
==========================================
  Files           2        2              
  Lines         167      171       +4     
==========================================
+ Hits          159      161       +2     
- Misses          8       10       +2     
Impacted Files Coverage Δ
lib/rspec-puppet-facts.rb 96.98% <100.00%> (-1.17%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ekohl
Copy link
Member Author

ekohl commented Jul 21, 2023

Updated to use voxpupuli/facterdb#282.

The major cost is FacterDB.get_facts. Instead of calling it once for
every OS version this instead calls it once with a complex filter. It
then uses JGrep to simulate another smaller DB and futher query that.

In my non-scientific test this reduces the load time of puppet-example
from 3.5 to 2.5 seconds.
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 this pull request may close these issues.

1 participant