Puppet performance troubleshooting: using the built-in profiler in standalone puppet apply

Mattias Geniar, Tuesday, December 24, 2013

Previously, it was only possible to do Profiling of a Puppet run with the client/server model, where you need a puppet master running. The master would compile the catalog and could provide debug/profiling information. However, if you're testing Puppet manifests/modules using a typical Vagrant setup, you most-likely don't have a puppet master. And it would be cool to have performance metrics of catalog compilation even on standalone puppet runs.

Enter Puppet 3.4.

Because of this pull request that was merged in 3.4, we can now use profiling with standalone 'puppet apply' environments. So especially useful in Vagrant-style developing.

How does this work? Add the --debug, --profile and --logdest to the Puppet Apply runs.

A normal run:

$ puppet apply

A run with debugging and profile information:

$ puppet apply --profile --debug --logdest=/tmp/file_to_log_profiling_info_to.log

And voila: you have all the performance metrics you need in your logdest-file. To find all your performance metrics, search for PROFILE in your logfile.

$ grep 'PROFILE' /tmp/file_to_log_profiling_info_to.log

Output can be similar to this, with all the timings of the catalog compilation.

$ grep 'PROFILE' /tmp/file_to_log_profiling_info_to.log
Puppet (debug): PROFILE [apply] 1 Setup server facts for compiling: took 0.0005 seconds
Puppet (debug): PROFILE [apply] 2.4.50 Called include: took 0.0224 seconds
Puppet (debug): PROFILE [apply] 2.4.51 Called include: took 0.0327 seconds
Puppet (debug): PROFILE [apply] Called template: took 0.0994 seconds
Puppet (debug): PROFILE [apply] Evaluated resource Selinux::Module[zabbix-agent]: took 0.0111 seconds
Puppet (debug): PROFILE [apply] Evaluated resource Motd::Register_module[zabbix_agent]: took 0.0244 seconds
Puppet (debug): PROFILE [apply] Evaluated resource Motd::Register_module[ntp]: took 0.0228 seconds
Puppet (debug): PROFILE [apply] Evaluated resource Nginx::Proxy[site.tld]: took 0.0330 seconds
Puppet (debug): PROFILE [apply] 2 Compiled catalog for host.tld in environment production: took 15.9748 seconds
Puppet (debug): PROFILE [apply] 3 Filtered result for catalog host.tld: took 1.2557 seconds

Thanks Puppetlabs!

Hi! My name is Mattias Geniar. I'm a Support Manager at Nucleus Hosting in Belgium, a general web geek, public speaker and podcaster. Currently working on DNS Spy. Follow me on Twitter as @mattiasgeniar.

I respect your privacy and you won't get spam. Ever.
Just a weekly newsletter about Linux and open source.

SysCast podcast

In the SysCast podcast I talk about Linux & open source projects, interview sysadmins or developers and discuss web-related technologies. A show by and for geeks!

cron.weekly newsletter

A weekly newsletter - delivered every Sunday - for Linux sysadmins and open source users. It helps keeps you informed about open source projects, Linux guides & tutorials and the latest news.

Share this post

Did you like this post? Will you help me share it on social media? Thanks!


R.I.Pienaar Saturday, December 26, 2015 at 23:34

I did a talk about this earlier this year. Check it out. https://www.slideshare.net/mobile/ripienaar/puppet-performance-profiling-cm-camp-2015


Leave a Reply

Your email address will not be published. Required fields are marked *