Jira (PUP-11312) Puppet creates excessive numbers of Pathname instances

15 views
Skip to first unread message

Josh Cooper (Jira)

unread,
Oct 1, 2021, 12:43:02 PM10/1/21
to puppe...@googlegroups.com
Josh Cooper created an issue
 
Puppet / Bug PUP-11312
Puppet creates excessive numbers of Pathname instances
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2021/10/01 9:42 AM
Priority: Normal Normal
Reporter: Josh Cooper

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.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Ciprian Badescu (Jira)

unread,
Oct 4, 2021, 10:19:02 AM10/4/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Oct 4, 2021, 6:59:03 PM10/4/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Oct 11, 2021, 4:33:01 PM10/11/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sprint: Coremunity Kanban

Josh Cooper (Jira)

unread,
Nov 18, 2021, 10:59:01 AM11/18/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Fix Version/s: PUP 7.13.0

Josh Cooper (Jira)

unread,
Nov 18, 2021, 10:59:02 AM11/18/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Release Notes: Bug Fix
Release Notes Summary: Reduces the number of Pathname allocations when parsing puppet manifests.

Josh Cooper (Jira)

unread,
Nov 18, 2021, 11:00:03 AM11/18/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Nov 19, 2021, 11:31:02 AM11/19/21
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages