Git减慢Emacs死亡 - 如何解决这个? [英] Git slows down Emacs to Death - How to Fix this?
问题描述
打开文件(通过键入 Ctrl-x f
,AKA 查找文件
)或键入<$在 Dired
模式下,在该文件上的c $ c> f )在工作目录中有一个 .git
Opening a file (either by typing Ctrl-x f
, AKA Find File
) or by typing f
on that file in Dired
mode), is painfully slow in working directories that have a .git
subdirectory.
即使最简单的文件(50行,大多数是注释)也可能需要 8秒才能打开。
Even the simplest file (50 lines with mostly comments) could take up to 8 seconds to open.
同一文件在不由Git管理的不同目录中,立即在jiffy中打开。
The same file, in a different directory not managed by Git, opens in a jiffy, immediately.
为什么会发生这种情况,如何解决此问题 没有 禁用vc模式? (因为我使用Emacs的主要原因之一是它的 Mx ediff-revision
)
Why is this happening and how can I fix this without disabling vc-mode? (since one of the main reasons I use Emacs is its M-x ediff-revision
)
UPDATE 1 :感谢@ sanityinc的答案下面,我运行ELP分析,这是我收到的(对于一个非常小的文件,69行,其中59是纯粹的意见):
UPDATE 1: Thanks to @sanityinc's answer below, I ran ELP Profiling and this is what I received (for a very small file, 69 lines, 59 of which are plain comments):
Function Name Call Count Elapsed Time Average Time
------------- ---------- ------------ ------------
vc-call-backend 11 23.023 2.093
vc-find-file-hook 1 8.757 8.757
vc-mode-line 1 7.812 7.812
vc-default-mode-line-string 1 7.345 7.345
vc-state-refresh 1 6.921 6.921
vc-state 1 6.921 6.921
vc-default-state-heuristic 1 6.921 6.921
vc-registered 1 0.945 0.945
vc-backend 1 0.945 0.945
vc-git-registered 1 0.912 0.912
vc-working-revision 1 0.4240000000 0.4240000000
vc-find-root 4 0.0990000000 0.0247500000
vconcat 623 0.0220000000 3.53...e-005
vc-bzr-registered 1 0.016 0.016
vc-check-master-templates 2 0.014 0.007
vc-default-registered 2 0.014 0.007
vc-rcs-registered 1 0.008 0.008
vc-sccs-registered 1 0.006 0.006
vc-svn-registered 1 0.002 0.002
vc-cvs-registered 1 0.001 0.001
vc-sccs-search-project-dir 1 0.0 0.0
vc-kill-buffer-hook 6 0.0 0.0
vc-find-backend-function 11 0.0 0.0
vc-default-find-file-hook 1 0.0 0.0
vc-possible-master 6 0.0 0.0
vc-file-clearprops 1 0.0 0.0
vc-file-setprop 3 0.0 0.0
vc-file-getprop 5 0.0 0.0
vc-make-backend-sym 15 0.0 0.0
这是很好的信息,但我不是Emacs / elisp专家,那么我该如何从这里走?
This is great information but I am not an Emacs/elisp expert, so how where do I go from here?
UPDATE 2:将此问题放在后面的燃烧器上了一段时间后,我遇到了这个伟大的博客文章: Cygwin慢启动:罪魁祸首发现了!这本质上建议在后台启动bash完成。我快速实施它并重新运行ELP分析测试:
UPDATE 2: After putting this problem on the back burner for a while, I came across this great blog post: Cygwin slow start up: the culprit discovered! which essentially suggests starting bash completion in the background. I quickly implemented it and re-ran the ELP profiling test:
vc-call-backend 11 14.489 1.317
vc-find-file-hook 1 5.488 5.488
vc-mode-line 1 5.118 5.118
vc-default-mode-line-string 1 4.719 4.719
vc-state-refresh 1 4.282 4.282
vc-state 1 4.282 4.282
vc-default-state-heuristic 1 4.282 4.282
vc-working-revision 1 0.437 0.437
vc-registered 1 0.37 0.37
vc-backend 1 0.37 0.37
vc-git-registered 1 0.34 0.34
vc-find-root 4 0.088 0.022
vc-bzr-registered 1 0.015 0.015
vc-check-master-templates 2 0.013 0.0065
vc-default-registered 2 0.013 0.0065
vc-rcs-registered 1 0.007 0.007
vc-sccs-registered 1 0.006 0.006
vc-cvs-registered 1 0.001 0.001
vconcat 623 0.001 1.60...e-006
vc-svn-registered 1 0.001 0.001
vc-sccs-search-project-dir 1 0.0 0.0
vc-kill-buffer-hook 6 0.0 0.0
vc-find-backend-function 11 0.0 0.0
vc-default-find-file-hook 1 0.0 0.0
vc-possible-master 6 0.0 0.0
vc-file-clearprops 1 0.0 0.0
vc-file-setprop 3 0.0 0.0
vc-file-getprop 5 0.0 0.0
vc-make-backend-sym 15 0.0 0.0
很高兴看到 vc-call-backend
从23秒下降到14秒,但这仍然是不可接受的(发现CVS控制的文件需要不到一秒的时间!)
It's great to see vc-call-backend
going down from 23 seconds to 14 seconds, but this is still unacceptable (finding a CVS-controlled file takes less than a split-second!).
UPDATE 3:无法解决这个谜,我试过升级到最新的cygwin(1.7.9-1)的运气。
UPDATE 3: Unable to solve the mystery, I tried my luck by upgrading to the latest cygwin (1.7.9-1). That didn't help.
所以,我决定尝试移动沙盒(以及它的 .git
子目录)从Samba共享到本地存储( C:\Users\WinWin\Documents
)。然后我重新运行ELP分析测试:
So, I decided to try moving the sandbox (along with its .git
subdirectory) from the Samba share to local storage (C:\Users\WinWin\Documents
). I then re-ran the ELP profiling test:
vc-call-backend 11 2.082 0.1892727272
vc-find-file-hook 1 0.897 0.897
vc-git--call 7 0.8929999999 0.1275714285
vc-git-mode-line-string 1 0.78 0.78
vc-mode-line 1 0.78 0.78
vc-default-mode-line-string 1 0.655 0.655
vc-git--out-ok 5 0.6519999999 0.1304
vc-git-state 1 0.53 0.53
vc-state-refresh 1 0.53 0.53
vc-state 1 0.53 0.53
vc-default-state-heuristic 1 0.53 0.53
vc-git-working-revision 2 0.25 0.125
vc-git-registered 2 0.2239999999 0.1119999999
vc-git--run-command-string 1 0.18 0.18
vc-working-revision 1 0.125 0.125
vc-registered 1 0.1169999999 0.1169999999
vc-backend 2 0.1169999999 0.0584999999
vc-git--empty-db-p 1 0.11 0.11
vc-find-root 3 0.003 0.001
vc-git-root 2 0.002 0.001
vc-check-master-templates 2 0.001 0.0005
vc-sccs-registered 1 0.001 0.001
vc-default-registered 2 0.001 0.0005
vc-bzr-registered 1 0.001 0.001
vc-rcs-registered 1 0.0 0.0
vc-sccs-search-project-dir 1 0.0 0.0
vc-kill-buffer-hook 5 0.0 0.0
vc-default-find-file-hook 1 0.0 0.0
vc-possible-master 6 0.0 0.0
vc-cvs-registered 1 0.0 0.0
vc-file-clearprops 1 0.0 0.0
vc-file-setprop 3 0.0 0.0
vc-file-getprop 5 0.0 0.0
vc-svn-registered 1 0.0 0.0
vc-make-backend-sym 2 0.0 0.0
哇!这将 vc-call-backend
从14秒降低到2秒。这很棒,但不是很好,因为使用Emacs / CVS ,我可以在小于35ms 中访问沙箱最初所在的同一个Samba共享上的文件:
Wow! That lowered vc-call-backend
from 14 seconds to 2 seconds. This is great but not wonderful, because with Emacs/CVS I am able to visit a file in less than 35ms -- on the same Samba share where the sandbox originally resides:
vc-call-backend 5 0.031 0.0062
vc-find-file-hook 1 0.031 0.031
vc-registered 1 0.031 0.031
vc-backend 1 0.031 0.031
vc-rcs-registered 1 0.016 0.016
vc-check-master-templates 1 0.016 0.016
vc-default-registered 1 0.016 0.016
vc-insert-file 1 0.015 0.015
vc-cvs-get-entries 1 0.015 0.015
vc-cvs-registered 1 0.015 0.015
vc-cvs-state-heuristic 1 0.0 0.0
vc-cvs-parse-sticky-tag 1 0.0 0.0
vc-kill-buffer-hook 1 0.0 0.0
vc-find-backend-function 1 0.0 0.0
vc-cvs-parse-entry 1 0.0 0.0
vc-mode-line 1 0.0 0.0
vc-default-find-file-hook 1 0.0 0.0
vc-possible-master 3 0.0 0.0
vc-cvs-mode-line-string 1 0.0 0.0
vc-default-mode-line-string 1 0.0 0.0
vc-state-refresh 1 0.0 0.0
vc-working-revision 1 0.0 0.0
vc-state 1 0.0 0.0
vc-file-clearprops 1 0.0 0.0
vc-file-setprop 5 0.0 0.0
vc-file-getprop 7 0.0 0.0
vc-make-backend-sym 2 0.0 0.0
提出了两个问题:
- git + cygwin的组合对于
网络速度如此敏感? - 如何使git下降到小于50ms?毕竟,它是通过
快速版本控制系统
- What in the combination of git+cygwin makes it so sensitive to network speed?
- How can I make git go down to less than 50ms? After all, it is call "the fast version control system"
使用msysgit 1.7.8时更新:
vc-call-backend 11 0.626 0.0569090909
vc-find-file-hook 1 0.281 0.281
vc-mode-line 1 0.2189999999 0.2189999999
vc-default-mode-line-string 1 0.1879999999 0.1879999999
vc-state-refresh 1 0.157 0.157
vc-state 1 0.157 0.157
vc-default-state-heuristic 1 0.157 0.157
vc-registered 1 0.062 0.062
vc-backend 1 0.062 0.062
vc-git-registered 1 0.062 0.062
vc-working-revision 1 0.0310000000 0.0310000000
vc-rcs-registered 1 0.0 0.0
vc-sccs-search-project-dir 1 0.0 0.0
vc-kill-buffer-hook 6 0.0 0.0
vc-find-backend-function 11 0.0 0.0
vc-default-find-file-hook 1 0.0 0.0
vc-possible-master 6 0.0 0.0
vc-check-master-templates 2 0.0 0.0
vc-cvs-registered 1 0.0 0.0
vc-sccs-registered 1 0.0 0.0
vc-file-clearprops 1 0.0 0.0
vconcat 623 0.0 0.0
vc-default-registered 2 0.0 0.0
vc-file-setprop 3 0.0 0.0
vc-find-root 4 0.0 0.0
vc-file-getprop 5 0.0 0.0
vc-bzr-registered 1 0.0 0.0
vc-svn-registered 1 0.0 0.0
vc-make-backend-sym 15 0.0 0.0
你能区分一下吗? :)
Can you tell the difference? :)
Emacs下的Git现在速度更快,但它仍然比Emacs下的CVS慢得多。所以我不知道为什么Git被称为快速版本控制系统。它可能比CVS更好,但更快?
Git under Emacs is way faster now, but it still much much slower than CVS under Emacs. So I have no idea why Git is called the "Fast Version Control System". It may be better than CVS, but faster?
推荐答案
有一个内置的分析器叫ELP。您可以尝试 M-x elp-instrument-package
,输入vc,然后尝试查找文件。之后, Mx elp-results
将显示个人资料报告。
There's a built-in profiler called ELP. You can try something like M-x elp-instrument-package
, enter "vc", and then try finding a file. Afterwards, M-x elp-results
will show you a profile report.
(请注意,花费在非vc相关的功能,这种技术不会显示它,但你可以测试更多的软件包,如果你喜欢。)
(Note that if the time is instead being spent in non-vc-related functions, this technique will not show it, but you can instrument further packages if you like.)
这篇关于Git减慢Emacs死亡 - 如何解决这个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!