Jira (PUP-9508) Puppet::Util::Warnings#maybe_log potentially very slow

8 views
Skip to first unread message

Jacob Helwig (JIRA)

unread,
Feb 21, 2019, 5:20:03 PM2/21/19
to puppe...@googlegroups.com
Jacob Helwig created an issue
 
Puppet / Improvement PUP-9508
Puppet::Util::Warnings#maybe_log potentially very slow
Issue Type: Improvement Improvement
Assignee: Unassigned
Created: 2019/02/21 2:19 PM
Priority: Normal Normal
Reporter: Jacob Helwig

https://github.com/puppetlabs/puppet/blob/293b87447ff955bb4c866b5b0eda3a23e5901ff2/lib/puppet/util/warnings.rb#L23-L30

Puppet::Util::Warnings#maybe_log stores the list of messages that it has logged from each class in an array, and uses Array#include? to see whether the message has already been seen. This has the potential to slow down significantly as the number of messages logged from a specific class increases.

We should probably look into storing the set of previously seen messages in something with a lookup time closer to O(1) than the current O(N) scan through the array.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Henrik Lindberg (JIRA)

unread,
Feb 22, 2019, 6:26:03 AM2/22/19
to puppe...@googlegroups.com
Henrik Lindberg commented on Improvement PUP-9508
 
Re: Puppet::Util::Warnings#maybe_log potentially very slow

How about just replacing the Array of messages with an instance of Set?

Jacob Helwig (JIRA)

unread,
Feb 22, 2019, 12:20:03 PM2/22/19
to puppe...@googlegroups.com
Jacob Helwig commented on Improvement PUP-9508

If checking whether something is already a member of a Set in Ruby is closer to O(1) than the O(N) that we have now, that certainly meets the criteria. I haven't dug into the implementation of Set in Ruby yet to see. This is mostly something the Coremunity team noticed while reviewing nearby code, and we opened the ticket to make sure that there was a reminder that there was something to follow up on. There wasn't a specific implementation in mind other than "not the one we're using now" when opening this ticket.

Jorie Tappa (JIRA)

unread,
Feb 25, 2019, 12:55:03 PM2/25/19
to puppe...@googlegroups.com

Jorie Tappa (JIRA)

unread,
Feb 25, 2019, 12:55:04 PM2/25/19
to puppe...@googlegroups.com
Jorie Tappa updated an issue
Change By: Jorie Tappa
Sprint: Coremunity Hopper

Josh Cooper (JIRA)

unread,
Mar 28, 2019, 11:36:04 PM3/28/19
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sprint: Coremunity Hopper Grooming

Josh Cooper (JIRA)

unread,
Sep 17, 2019, 11:28:05 PM9/17/19
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sprint: Coremunity Grooming

Josh Cooper (Jira)

unread,
Oct 19, 2022, 11:08:01 PM10/19/22
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Labels: Easy
This message was sent by Atlassian Jira (v8.20.11#820011-sha1:0629dd8)
Atlassian logo

Josh Cooper (Jira)

unread,
May 17, 2023, 2:11:02 PM5/17/23
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Labels: Easy performance

Josh Cooper (Jira)

unread,
May 17, 2023, 2:11:02 PM5/17/23
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Team: Coremunity Phoenix

Josh Cooper (Jira)

unread,
May 17, 2023, 2:11:03 PM5/17/23
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages