Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Avoid redundant calls to filepath.Clean#2652

Merged
aaron-prindle merged 1 commit intoGoogleContainerTools:mainfrom
aaronlehmann:filepath-clean-pr
Aug 1, 2023
Merged

Avoid redundant calls to filepath.Clean#2652
aaron-prindle merged 1 commit intoGoogleContainerTools:mainfrom
aaronlehmann:filepath-clean-pr

Conversation

@aaronlehmann
Copy link
Copy Markdown
Contributor

@aaronlehmann aaronlehmann commented Jul 31, 2023

filepath.Clean shows up in profiles as a hot spot, and there seem to be many redundant calls, particularly in ignorelist handling. We can avoid these redundant calls by pre-cleaning entries in the ignore list, and providing fast paths when we know we're already dealing with a cleaned candidate path.

Before:

 580ms  3.03% 72.35%      590ms  3.08%  path/filepath.(*lazybuf).append (inline)
 390ms  2.03% 74.39%      990ms  5.16%  path/filepath.Clean

After:

 0.13s  0.69% 84.01%      0.17s  0.91%  path/filepath.(*lazybuf).append (inline)
 0.13s  0.69% 84.70%      0.31s  1.65%  path/filepath.Clean

filepath.Clean shows up in profiles as a hot spot, and there seem to be
many redundant calls, particularly in ignorelist handling. We can avoid
these redundant calls by pre-cleaning entries in the ignore list, and
providing fast paths when we know we're already dealing with a cleaned
candidate path.

Before:

     580ms  3.03% 72.35%      590ms  3.08%  path/filepath.(*lazybuf).append (inline)
     390ms  2.03% 74.39%      990ms  5.16%  path/filepath.Clean

After:

     0.13s  0.69% 84.01%      0.17s  0.91%  path/filepath.(*lazybuf).append (inline)
     0.13s  0.69% 84.70%      0.31s  1.65%  path/filepath.Clean
Copy link
Copy Markdown
Collaborator

@aaron-prindle aaron-prindle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for this @aaronlehmann! LGTM

@aaron-prindle aaron-prindle merged commit 32ce1bf into GoogleContainerTools:main Aug 1, 2023
aaron-prindle added a commit to aaron-prindle/kaniko that referenced this pull request Aug 7, 2023
@aaron-prindle aaron-prindle added this to the v1.14.0 milestone Aug 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants