1

In OSX El Capitan, I am using Magit 20171026.217, Git 2.10.1 (Apple Git-78), Emacs 25.1.1, darwin.

In CentOS Release 6.6, I'm using Magit 20180903.2339, Git 2.13.1, Emacs 26.1, gnu/linux.

For the same 40 MByte git repo, the magit status buffer requires 4 seconds to appear in linux but only 0.5 seconds in Mac OS. There was a one-line change in one file in the linux repo.

In CentOS, my .emacs contains the following commands from the magit performance page and elsewhere:

    ;; https://magit.vc/manual/magit/Performance.html
    (setq magit-refresh-status-buffer nil)
    (setq magit-diff-highlight-indentation nil)
    (setq magit-diff-highlight-trailing nil)
    (setq magit-diff-paint-whitespace nil)
    (setq magit-diff-highlight-hunk-body nil)
    (setq magit-diff-refine-hunk nil)
    (setq magit-revision-insert-related-refs nil)
    (remove-hook 'magit-refs-sections-hook 'magit-insert-tags)
    (remove-hook 'server-switch-hook 'magit-commit-diff)
    (setq vc-handled-backends nil)
    (setq auto-revert-buffer-list-filter
          'magit-auto-revert-repository-buffers-p)
    ;; https://williambert.online/2015/11/How-I-made-Magit-fast-again/
    (setq magit-commit-show-diff nil)
    (setq magit-revert-buffers 1)
    (setq magit-refresh-verbose 1)

I used this code to profile magit-status on linux and macOS:

    (defun profile-magit ()
      (elp-instrument-package "magit")
      (elp-reset-all)
      (magit-status "pathToRepo")
      (elp-results))
    (profile-magit)

The results are shown below, first for CentOS (bad) and then for MacOS (great).

Any suggestions on speeding up the CentOS performance are greatly appreciated.

PROFILING RESULTS ON CENTOS (very slow):

    magit-status                                      1           4.637725058   4.637725058
    magit-run-section-hook                            2           4.633367778   2.316683889
    magit-process-file                                26          4.408109038   0.1695426553
    magit-status-internal                             1           4.3173727809  4.3173727809
    magit-mode-setup                                  1           4.317356942   4.317356942
    magit-mode-setup-internal                         1           4.31735279    4.31735279
    magit-refresh-buffer                              1           3.95782774    3.95782774
    magit-status-refresh-buffer                       1           3.957227878   3.957227878
    magit-git-insert                                  13          2.124903824   0.1634541403
    magit-git-str                                     23          1.4826771669  0.0644642246
    magit-insert-status-headers                       1           1.127880501   1.127880501
    magit-rev-parse-safe                              20          1.093782861   0.0546891430
    magit-insert-unpushed-to-upstream-or-recent       1           1.082952769   1.082952769
    magit-git-string                                  14          1.0594253679  0.0756732405
    magit-insert-headers                              1           0.982247303   0.982247303
    magit-git-wash                                    4           0.82460503    0.2061512575
    magit-insert-recent-commits                       1           0.783410273   0.783410273
    magit-insert-log                                  2           0.63769903    0.318849515
    magit-rev-verify                                  4           0.601661585   0.1504153962
    magit-git-exit-code                               3           0.6005712080  0.2001904026
    magit-rev-parse                                   3           0.4716020800  0.1572006933
    magit-log-wash-log                                1           0.46797409    0.46797409
    magit-insert-tags-header                          1           0.389292032   0.389292032
    magit-git-items                                   2           0.386998803   0.1934994015
    magit-insert-staged-changes                       1           0.359801993   0.359801993
    magit-abbrev-length                               1           0.31824761    0.31824761
    magit-toplevel                                    21          0.317811276   0.0151338702
    magit-insert-unpulled-from-upstream               1           0.314986998   0.314986998
    magit-insert-head-branch-header                   1           0.302152539   0.302152539
    magit-git-success                                 2           0.294809955   0.1474049775
    magit-rev-format                                  2           0.293499864   0.146749932
    magit-insert-upstream-branch-header               1           0.29064293    0.29064293
    magit-insert-untracked-files                      1           0.242863067   0.242863067
    magit-display-buffer                              1           0.212477492   0.212477492
    magit-bare-repo-p                                 1           0.201640107   0.201640107
    magit-rev-parse-true                              1           0.201567176   0.201567176
    magit-git-true                                    1           0.201562606   0.201562606
    magit-git-output                                  1           0.201557613   0.201557613
    magit-get-current-tag                             2           0.196021831   0.0980109155
    magit-get-next-tag                                1           0.193064518   0.193064518
    magit-insert-unstaged-changes                     1           0.187144843   0.187144843
    magit-git-dir                                     11          0.1754272640  0.0159479330
    magit-insert-merge-log                            1           0.174901715   0.174901715
    magit-merge-in-progress-p                         1           0.174897354   0.174897354
    magit-insert-stashes                              1           0.159585508   0.159585508
    magit-wash-sequence                               3           0.1505684099  0.0501894699
    magit-log-wash-rev                                10          0.149665603   0.0149665603
    magit-get-current-branch                          8           0.1476631309  0.0184578913
    magit-format-ref-labels                           10          0.147321033   0.0147321032
    magit-status-mode                                 1           0.146352289   0.146352289
    magit-rev-ancestor-p                              1           0.146086039   0.146086039
    magit-get-all                                     18          0.145360679   0.0080755932
    magit-config-get-from-cached-list                 19          0.145263918   0.0076454693
    magit-load-config-extensions                      1           0.144793241   0.144793241
    magit-display-buffer-traditional                  1           0.107423347   0.107423347
    magit-section-ident                               147         0.0021125400  1.437...e-05
    magit-mode                                        1           0.000829181   0.000829181
    magit-diff-wash-diffs                             1           0.000642034   0.000642034
    magit-get                                         17          0.0006312269  3.713...e-05
    magit--safe-default-directory                     9           0.0006285869  6.984...e-05
    magit-section                                     19          0.0006018359  3.167...e-05
    magit-diff-wash-diff                              1           0.000599268   0.000599268
    magit-section-cached-visibility                   22          0.000589903   2.681...e-05
    magit-insert-heading                              7           0.00055112    7.873...e-05
    magit-diff-insert-file-section                    1           0.000520999   0.000520999
    magit-maybe-make-margin-overlay                   9           0.00050706    5.634...e-05
    magit-file-accessible-directory-p                 9           0.000468549   5.2061e-05
    magit-section-match                               10          0.0004680669  4.680...e-05
    magit-maybe-save-repository-buffers               1           0.000440343   0.000440343
    magit-save-repository-buffers                     1           0.000433461   0.000433461
    magit-get-push-branch                             5           0.000421858   8.43716e-05
    magit-get-section                                 22          0.000419913   1.908...e-05
    magit-process-environment                         26          0.0003858840  1.484...e-05
    magit-section-match-1                             51          0.0003856660  7.562...e-06
    magit-get-push-remote                             5           0.0003759310  7.518...e-05
    magit-rebase-in-progress-p                        2           0.000323864   0.000161932
    magit-section-show                                7           0.000277453   3.963...e-05
    magit-diff-wash-hunk                              1           0.00026903    0.00026903
    magit-insert-rebase-sequence                      1           0.000250239   0.000250239
    magit-insert-sequencer-sequence                   1           0.00024326    0.00024326
    magit-log-format-margin                           10          0.0002284770  2.284...e-05
    magit-mode-get-buffer                             1           0.000188089   0.000188089
    magit-get-upstream-branch                         2           0.000178769   8.93845e-05
    magit-bisect-in-progress-p                        3           0.0001767080  5.890...e-05
    magit--process-coding-system                      26          0.0001568349  6.032...e-06
    magit-insert-child-count                          20          0.000139597   6.979...e-06
    magit-diff-expansion-threshold                    22          0.000138593   6.299...e-06
    magit-insert-bisect-output                        1           0.000132705   0.000132705
    magit-process-git-arguments                       26          0.000132603   5.100...e-06
    magit-cherry-pick-in-progress-p                   1           0.000122953   0.000122953
    magit-insert-am-sequence                          1           0.000115193   0.000115193
    magit-revert-in-progress-p                        1           0.000114903   0.000114903
    magit-am-in-progress-p                            1           0.000111797   0.000111797
    magit-insert-unpushed-to-pushremote               1           0.00010976    0.00010976
    magit-section-update-highlight                    1           0.000108693   0.000108693
    magit-section-match-assoc                         5           0.000100528   2.01056e-05
    magit-expand-git-file-name                        11          9.6376e-05    8.761...e-06
    magit-insert-push-branch-header                   1           9.618e-05     9.618e-05
    magit-make-margin-overlay                         16          9.1406e-05    5.712875e-06
    magit-delete-line                                 15          8.555...e-05  5.703...e-06
    magit-preserve-section-visibility-cache           19          7.8316e-05    4.121...e-06
    magit-insert-unpulled-from-pushremote             1           7.3261e-05    7.3261e-05
    magit-file-section-p                              22          7.145...e-05  3.248...e-06
    magit-file-section                                2           6.5891e-05    3.29455e-05
    magit--age                                        10          6.1487e-05    6.1487e-06
    magit--assert-default-directory                   1           6.0568e-05    6.0568e-05
    magit-section-match-2                             45          4.7839e-05    1.063...e-06
    magit-log-propertize-keywords                     12          4.7763e-05    3.980...e-06
    magit-diff-highlight                              1           4.1871e-05    4.1871e-05
    magit-section-goto-successor                      1           3.9938e-05    3.9938e-05
    magit-set-buffer-margin                           1           3.2258e-05    3.2258e-05
    magit-insert-bisect-rest                          1           2.7742e-05    2.7742e-05
    magit-hunk-section                                1           2.7432e-05    2.7432e-05
    magit-section-hide                                2           2.6654e-05    1.3327e-05
    magit-insert-bisect-log                           1           2.4944e-05    2.4944e-05
    magit-refresh-get-relative-position               1           2.3263e-05    2.3263e-05
    magit-section-maybe-cache-visibility              9           2.139...e-05  2.377...e-06
    magit-get-boolean                                 1           1.782e-05     1.782e-05
    magit-margin-option                               11          1.307...e-05  1.188...e-06
    magit-process-unset-mode-line-error-status        1           1.2741e-05    1.2741e-05
    magit-ignore-submodules-p                         2           1.253e-05     6.265e-06
    magit-diff-scope                                  1           1.0888e-05    1.0888e-05
    magit-insert-diff-filter-header                   1           1.0598e-05    1.0598e-05
    magit-repository-local-get                        1           9.41e-06      9.41e-06
    magit-section-highlight                           1           9.284e-06     9.284e-06
    magit-current-section                             5           8.803...e-06  1.760...e-06
    magit-set-window-margin                           1           7.655e-06     7.655e-06
    magit-save-window-configuration                   1           7.348e-06     7.348e-06
    magit-diff-type                                   1           6.795e-06     6.795e-06
    magit-maybe-set-dedicated                         1           6.511e-06     6.511e-06
    magit-repository-local-exists-p                   1           5.645e-06     5.645e-06
    magit-auto-revert-mode-enable-in-buffers          1           5.231e-06     5.231e-06
    magit-log-margin-width                            1           5.01e-06      5.01e-06
    magit--tramp-asserts                              1           4.475e-06     4.475e-06
    magit-hunk-section-p                              1           4.097e-06     4.097e-06
    magit-section-make-overlay                        1           2.431e-06     2.431e-06
    magit-region-sections                             1           2.136e-06     2.136e-06
    magit-auto-revert-mode-cmhh                       1           2.103e-06     2.103e-06
    magit-decode-git-path                             2           2.044...e-06  1.022...e-06
    magit-repository-local-repository                 1           1.555e-06     1.555e-06
    magit-xref-setup                                  1           1.51e-06      1.51e-06
    magit-insert-error-header                         1           1.505e-06     1.505e-06
    magit-turn-on-auto-revert-mode-if-desired         1           1.046e-06     1.046e-06
    magit-file-mode-turn-on                           1           9.83e-07      9.83e-07
    magit-buffer-margin-p                             1           9.05e-07      9.05e-07
    magit-cancel-section                              2           0.0           0.0

PROFILING RESULTS ON MACOS (very fast):

    magit-status                                      1           0.584569      0.584569
    magit-process-file                                26          0.5628430000  0.0216478076
    magit-status-internal                             1           0.510929      0.510929
    magit-mode-setup                                  1           0.510912      0.510912
    magit-mode-setup-internal                         1           0.510904      0.510904
    magit-refresh-buffer                              1           0.485749      0.485749
    magit-status-refresh-buffer                       1           0.484318      0.484318
    magit-run-section-hook                            1           0.430791      0.430791
    magit-git-insert                                  13          0.2643129999  0.0203317692
    magit-git-str                                     24          0.2187900000  0.0091162500
    magit-insert-status-headers                       1           0.160217      0.160217
    magit-rev-parse-safe                              20          0.15506       0.007753
    magit-insert-headers                              1           0.139779      0.139779
    magit-insert-head-branch-header                   1           0.139406      0.139406
    magit-git-string                                  12          0.134189      0.0111824166
    magit-insert-unpushed-to-upstream-or-recent       1           0.109471      0.109471
    magit-insert-recent-commits                       1           0.082984      0.082984
    magit-git-exit-code                               3           0.082196      0.0273986666
    magit-insert-remaining-headers                    1           0.07875       0.07875
    magit-toplevel                                    17          0.0727460000  0.0042791764
    magit-rev-verify                                  4           0.0676649999  0.0169162499
    magit-insert-log                                  2           0.066954      0.033477
    magit-git-wash                                    4           0.06692       0.01673
    magit-git-items                                   2           0.064539      0.0322695
    magit-rev-format                                  2           0.056975      0.0284875
    magit-log-wash-log                                1           0.04906       0.04906
    magit-insert-tags-header                          1           0.048515      0.048515
    magit-rev-parse                                   3           0.045511      0.0151703333
    magit-insert-untracked-files                      1           0.043747      0.043747
    magit-abbrev-length                               1           0.032661      0.032661
    magit-insert-unpulled-from-upstream               1           0.032577      0.032577
    magit-insert-staged-changes                       1           0.031339      0.031339
    magit-insert-upstream-branch-header               1           0.03007       0.03007
    magit-git-success                                 2           0.0290969999  0.0145484999
    magit-get-current-tag                             2           0.028617      0.0143085
    magit-status-mode                                 1           0.022703      0.022703
    magit-get-all                                     14          0.0214800000  0.0015342857
    magit-config-get-from-cached-list                 15          0.0213949999  0.0014263333
    magit-load-config-extensions                      1           0.021059      0.021059
    magit-get-next-tag                                1           0.019779      0.019779
    magit-insert-unstaged-changes                     1           0.019263      0.019263
    magit-get-current-branch                          6           0.017693      0.0029488333
    magit-git-dir                                     11          0.017037      0.0015488181
    magit-insert-merge-log                            1           0.016681      0.016681
    magit-wash-sequence                               1           0.016351      0.016351
    magit-insert-stashes                              1           0.016344      0.016344
    magit-log-wash-rev                                11          0.016312      0.0014829090
    magit-bare-repo-p                                 1           0.016012      0.016012
    magit-rev-parse-p                                 1           0.015726      0.015726
    magit-git-true                                    1           0.01572       0.01572
    magit-format-ref-labels                           11          0.014966      0.0013605454
    magit-rev-ancestor-p                              1           0.013539      0.013539
    magit-maybe-save-repository-buffers               1           0.001332      0.001332
    magit-save-repository-buffers                     1           0.001325      0.001325
    magit-mode                                        1           0.001204      0.001204
    magit--safe-default-directory                     9           0.001082      0.0001202222
    magit-file-accessible-directory-p                 9           0.0009219999  0.0001024444
    magit-display-buffer                              1           0.000802      0.000802
    magit-rebase-in-progress-p                        2           0.00054       0.00027
    magit-get                                         13          0.0004720000  3.630...e-05
    magit-insert-heading                              5           0.000455      9.1e-05
    magit-display-buffer-traditional                  1           0.0004        0.0004
    magit-format-ref-label                            14          0.0003319999  2.371...e-05
    magit-insert-rebase-sequence                      1           0.000295      0.000295
    magit-section-show                                16          0.000288      1.8e-05
    magit-get-push-branch                             3           0.000285      9.499...e-05
    magit-insert-sequencer-sequence                   1           0.000253      0.000253
    magit-log-format-margin                           11          0.000248      2.254...e-05
    magit-maybe-make-margin-overlay                   6           0.000239      3.983...e-05
    magit-get-push-remote                             3           0.000234      7.8e-05
    magit-mode-get-buffer                             1           0.000201      0.000201
    magit-section-match-1                             32          0.000183      5.71875e-06
    magit-file-lines                                  1           0.000176      0.000176
    magit-section-match                               7           0.000175      2.5e-05
    magit-bisect-in-progress-p                        3           0.000173      5.766...e-05
    magit-get-upstream-branch                         2           0.000171      8.55e-05
    magit-section-ident                               65          0.0001589999  2.446...e-06
    magit-cherry-pick-in-progress-p                   1           0.000135      0.000135
    magit-section-set-visibility-from-cache           19          0.0001229999  6.473...e-06
    magit-process-git-arguments                       26          0.0001229999  4.730...e-06
    magit-insert-bisect-output                        1           0.000119      0.000119
    magit-insert-unpulled-from-pushremote             1           0.000117      0.000117
    magit-insert-am-sequence                          1           0.000117      0.000117
    magit-revert-in-progress-p                        1           0.000113      0.000113
    magit-am-in-progress-p                            1           0.000113      0.000113
    magit-insert-unpushed-to-pushremote               1           0.000106      0.000106
    magit--process-coding-system                      26          9.300...e-05  3.576...e-06
    magit-insert-push-branch-header                   1           9.2e-05       9.2e-05
    magit-make-margin-overlay                         17          8.9e-05       5.235...e-06
    magit-delete-line                                 11          8.300...e-05  7.545...e-06
    magit-section-update-highlight                    1           7.5e-05       7.5e-05
    magit-section-visibility-ident                    35          6.999...e-05  1.999...e-06
    magit-get-section                                 20          6.8e-05       3.4e-06
    magit-expand-git-file-name                        11          5.900...e-05  5.363...e-06
    magit-diff-highlight                              1           5.1e-05       5.1e-05
    magit--age                                        11          5e-05         4.545...e-06
    magit-cygwin-env-vars                             26          4.699...e-05  1.807...e-06
    magit-section-update-visibility-cache             16          4.499...e-05  2.812...e-06
    magit-diff-expansion-threshold                    19          3.799...e-05  2e-06
    magit-set-buffer-margin                           1           3.6e-05       3.6e-05
    magit-insert-bisect-log                           1           3.1e-05       3.1e-05
    magit-insert-bisect-rest                          1           3e-05         3e-05
    magit-margin-option                               12          1.9e-05       1.583...e-06
    magit-diff-scope                                  1           1.7e-05       1.7e-05
    magit-log-propertize-keywords                     11          1.600...e-05  1.454...e-06
    magit-auto-revert-mode-enable-in-buffers          1           1.5e-05       1.5e-05
    magit-save-window-configuration                   1           1.5e-05       1.5e-05
    magit-get-boolean                                 1           1.5e-05       1.5e-05
    magit-current-section                             5           1.400...e-05  2.800...e-06
    magit-section-match-2                             29          1.4e-05       4.827...e-07
    magit-section-goto-successor                      1           1.4e-05       1.4e-05
    magit-insert-child-count                          16          1.100...e-05  6.875...e-07
    magit-section-highlight                           1           1.1e-05       1.1e-05
    magit-set-window-margin                           1           9e-06         9e-06
    magit-refresh-get-relative-position               1           8e-06         8e-06
    magit-auto-revert-mode-cmhh                       1           5e-06         5e-06
    magit-log-margin-width                            1           4e-06         4e-06
    magit-insert-error-header                         1           2e-06         2e-06
    magit-maybe-set-dedicated                         1           2e-06         2e-06
    magit-buffer-margin-p                             1           2e-06         2e-06
    magit-section-make-overlay                        1           2e-06         2e-06
    magit-diff-type                                   1           2e-06         2e-06
    magit--tramp-asserts                              1           2e-06         2e-06
    magit-region-sections                             1           1e-06         1e-06
    magit-turn-on-auto-revert-mode-if-desired         1           1e-06         1e-06
    magit-diff-use-hunk-region-p                      1           1e-06         1e-06
    magit-insert-diff-filter-header                   1           1e-06         1e-06
    magit-xref-setup                                  1           1e-06         1e-06
    magit-cancel-section                              3           0.0           0.0
  • You're using the same hardware for both operating systems? – phils Oct 21 '18 at 23:29
  • The hardware is different as shown below. It shouldn't really matter because on CentOS, "git status" from the command line takes less than a second but over 4 seconds in magit. MACOS: Macbook Pro 2.5 GHZ Intel Core I7, 16 GB memory CENTOS: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit CPU(s): 2 CPU MHz: 2599.997 L1d cache: 32K L1i cache: 32K L2 cache: 256K L3 cache: 25600K – Felix F. Oct 22 '18 at 0:05
  • For clarity, you're saying that running git status via Magit (as opposed to M-x magit-status which is something extremely different) takes over 4 seconds? – phils Oct 22 '18 at 1:14
  • A cursory look at those profiles does suggest that absolutely everything is significantly slower on your CentOS machine. I'd be surprised if this is anything particular to Magit. It might be specific to Emacs, depending on how Emacs was compiled? For starters I would suggest you do some benchmarking between the systems without involving Emacs. – phils Oct 22 '18 at 1:26
  • Thanks for the feedback. Could you please suggest a benchmark test that would diagnose whether the slow M-x magit-status can really be blamed on the hardware? – Felix F. Oct 22 '18 at 2:51
2

The opposite of your problem used to be a common problem: Magit was slow on macOS but fast on a proper Unix. That issue was due to an Emacs bug and updating to Emacs 26.1 fixes it.

There are many differences between the two "situations". The only way to figure out which of these differences makes the difference is to eliminate the differences one by on.

I understand you might not be inclined to update the Magit used in the fast situation as that might very well result in that becoming slow too. But that would be a good thing because then we would know that there is some performance regression and could rule out the other potential issues.

You might want to create a copy of ~/.emacs.d/elpa/ (or just the relevant packages) and then reinstall all packages. That way you could go back to the known good version if it so happens that there indeed is a performance regression.


As far as I can gather from a distance, the problem is the virtual machine. That doesn't have to be slow; other users have reported that running Magit in a virtual machine is faster than running natively on Windows for example. So it probably is something specific to the virtual machine that you are using, such as the file system you use inside that. I cannot help with that though, as I likely know less about it than you do.

  • Thanks for the suggestion on saving elpa/ and upgrading emacs. I'll try that soon. – Felix F. Oct 26 '18 at 20:27
  • Unfortunately, git clean -fdx didn't change performance. – Felix F. Oct 26 '18 at 20:28
  • In MacOS, just upgraded to these: Magit 20181027.1216, Git 2.19.1, Emacs 26.1, darwin. – Felix F. Oct 27 '18 at 23:27
  • Magit status still appears instantaneously, so there is still a problem on CentOS which takes 4 seconds with new versions. – Felix F. Oct 27 '18 at 23:29
  • Well, since "fast on macOS, slow on Linux" is something I never heard of before, I think we have established the issue is the virtual machine. – tarsius Oct 28 '18 at 9:10

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.