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

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!

Leave a Reply

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



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Why ads?

I'm glad you made it to this blogpost. I hope it helps solve your problem. So why then do I show ads on the site? Writing content, testing it and making sure the layout isn't totally b0rked takes time. A lot of time. The ads are a way to pay back a small portion of that time.

And as you know running a site costs (a bit of) money: the domain name, webhosting, time spent writing and updating content, ... So if you like the content of this blog, consider disabling your AdBlocker for this domain. Thanks!

Recent posts

Looking for help?

Tired of fixing all these tech-problems yourself? We've got an excellent team at Nucleus, a top-class Belgian hosting provider, that can help you.

Discover our Managed Hosting, where skilled engineers manage your servers and keep them up-to-date, so you can focus on your core business. We use a variety of Configuration Management Systems such as Puppet to make sure every config is reviewed, unit-tested and guaranteed to be working.

Want to get in touch? Find me as @mattiasgeniar on Twitter or via the contact-page on this blog.