After Magit has run
git for side-effects, it also refreshes the
current Magit buffer and the respective status buffer. This is
necessary because otherwise outdated information might be displayed
without the user noticing. Magit buffers are updated by recreating
their content from scratch, which makes updating simpler and less
error-prone, but also more costly. Keeping it simple and just
re-creating everything from scratch is an old design decision and
departing from that will require major refactoring.
I plan to do that in time for the next major release. I also intend to create logs and diffs asynchronously, which should also help a lot but also requires major refactoring.
Meanwhile you can tell Magit to only automatically refresh the current Magit buffer, but not the status buffer. If you do that, then the status buffer is only refreshed automatically if it itself is the current buffer.
(setq magit-refresh-status-buffer nil)
You should also check whether any third-party packages have added
magit-post-refresh-hook. If so, then
check whether those additions impacts performance significantly.
magit-refresh-verbose and then inspecting the output in the
*Messages* buffer, should help doing so.
Magit also reverts buffers which visit files located inside the
current repository, when the visited file changes on disk. That is
implemented on top of
auto-revert-mode from the built-in library
autorevert. To figure out whether that impacts performance, check
whether performance is significantly worse, when many buffers exist
and/or when some buffers visit files using Tramp. If so, then this
(setq auto-revert-buffer-list-filter 'magit-auto-revert-repository-buffers-p)
For alternative approaches see Automatic Reverting of File-Visiting Buffers.
If you have enabled any features that are disabled by default, then you should check whether they impact performance significantly. It’s likely that they were not enabled by default because it is known that they reduce performance at least in large repositories.
If performance is only slow inside certain unusually large repositories, then you might want to disable certain features on a per-repository or per-repository-class basis only. See Per-Repository Configuration.
|• Microsoft Windows Performance:|
|• MacOS Performance:|
When showing logs, Magit limits the number of commits initially shown
in the hope that this avoids unnecessary work. When using
used, then this unfortunately does not have the desired effect for
large histories. Junio, Git’s maintainer, said on the git mailing
list (http://www.spinics.net/lists/git/msg232230.html): "
to compute the whole history and the max-count only affects the output
--graph does its computation".
In other words, it’s not that Git is slow at outputting the differences, or that Magit is slow at parsing the output - the problem is that Git first goes outside and has a smoke.
We actually work around this issue by limiting the number of commits
not only by using
-<N> but by also using a range. But unfortunately
that’s not always possible.
In repositories with more than a few thousand commits
never be a member of
magit-log-section-arguments. That variable is
used in the status buffer which is refreshed every time you run any
--color --graph is even slower. Magit uses code that is part of
Emacs to turn control characters into faces. That code is pretty slow
and this is quite noticeable when showing a log with many branches and
merges. For that reason
--color is not enabled by default anymore.
Consider leaving it at that.
If diffs are slow, then consider turning off some optional diff
features by setting all or some of the following variables to
When showing a commit instead of some arbitrary diff, then some
additional information is displayed. Calculating this information
can be quite expensive given certain circumstances. If looking at
a commit using
magit-revision-mode takes considerably more time than
looking at the same commit in
magit-diff-mode, then consider setting
When refreshing the "references buffer" is slow, then that’s usually because several hundred refs are being displayed. The best way to address that is to display fewer refs, obviously.
If you are not, or only mildly, interested in seeing the list of tags, then start by not displaying them:
(remove-hook 'magit-refs-sections-hook 'magit-insert-tags)
Then you should also make sure that the listed remote branches
actually all exist. You can do so by pruning branches which no longer
When you initiate a commit, then Magit by default automatically shows a diff of the changes you are about to commit. For large commits this can take a long time, which is especially distracting when you are committing large amounts of generated data which you don’t actually intend to inspect before committing. This behavior can be turned off using:
(remove-hook 'server-switch-hook 'magit-commit-diff)
Then you can type
C-c C-d to show the diff when you actually want to
see it, but only then. Alternatively you can leave the hook alone and
C-g in those cases when it takes to long to generate the
diff. If you do that, then you will end up with a broken diff buffer,
but doing it this way has the advantage that you usually get to see
the diff, which is useful because it increases the odds that you spot
Emacs comes with a version control interface called "VC", see (emacs)Version Control. It is enabled be default and if you don’t use it in addition to Magit, then you should disable it to keep it from performing unnecessary work:
(setq vc-handled-backends nil)
You can also disable its use only for Git but keep using it when using another version control system:
(setq vc-handled-backends (delq 'Git vc-handled-backends))