emacs

cjohansen 2025-12-17T13:52:09.925139Z

I love magit, but it is very slow. Does anyone have any pointers on speeding it up?

cjohansen 2025-12-18T08:05:53.857309Z

@afoltzm Wow, same here ๐Ÿ˜ฎ

cjohansen 2025-12-18T08:06:13.028309Z

@jakemcc Your articles where very helpful, thanks!

๐Ÿ‘ 1
tvaughan 2025-12-18T09:53:59.008979Z

Perhaps try disabling font locking just to see if that makes a difference? I still think there isn't a way to disable computing diffs in the status buffer?

Sophie Bosio 2025-12-18T10:29:05.439559Z

I also experienced some slowness with Magit in my largest repo at work, and read some tips online. Can't remember where I found it, but someone suggested that dropping the tags header helps. I'm not really interested in the tags day-to-day anyway, so I have this in my Magit config:

; Remove tags from status buffer headings to speed up refresh slightly
(remove-hook 'magit-status-sections-hook 'magit-insert-tags-header)
Edit: Just skimmed @jakemccโ€™s article which covered this much better ๐Ÿ˜‚ Go read that instead! Might very well have been here I got the info way back when!

jakemcc 2025-12-18T15:20:39.444339Z

Glad the articles were helpful. Makes the time spent writing that up worthwhile ๐Ÿ˜‚

2
โค๏ธ 1
smishra 2025-12-18T20:32:53.847199Z

try a git gc and git fetch --prune. it is possible that magit is spending a lot of time enumerating stuff that's irrelevant now.

ag 2025-12-18T20:35:37.640779Z

also, don't forget about git fsmonitor https://github.blog/engineering/improve-git-monorepo-performance-with-a-file-system-monitor/

cjohansen 2025-12-18T21:22:16.400629Z

๐Ÿ™

mpenet 2025-12-17T13:56:46.538699Z

how slow?

cjohansen 2025-12-17T13:57:10.653479Z

M-x magit takes 3-4 seconds to build a UI

cjohansen 2025-12-17T13:57:21.733219Z

Staging a hunk takes several seconds

mpenet 2025-12-17T13:57:31.128839Z

on macos you have to be careful which git binary is used

๐Ÿ‘€ 1
โž• 1
vemv 2025-12-17T13:57:35.214619Z

Never heard of slowness. Maybe some other mode is conflicting? If you have it easy, perhaps try it over a minimal clean Emacs install and a variety of repos

cjohansen 2025-12-17T13:57:55.817229Z

@mpenet I'm on OSX, maybe this is my problem?

mpenet 2025-12-17T13:58:02.032189Z

could be

cjohansen 2025-12-17T13:58:04.227669Z

Basically, everything takes several seconds

mpenet 2025-12-17T13:58:10.665179Z

git is installed via brew or dev tools?

cjohansen 2025-12-17T13:58:33.829249Z

Not really sure. Maybe it's just system git? ๐Ÿค”

cjohansen 2025-12-17T13:58:40.176339Z

/usr/bin/git

mpenet 2025-12-17T13:58:44.268729Z

which git

mpenet 2025-12-17T13:59:00.062229Z

hmm don't know then. I just recall that homebrew git was painfully slow

cjohansen 2025-12-17T13:59:21.098879Z

what's the recommended git installation to use?

mpenet 2025-12-17T13:59:27.464349Z

git --version git version 2.50.1 (Apple Git-155)

mpenet 2025-12-17T13:59:44.266799Z

that's what I am using, it's fast, even on massive repos

cjohansen 2025-12-17T13:59:44.363709Z

Same

cjohansen 2025-12-17T13:59:49.930369Z

Hmm

vemv 2025-12-17T13:59:50.172509Z

FWIW I've always used /opt/homebrew/bin/git with no issue

๐Ÿ‘ 1
mpenet 2025-12-17T13:59:57.002949Z

ymmv I guess

cjohansen 2025-12-17T14:00:05.431129Z

How can I check what git magit is using?

mpenet 2025-12-17T14:00:14.520739Z

emacs version? native-comp?

cjohansen 2025-12-17T14:00:23.698209Z

Emacs for osx

cjohansen 2025-12-17T14:00:32.826399Z

29.4

mpenet 2025-12-17T14:00:35.293589Z

> GNU Emacs 31.0.50 (build 1, aarch64-apple-darwin24.5.0, NS appkit-2575.60 Version 15.5 (Build 24F74)) of 2025-06-06

mpenet 2025-12-17T14:00:38.989489Z

I am on emacs-plus

mpenet 2025-12-17T14:00:56.433559Z

never had luck with emacs for osx

mpenet 2025-12-17T14:01:07.226319Z

but it was a while since I last tried

cjohansen 2025-12-17T14:01:08.841579Z

Oh? I've used it for 10 years with no hiccups

cjohansen 2025-12-17T14:01:22.788629Z

Unless it is the reason why magit is slow ๐Ÿ˜…

mpenet 2025-12-17T14:01:26.095779Z

๐Ÿ™‚

mpenet 2025-12-17T14:01:34.331519Z

give it a try, maybe that helps

gunnar 2025-12-17T14:08:51.139319Z

I have Emacs for OSX. No problems here.

gunnar 2025-12-17T14:09:26.725579Z

(I'm on 30.1)

cjohansen 2025-12-17T14:17:47.678359Z

I have some corporate bullshit software like Microsoft Defender etc, could that be my problem? It doesn't seem like git is slow in the terminal.

Gent Krasniqi 2025-12-17T14:26:03.210209Z

Well magit and emacs on linux for me is faster than magit and emacs on Windows on more powerful hardware (but with Microsoft Defender and a lot of other over-protective stuff on corporate laptops) but I guess that is somewhat expected for emacs on windows.

Roma 2025-12-17T14:56:34.792749Z

https://docs.magit.vc/magit/Essential-Settings.html#Performance-1 this might be helpful

dpsutton 2025-12-17T15:05:03.295359Z

hereโ€™s what i would check: start up an eshell terminal and type which git i think this will be the one resolved by magit. work on a trivial repo where you know there are no weird commit hooks m-x profiler-start and do a cpu profiling of rendering the magit buffer a few times and see where itโ€™s waiting?

jakemcc 2025-12-17T15:59:08.289689Z

Back when I was working in a large monorepo, I did some digging into what was taking time and tweaked what magit-status UI displays and drastically improved the speed by having it do less work. https://jakemccrary.com/blog/2020/11/14/speeding-up-magit/ with some pointers on that strategy. I can't remember the status of native-comp with the version of emacs you posted but that made a difference as well (different https://jakemccrary.com/blog/2020/12/30/speeding-up-magit-with-the-native-comp-branch-of-emacs/)

โž• 1
๐ŸŽ‰ 1
cjohansen 2025-12-17T16:19:46.763289Z

Thanks for all the input! There are several things here I'll try.

respatialized 2025-12-17T22:33:36.825089Z

https://www.gnu.org/software/emacs/manual/html_node/emacs/Customizing-VC.html Double check the value of vc-handled-backends; Git is second-to-last by default! Profiling pointed my in the direction of this var - I've been burned by this in the past and it's a pretty trivial change to make to see if it improves performance

๐Ÿ™ 1
practicalli-johnny 2025-12-18T00:21:22.180949Z

I noticed Magit status buffer taking longer to display after using Emacs with Native Compilation enabled. Once the Magit status buffer was open then it seemed fine. Subsequent opening if Magit Status buffer was slow. I always open magit in a full sxreen buffer.

Samuel Ludwig 2025-12-17T19:55:09.614179Z

Anyone ever run into hanging when they create a mismatched quote in a regex, or a mismatched backquote in a comment (or docstring, maybe?) via cutting/backspacing/editing? I usually need to pkill emacs as a result. I know this is a super fuzzy ask, and I haven't been able to come up with a consistent replication yet; my heart feels like it might be clojure-lsp related (or possibly treesitter) Don't know if this sounds familiar to anyone, still in the investigation phase

Gent Krasniqi 2025-12-18T09:35:54.346449Z

I've had a similar thing (enter search string, backspace a few times -> hanging) with consult-ripgrep, but still not able to reproduce it reliably. I initially thought it might just be a rg issue in folders with a lot of stuff, but that wasn't it. But the good thing is that I can at least just kill rg and emacs is fine again.

ag 2025-12-17T20:24:56.830339Z

You mean pkill -SIGUSR2 emacs, I hope?

Samuel Ludwig 2025-12-17T20:38:13.794869Z

huh, y'know I only vaguely conceptually understand the differences between different kill signals (as in kill-for-sure-right-now vs kill-but-cleanup-after-yourself-first). what's the potential adverse effects/mechanical differences of pkill X vs pkill -SIGUSR2 X? i'm guessing just potential for zombie processes?

ag 2025-12-17T21:15:53.936269Z

the latter doesn't actually kill the process, it sends a signal from the outside that makes Emacs enter a debugger.

Samuel Ludwig 2025-12-17T21:22:57.987159Z

oh, i've never tried that before/didn't know it existed; that'll definitely make these less disruptive--if it can break through the freeze at all. appreciate it, I see a recommendation to probably M-x toggle-debug-on-quit immediately after (assuming I get control back) ty monsieur gratitude

ag 2025-12-17T21:26:06.637869Z

it does flip debug-on-quit on - which sometimes is annoying as after you deal with whatever hangs it, you often have to manually flip it off again. I have an alias: alias ,sigusr2='pkill -SIGUSR2 emacs' pro-tip: always start your custom bash functions and aliases prefixed, so you can easily find them. I would type , TAB and see all my customs

๐Ÿ‘ 1
ag 2025-12-17T21:27:38.391639Z

it is an absolute lifesaver. I don't remember the last time I actually had to hardkill Emacs process because it decided to hang for a while

Samuel Ludwig 2025-12-17T21:28:25.621669Z

oh that is beautiful, and the , prefix is a great strat