TIL Speed up Magit on MacOS

1 min read

I’ve been using Magit in Emacs for many years and on larger (and some smaller) projects there would usually be a 3 to 5 second delay with magit-status and commits. Today I’ve been refactoring my config and fixing annoyances and learned that setting the git executable explicitly fixed that issue for me - from about 4 seconds down to less than a second.

(use-package magit
  :bind ("C-x g" . magit-status)
  :custom
  (magit-git-executable "/opt/homebrew/bin/git"))

Comments from Mastodon

15 comments • Join the discussion

Arch 💕's avatar

@greg so, turns out there's an little extra detail in here! mac already has a git binary at /usr/bin/git!

but if you `brew install git`, and then set the magit git path to the brew version explicitly--it seems like the *newer version* brew pulls in is where the real speed gain happens!

but yeah! that speedup is drastic, damn

Arch 💕's avatar

@greg hm! maybe!

for me, it looked like if i didn't specify that custom variable directly, magit would actually totally bypass exec-path-from-shell, though!

(since the default value for that variable was "/usr/bin/git", which does exist, meaning it didn't need to hunt on $PATH)

tl;dr - magit seems to prioritize explicitly using any version that lives in /usr/bin/, even if $PATH would resolve elsewhere

1
Greg Newman's avatar
Greg Newman @greg
View on Mastodon

@archenoth me too! Always learning. thanks. I wrote that code this week. I have to hook up a cron on cloudflare to grab the latest comments. And also need to make it threaded.

1
Arch 💕's avatar

@greg oh yeah! threading is tricky! (i wrote a simple client-side version of this earlier for my blog too, and haven't done that part either! ahah)

though, user icons are pretty easy to implement if you wanted to build something easier before doing that! since the uri just lives in account.avatar

(like this! github.com/Archenoth/archenoth)

custom emoji can also be directly pulled out of comments and replaced with image tags using global regex too! (like this! github.com/Archenoth/archenoth)

Greg Newman's avatar
Greg Newman @greg
View on Mastodon

@archenoth cool I’ll check this out. Thanks! I’m already grabbing avatars at this point. I just need to look a little deeper at the json response for deeper replies.

1
Greg Newman's avatar
Greg Newman @greg
View on Mastodon

@archenoth good find and great info! There is a verbose setting for magit to output everything to messages to find bottlenecks but I didn’t have to go that far.

1