Skip to content

Use a single FacterDB.get_facts call - #158

Draft
ekohl wants to merge 2 commits into
voxpupuli:masterfrom
ekohl:single-get-facts-call
Draft

Use a single FacterDB.get_facts call#158
ekohl wants to merge 2 commits into
voxpupuli:masterfrom
ekohl:single-get-facts-call

Conversation

@ekohl

@ekohl ekohl commented Jul 20, 2023

Copy link
Copy Markdown
Member

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

codecov Bot commented Jul 20, 2023

Copy link
Copy Markdown

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

ekohl commented Jul 21, 2023

Copy link
Copy Markdown
Member Author

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.
@ekohl
ekohl force-pushed the single-get-facts-call branch from f7a1e25 to 70f4c33 Compare September 13, 2024 14:00
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