Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-5013

resource evaluation metrics are missing when not using an ENC

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 3.8.3, PUP 4.2.2
    • Component/s: None
    • Labels:
      None
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Hide
      When surfacing Puppet metrics in Puppet Server, w/o this change, a huge percentage of the metrics related to resource evaluation are never registered / tracked, because there are multiple code paths that can lead to resource evaluation during compilation, and only one of them has a profiling block around it.

      E.g. whether or not a resource gets metrics tracked may depend on whether it was introduced via NC vs site.pp, etc.

      This fix to the profiling code provides much more interesting and complete data to look at.
      Show
      When surfacing Puppet metrics in Puppet Server, w/o this change, a huge percentage of the metrics related to resource evaluation are never registered / tracked, because there are multiple code paths that can lead to resource evaluation during compilation, and only one of them has a profiling block around it. E.g. whether or not a resource gets metrics tracked may depend on whether it was introduced via NC vs site.pp, etc. This fix to the profiling code provides much more interesting and complete data to look at.

      Description

      When doing some experimental work around improving metrics in Puppet Server, I noticed that one of the more interesting metrics (about how long is spent evaluating each resource type during a catalog compilation) was not always showing up. After some poking through the code, I discovered this:

      https://github.com/puppetlabs/puppet/blob/2667053d0438d650c909158c79ce85cfaee8019a/lib/puppet/parser/compiler.rb#L385-L388

      def evaluate_definitions
          exceptwrap do
            Puppet::Util::Profiler.profile("Evaluated definitions", [:compiler, :evaluate_definitions]) do
              !unevaluated_resources.each do |resource|
                Puppet::Util::Profiler.profile("Evaluated resource #{resource}", [:compiler, :evaluate_resource, resource]) do
                  resource.evaluate
                end
              end.empty?
            end
          end
        end
      

      It turns out that this code seems to track metrics for resources that get into the catalog via some kind of classifier (PE NC or OSS ENC script), but if you use node blocks in the site.pp file directly, then the resources all get evaluated non-lazily sometime earlier in the compilation:

      https://github.com/puppetlabs/puppet/blob/2667053d0438d650c909158c79ce85cfaee8019a/lib/puppet/parser/compiler.rb#L226-L237

      And thus, you don't get any resource evaluation metrics for those resources.

      My proposal to improve this would be to move that profiling code to this spot:

      https://github.com/puppetlabs/puppet/blob/2667053d0438d650c909158c79ce85cfaee8019a/lib/puppet/parser/resource.rb#L77-L86

      where, I believe, it would happen every time a resource was evaluated, regardless of how it found its way into the catalog.

      The site.pp / node default approach seems useful for debugging, and a user might be really interested in looking at metrics for resource evaluation in that sort of use case.

      I've only looked into this for Puppet 3 so far, but if the general approach seems reasonable, I'll be happy to make sure it gets patched all the way up to Puppet 4/master (assuming that the compilation logic hasn't changed drastically in the other branches).

        Attachments

          Activity

            jsd-sla-details-panel

              People

              • Assignee:
                Unassigned
                Reporter:
                chris Chris Price
                QA Contact:
                Sean Griffin
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support