Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookbook loading is inefficient with large ignored directories #6323

Closed
acoulton opened this issue Aug 11, 2017 · 2 comments
Closed

Cookbook loading is inefficient with large ignored directories #6323

acoulton opened this issue Aug 11, 2017 · 2 comments
Labels
Aspect: Performance Works without negatively affecting the system running it.

Comments

@acoulton
Copy link

Description

The CookbookVersionLoader recurses into every directory and loads a full list of files before iterating back over to remove any that match the chefignore.

This causes very slow cookbook loading when there are entirely-ignored directories with large numbers of files. For example, the presence of build-time gems with a vendors/* ignore pattern produces very slow chefspec performance.

It would be better if directories and files were tested against the ignore during recursion, so that the vendors directory could be skipped outright if it matches a pattern that excludes the whole directory. Note that fixing this won't take effect until #2994 is also fixed, as at present cookbook-level chefignores are completely ignored by the cookbook loader.

Chef Version

Verified in Chef 12.21.1 and 13.2.20

Platform Version

Ubuntu 14.04

Replication Case

I have created a self-executing replication case in this gist - download to a path with at least one empty parent directory to avoid chef attempting to load siblings as cookbooks and execute.

  • Create a simple cookbook with chefspec setup and a single empty recipe
  • Create a chefignore containing vendor/* in the cookbook root directory
  • Create a minimal spec with two specs, each just triggering converge on the empty recipe
  • Run chefspec and observe the runtime is very short
  • Populate a large number (10k or so) of recursive files / directories into {cookbook}/vendor equivalent to running bundle install --deployment with a chef / chefspec gemfile
  • Run chefspec and observe that each spec now takes multiple seconds to run

Output

From my replication case - observe that once vendor is present the run is around 180 times slower at 11.6 rather than 0.06 seconds. The presence of a chefignore has no effect.

Installing gems
With no local vendors
..

Finished in 0.06462 seconds (files took 0.96274 seconds to load)
2 examples, 0 failures


real    0m1.307s
user    0m1.104s
sys     0m0.163s

With local vendors and no chefignore - expected to be slow
..

Finished in 11.59 seconds (files took 0.93044 seconds to load)
2 examples, 0 failures


real    0m12.797s
user    0m11.916s
sys     0m0.710s

With local vendors chefignored - should be faster
..

Finished in 11.58 seconds (files took 0.98431 seconds to load)
2 examples, 0 failures


real    0m12.841s
user    0m12.017s
sys     0m0.598s
@lamont-granquist
Copy link
Contributor

#7794 and #7820 were some major cleanup done recently for Chef-15.

@lamont-granquist
Copy link
Contributor

looks like this is still unfixed after the cleanup

@tas50 tas50 added the Aspect: Performance Works without negatively affecting the system running it. label May 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Aspect: Performance Works without negatively affecting the system running it.
Projects
None yet
Development

No branches or pull requests

4 participants