puppetlabs / puppetlabs/puppetlabs-stdlib
slow custom facts
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 349
- Forks
- 573
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 1
Description
The package_provider.rb facts can be optimized simply by moving the require lines into the setcode block. This reduces stand-alone puppet runs by 0.5s on modern systems. (On puppet-agent runs, no such savings are observed, probably because the libraries are already required by the puppet agent itself. Apparently, the facter command evaluates the outer and inner blocks in different contexts.
Interestingly, moving the corresponding lines in service_provider.rb has no measurable performance benefit.
Current version
# bench 3 "facter -p >/dev/null"
Run 1
Run 2
Run 3
1665392723.165300291
1665392730.070952629
2.3018
With recommended change
# bench 3 "facter -p >/dev/null"
Run 1
Run 2
Run 3
1665392652.861524963
1665392661.744424272
2.9609
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect lib/facter/package_provider.rb, especially the require lines linked in the issue and the setcode block. Run the stated bench 3 "facter -p >/dev/null" comparison, move only the package-provider requires as described, and confirm the standalone facter run improves without changing service_provider.rb.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- performance
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100