Open
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