RiotGames/berkshelf — pull request #829 by kainosnoema (2013-08-31 23:58:01+00:00)
Title: Avoid reloading each cached cookbook on every resolve

For most actions, this fix turns an O(n^2) situation into essentially O(n). Because we're not needing to reload a cookbook every time, Celluloid also becomes unnecessary and we can remove that dependency.

Given a Berksfile containing all 107 cookbooks from the [original opscode repo](https://github.com/opscode/cookbooks/tree/0.10.rc.0) and a warmup run to cache the cookbooks locally in `~/.berksfile`, the difference is striking:

Before fix (v2.0.9):

```sh
~/Code/berks-perf-test $ berks install
# ...
~/Code/berks-perf-test $ time berks install
# ...
real 0m22.425s
user 0m19.823s
sys 0m3.673s
```

After fix (fe544be):

```sh
~/Code/berks-perf-test $ berks install
# ...
~/Code/berks-perf-test $ time berks install
# ...
real 0m3.527s
user 0m2.892s
sys 0m0.584s
```

For our internal cookbooks, we're seeing `berks install` times drop from single-digit seconds (which add up) to effectively zero. This makes a huge difference for us in day-to-day development.

I'd love to see this get into a 2.0.x release and over to the `vagrant-berkshelf` plugin as soon as possible. That said, I believe it still applies cleanly to the master branch as well. I've had limited success getting all the specs to pass there so some help from a core committer on that would be great.