使用vagrant ssh时由于git极度放慢速度

时间:2016-05-26 12:03:11

标签: git vagrant ubuntu-14.04 virtualbox windows-10

Vagrant版本

Vagrant 1.8.1

主机操作系统

这是您在本地运行的操作系统。 Windows 10预览

访客操作系统

这是您在虚拟机中运行的操作系统。 Ubuntu 1404

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  # Every Vagrant virtual environment requires a box to build off of.
  config.vm.box = "geerlingguy/ubuntu1404"

  # Create a private network, which allows host-only access to the machine using a specific IP.
  config.vm.network "public_network", ip: "192.168.33.22"

    config.vm.provider "virtualbox" do |v|
      v.memory = 2048
      v.cpus = 2
    end
  # Share an additional folder to the guest VM. The first argument is the path on the host to the actual folder.
  # The second argument is the path on the guest to mount the folder.
  config.vm.synced_folder "./", "/var/www", type: "nfs"

  # Define the bootstrap file: A (shell) script that runs after first setup of your box (= provisioning)
  config.vm.provision :shell, path: "script.sh"

 config.vm.network :forwarded_port, guest: 80, host: 4567

调试输出

如果使用任何命令,则需要花费大量时间才能完成执行。

如果按 Ctrl + Z 那么

[1]-  Stopped                 git diff --no-ext-diff --quiet --exit-code

[2]+  Stopped                 git diff-index --cached --quiet HEAD --

在此期间,CPU使用情况如下: -

Tasks: 101 total,   1 running, 100 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us, 25.0 sy,  0.0 ni, 75.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:   2048916 total,   450200 used,  1598716 free,    17852 buffers
KiB Swap:   524284 total,        0 used,   524284 free.   209176 cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 2112 vagrant   20   0   18500   3940   3076 D  61.1  0.2   0:03.62 git
 1831 vagrant   20   0  103580   4264   3208 S  30.5  0.2   0:01.74 sshd
 1874 vagrant   20   0   24824   2924   2488 R  30.5  0.1   0:04.63 top
    1 root      20   0   33624   4124   2660 S   0.0  0.2   0:03.18 init
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.01 kthreadd
    3 root      20   0       0      0      0 S   0.0  0.0   0:00.04 ksoftirqd/0
    5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:+
    7 root      20   0       0      0      0 S   0.0  0.0   0:00.93 rcu_sched

1 个答案:

答案 0 :(得分:0)

您可以尝试此命令

git config core.preloadindex true