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

Puppet creates excessive numbers of Pathname instances

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • None
    • PUP 7.13.0
    • None
    • None
    • Coremunity
    • Coremunity Kanban
    • Needs Assessment
    • Bug Fix
    • Reduces the number of Pathname allocations when parsing puppet manifests.
    • Needs Assessment

    Description

      There are a few different places where we make excessive numbers of Pathname objects and resulting Strings:

      1. Most of Puppet's FileSystem methods make two copies of their string arguments. Once to create the Pathname instance (via assert_path) and another when ruby's File.xxx method calls Pathname#to_path to get the original string back.

      2. Some of Puppet's FileSystem implementation, eg Windows#replace_file, methods call "back out" to Puppet::FileSystem.replace_file, which makes another copy of Pathname instead of using the existing instance.

      3. Checker4_0#namespace_for_file(file) creates N Pathname instances (one for each module path directory in the environment) for each file argument. And then calls Pathname#cleanpath and Pathname#relative_path_from, both of which resolve each path component, e.g. "/a/b/c/d/etc" is copied to "/a/b/c/d", "/a/b/c", "/a/b", "/a", "". The mapping of file to namespace is cached in the environment, but if you have M files in an environment, then we get N * M Pathname instances and N * M * P string copies.

      4. PathNamePattern calls Pathname.each_filename to determine if any path component contains ... That ends up calling Pathname#chop_basename. We should just call String.split. It also calls Pathname#to_s multiple times during validation.

      Attachments

        Activity

          People

            josh Josh Cooper
            josh Josh Cooper
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Zendesk Support