-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Vagrant CLI on Windows is very slow #11853
Comments
Same here; running Environment: Windows 10 1909 (18363.1139), 16GB RAM, Core i7, Vagrant 2.2.10, VirtualBox 6.1.8.
Tried adding C:\HashiCorp to the virus scan exclusion list, but no difference. |
This may be due to powershell compiling assemblies on startup which is causing the delay. Precompiling them can resolve the issue if it is indeed the root cause: https://serverfault.com/questions/761301/calling-powershell-exe-is-extremely-slow/761473#761473 |
@chrisroberts Thanks for the tip, but Vagrant is also slow using normal cmd.exe.
Not as accurate as I'm thinking it's a problem running the embedded ruby environment on Windows that's slow... |
Using cmd it takes 19 seconds on my notebook:
|
@yasny / @keilma It is not an issue with running Vagrant under powershell or cmd. Vagrant executes powershell commands on Windows to determine things like available providers and user permissions. If powershell itself is slow to start, then it will result in Vagrant being slow as well. This is where precompiling the assemblies can help. |
Hi @chrisroberts, normal powershell operations or other scripts are working normal on my system. In the thread on serverfault it takes ~7 seconds for a write-host, on my host it's done in miliseconds:
|
@chrisroberts Thanks for your input. Do you have any other suggestions? It's really difficult to work with Vagrant on Windows :( |
Difficult? Not usable here. |
I got 28 sec for "vagarant version". Edit: that information above is for my work machine. For my much less powerful home PC, it's approximately 3 times faster. Maybe there is some big-brother s/w in between |
I also find the slow vagrant cli quit annoying, especially I used SysInternals Process Monitor to record the events, filtering on vagrant.exe, ruby.exe, and powershell.exe. It shows that majority of the execution time is the ruby process. I think the root cause is that Ruby, at least on Windows, is very slow. The PowerShell processes take a lot less time than ruby. The vagrant.exe wrapper takes very small time. |
Please remove the needs-repo and waiting-reply labels as clear repo steps have been provided and powershell has been eliminated. |
We experience same delay problems. We have stopped using any vagrant commands which have alternatives on windows. I.E. vagrant ssh we use ssh directly on windows to connect to VM. The biggest issue for us is rsync. We need to send files often from Windows Vagrant Host to VM. Running vagrant rsync almost every 5 minutes drives us crazy. |
@skalinkin Just use |
I've just experienced this and found a solution here: https://www.gitmemory.com/issue/hashicorp/vagrant/10521/492835941 I'm not 100% certain what these functions are required for, but as two of them are for Hyper-V which I'm not using on this machine I'm assuming it should be fairly safe to disable them
|
2 seconds to display help is still 2s too long. |
cmd /v:on /c "echo !TIME! & vagrant help > nul & echo !TIME!" That's ridiculous, unusable... I can't disable powershell/hyperv etc. as I'm using them (hyper-v). |
I applied @vuzzlevuzz's patch but it still takes over 10 seconds to "vagrant ssh" to a ubuntu vm from CMD (not PowerShell). |
Not just on Windows
|
With |
After nearly one year there is still no remedy in sight? PS> Measure-Command { vg -h } Days : 0 PS> vg -v |
While it is convenient (and portable way) to use PowerShell to source Windows host info it is a poor choice. Most of that info could be extracted by reading registry / invoking other utilities. I was surprised when my report was closed #10521 Basically Vagrant is not usable on Windows. Small number of voices means the product is no longer popular on Windows. |
@chrisroberts Could you please remove the needs-repo and waiting-reply labels, repo steps are Powershell was eliminated in #11853 (comment) |
Any news on that matter?
and it's the same in WSL2 (Ubuntu 20.04 LTS) :
|
Probably you configured passing control from WSL2 to Windows? WSL's For that reason I gave up using Vagrant in WSL 1 (and patched Windows Vagrant commending some stupidly slow Hyper-virt checks, I'm with VBox xD). |
Still too slow in 2.3.1 - even with gavenkoa "patch" - wish doesnt seems to change anything in version 2.3.x anyway
|
Hashicorp probably doesn't care about Vagrant anymore... I've really wanted to try and use it, but those huge execution times ruin it |
Tried this with VMWare as provider but still slow, any idea what should be modify for WMare provider? |
Measure-Command {vagrant help} Days : 0 It's crasy, windows 10. 4c 32g |
In case it's helpful, here are my timings: MacBook Pro 2015:
Mac Mini 2018:
Dell Latitude 5410
So, I conclude that:
|
@simplytech You can install
|
It is unacceptable. Vagrant 2.3.2 and Win 11. It is very disappointing. It works great under Linux. |
Any update on this? |
Did you had to restart something than? Is not working for me. Windows 11
|
I used VirtualBox provider, not HyperV. So the code should be updated for The workaround is about replacing costly |
Hi there, We're using Vagrant 2.3.4 on Windows 11 and it's still extremely slow, see the attached screenshot. Unfortunately gavenkoa's patch did not work for us. Any suggestions? |
Will there ever be a fix? |
Vagrant is by a wide margin the best option for running VMs on Windows, including Docker containers via boot2docker , which I find much better than the native Docker implementation. However this is a pretty major annoyance that the It looks like it sleeps for 2030ms and then does the work, and the actual work takes just milliseconds. The other commenters having even larger delays can be chalked up to the fact that Windows peaked on 7 and has been a dumpster fire of hot garbage rolling downhill ever since. Unlike the later iterations, 7 doesn't f*ck with your access times, so the 2 second delay is definitely something on Vagrant's end. e: to help in narrowing it down, the proposed solution of overriding these functions: def windows_admin?
return true
end
def windows_hyperv_admin?
return false
end
def windows_hyperv_enabled?
return false
end made zero difference, i.e. the delta execution speed was ~100 microseconds, having an insignificant impact. |
I could confirm it: Ruby VM startup time is about 3-4s on my PC (due to Sophos antivirus intercepting read of files). @anzz1 You could reveal finer details with
It shows lots of activity |
Thanks for this, very useful. Indeed , if I replace Im leaning towards Ruby simply being slow / unoptimized as a language, that it's not necessarily caused by any bug. However, there is definitely some room for optimization in Vagrant's side. Looking at the log, I am loading every single host platform/guest platform/provisioner/provider/protocol plugin under the sun when running any command. Shouldn't those be loaded as-needed instead? I don't necessarily need to load a plugin for |
varant on windows 10 is a nightmare.
@hashicorp-cloud |
FTFY. When something that takes 2 seconds to run in Windows 7 (which is still too much), takes 15 seconds on Windows 10, there is not much the developers of Ruby, of Vagrant, of Mars Curiosity Rover, or anyone can do. And Windows 11 is even worse. You could try asking Microsoft to scrap the fail that is current-day Windows, and keep supporting W7 indefinitely to have a fast and stable OS. Good luck with that, though. |
Nonsense, it takes 157 millis to create two random files, 1MB each, and then run a diff between the two on Windows 11… There shouldn't be any reason whatsoever for basic vagrant commands to take full seconds.
|
There is so much wrong in your methodology of testing I/O perf under Windows that I do not even know where to start. |
The entire point is that even with I/O the operation takes 1/50 of the time it takes to run a simple Vagrant command on the same system... You can run the same without I/O, see if it takes longer 😉 |
And my point is that when you run the same command on Windows 7, it takes 2 seconds instead of 15. I don't understand what is the argument you are trying to make. It seems that you do not either. Yes, sure, there are some words, but they make very little sense. What part is exactly "nonsense" according to you, the expert? |
For me any cli command takes around a minute, running with --debug, shows that it's stuck at
Sure enough, if I run the locale.exe -a separately as well, it takes a long while, any ideas to fix it? |
I recollect (but can’t test right now) you can just rename/remove locale.exe and it will skip and still work. |
@rgreer4 Yup, that just worked like a charm, deleting locale.exe reduced the time taken from 1minute-ish to 4-7 seconds! I'd say, still sluggish for a cli, but very much usable for me, thanks! |
deleting locale.exe sped up my commands. no -- I didn't measure, but I can run commands without getting bored. |
I've noticed this same issue on Windows 11 Pro (23H2) but interestingly when I switched to dual booting with Fedora 40 (KDE Plasma version on Linux 6.8.9-300.fc40.x86_64) I noticed significantly faster vagrant CLI speeds. Here's an example with
Under Linux things are about 3x faster for "basic" CLI commands (status, box list, version, help, etc - things that probably only do a handful of checks). This gets more interesting when I look at bringing up a Rocky Linux VM guest with Vagrant. I have a number of ports forwarded, 3 shared folders mounted, etc so I expect this to take some time but the difference between Windows 11 and Fedora 40 is crazy:
We're talking 24x slower on Windows vs Linux. To add additional notes, I'm using Virtualbox as the guest provider - I also noticed that mounting three shared folders took about 6 mins in Windows 11 vs about 9 seconds on Fedora. Another slow part seems to be the machine booting process. On Windows, this takes about 5 mins between boot/checking for guest additions. On Linux this is the longest step, but it still only takes 24 seconds. I've tried a few of the things in this thread to see if I can speed up Windows 11. I used the I also tried deleting |
I might have found a potential solution to my problem. It appears that on Windows 11 Pro some Hyper-V settings were enabled by default. I found that this was causing Virtualbox to enter "Snail execution mode":
(these are logs from Virtualbox which you can find by going to the Virtualbox GUI and clicking on Machine -> Show Log or hitting CTRL + L) It seems like this was the problem. After following steps listed in this Virtualbox forum post: https://forums.virtualbox.org/viewtopic.php?f=25&t=99390 I find that
This is still several times slow than Linux, but it's at least faster than before by several times. Highly recommend folks on Windows using Vagrant with Virtualbox take a look at their Hyper-V settings and disable them if possible. Seems like Snail execution mode can cause a lot of slow down with Virtualbox VMs that vagrant seems to handle, but will perform slower than necessary if the Hyper-V programs / features in Windows 11 are disabled. |
Vagrant 2.4.1 fresh installation on Windows 10 x64.
In this case Powershell is the culprit, and I already knew Powershell (any version) is very slow to start. |
Solution: |
Hello,
I was not able to find something useful to solve this issue so I will try it here.
I've a fresh installation of Vagrant (no plugins) on my host, but the response of the CLI is very very slow.
For example it takes 19 seconds to get the output of "vagrant version":
PS > Measure-Command { vagrant version }
Days : 0
Hours : 0
Minutes : 0
Seconds : 19
Milliseconds : 460
Ticks : 194606842
TotalDays : 0,000225239400462963
TotalHours : 0,00540574561111111
TotalMinutes : 0,324344736666667
TotalSeconds : 19,4606842
TotalMilliseconds : 19460,6842
Environment: Windows 10 2004 Build 19041.450 (32 GB RAM, Core i7), Vagrant 2.2.10, VirtualBox 6.1.12.
Thanks in advance.
Kind regards
Marcel
The text was updated successfully, but these errors were encountered: