stokastic
stokastic

Reputation: 996

mercurial slows emacs to death when opening/saving files

As the title says, when I open or save a file in emacs which is in an hg repo, it takes up to 7 3 (see update at the bottom) seconds to open the file. I'm on OS X on a macbook retina with solid state and plenty of power. Opening a non version controlled file seems instant.

Looking at this question which is the same for git, I determined that vc-call-backend is taking up most of the time. Here's an elp profile of a single find-file:

function                                    call count        total time    avg time
find-file                                         1           3.043015      3.043015
vc-call-backend                                   12          2.222802      0.1852335000
vc-find-file-hook                                 1           1.117738      1.117738
vc-hg-state                                       2           0.8375429999  0.4187714999
vc-mode-line                                      1           0.691795      0.691795
vc-default-mode-line-string                       1           0.691761      0.691761
vc-backend                                        1           0.42589       0.42589
vc-registered                                     1           0.425868      0.425868
vc-hg-registered                                  1           0.424229      0.424229
vc-state                                          1           0.413661      0.413661
vc-state-refresh                                  1           0.413652      0.413652
vc-default-state-heuristic                        1           0.413626      0.413626
vc-working-revision                               1           0.278064      0.278064
vc-hg-working-revision                            1           0.27795       0.27795

... (I cut everything below this line, all ran very quickly)

In this repository, running hg status from the command line takes almost 4 seconds (it's large), so my theory is that emacs is querying status so it can display something.

So my real question is how to make this less painful, without completely disabling vc-mode. I use ediff-revision vc-annotate and vc-log-dir constantly and wouldn't want to disable those features, but I don't think any of those should require a find-file hook. I don't care if I don't see the status bar line indicating status. Googling has given me few good suggestions. I don't want to manually enable and disable vc-mode all the time, I want something as automatic as possible.

Thanks!

UPDATE: it turns out that most of the problem was with a mercurial extension I was using that was part of kiln (kbfiles, see this). Things are still slow, but less painful. I updated the elp profile above with the new numbers

Upvotes: 1

Views: 231

Answers (1)

Stefan
Stefan

Reputation: 28601

Indeed, curently vc-hg.el just runs hg status <file> when opening the file, in order to determine if the file is indeed under Mercurial's control. Not sure why hg takes so long to determine the state of a single file, but you might like to M-x report-emacs-bug so that we can try and provide at least a workaround.

Upvotes: 1

Related Questions