Thanks to @vStone for pointing out the performance issue.
Since plugins were introduced, Vagrant has allowed plugins packaged as gems to autoload themselves by creating a file named "vagrant_init.rb" somewhere on their load path. This was intended as a way for gem authors to make installation ridiculously simple, and it worked!
However, this involved a significant impact on performance and this has been removed for a more manual approach in Vagrant 1.1. In Vagrant 1.1, users will be expected to have a ~/.vagrantrc
file which manually includes plugins they've installed via vagrant gem
. Gems can also, as always, be loaded in any Vagrantfile
as well.
For more information, read on...
The downside is that this feature required Vagrant to traverse the entire index of installed gems and load paths on every vagrant
invocation. The result is actually quite slow. With no other gems installed other than Vagrant, here is the behavior of Vagrant 1.0 on my MacBook Air running a vagrant --version
(which effectively does nothing):
vagrant master → time vagrant --version
Vagrant version 1.0.3
real 0m0.478s
user 0m0.415s
sys 0m0.060s
With a handful of gems installed (Chef, Veewee, etc):
vagrant master → time vagrant --version
Vagrant version 1.0.3
real 0m2.315s
user 0m2.255s
sys 0m0.050s
Whoa!
By simply removing all plugin auto loading, with all the gems installed as the slow version above, we get this behavior:
vagrant master → time vagrant --version
Vagrant version 1.1.0.dev
real 0m0.287s
user 0m0.252s
sys 0m0.032s
This is 40% faster than the original no-gems-installed speed of 1.0, and 88% faster than with gems installed.
So now, Vagrant will explicitly load a ~/.vagrantrc
file (overridable with the VAGRANT_RC
environmental variable), which is expected to just be Ruby code that requires in the proper gem. For example, for Veewee, this will probably look like this:
require "veewee"
And that's it.
This speeds up Vagrant quite a bit because Vagrant no longer needs to traverse the filesystem in order to "discover" autoloaded gems.
Please remember this is still an early early 1.1.0.dev build, and further optimizations (or slowdowns) can occur. But at the current stage, things look good.