reddit / emacs

magit + libgit2

zsome · 2022-08-24 10:34
Hi, Do you use magit + libgit2 ? Can I ask you to write a short comment how to set it up ? thanks !
nnreddit-user · 2022-08-24 11:00
It can't be done, at least not at a level that's useful (I've tried). There are still things raw git can do that libgit2 cannot (and that set continues to grow).
wyuenho · 2022-08-24 19:39
It can be "done", I just don't notice any difference lol, not even purported speedups because creating a process from emacs is actually quite fast already.
jimehgeek · 2022-08-25 01:44
If you’re talking about the `magit-libgit`, there’s no real difference compared to without it, cause only one thing is implemented: https://github.com/magit/magit/blob/712be4632b0ddc7899ca90db8f9be20d90b4326f/lisp/magit-libgit.el So the rest of magic still won’t use libgit2… lol
zsome · 2022-08-26 04:36
Thanks, I saw it but I saw this one as well: [https://github.com/magit/libegit2](https://github.com/magit/libegit2) I have problem with magit in the win10 system only , but the git gui and gitk can work well ...
jimehgeek · 2022-08-26 08:09
Ah, I’ve not seen that repo. Though it looks to be a wrapper module around libgit2, so I’m not sure the module alone would make magit automatically use it if available 🤔
nnreddit-user · 2022-08-26 09:18
In March, I started by trying to get magit-status (C-x g) to use libgit2 exclusively. Two weeks of effort resulted in 200 files changed and a 100 ms shaved off `C-x g` on an ubuntu system. As much as I hate name-dropping urls (because no one wants to click out of reddit), I do so here for the court as Exhibits A and B. https://github.com/dickmao/magit/tree/libgit2-el (magit) https://github.com/dickmao/libgit2-el (libegit2)
zsome · 2022-08-27 05:07
Thanks! I'll give a try to this! I intended to use it on win10 ... that is where it's a pain :(
nnreddit-user · 2022-08-27 07:19
> I'll give a try to this! That would be a mistake. I can already tell you're not going to get very far.
arthurno1 · 2022-08-27 11:12
> It can't be done, at least not at a level that's useful (I've tried). Depends on what you tried and how you use Git maybe? "Can't be done" anyway sounds a bit too presumptuous to me. There are things where libgit2 is faster than git, and there are things libgit2 can't do. Here is a brief note from [another discussion](https://gitlab.com/gitlab-org/gitaly/-/issues/2011): > There are areas where libgit2 offers major performance benefits, mostly for batch operations. We recently talked about running git blame on multiple files: with git, to blame N files you must start N git blame processes. Spawning a process is relatively expensive. Another good example is "last commit for path", where for each path, we must spawn a git log -1 foo/bar process. Apart from reducing process spawn overhead, libgit2 is also cheaper for looking up Git objects. The status quo in Gitaly is that we use a git cat-file process. For each object lookup we must do a write and a read syscall on the stdin and stdout pipes of git cat-file, respectively. A process that uses libgit2 is just doing memory-mapped IO so syscalls get amortized into page faults, and repeat lookups of the same Git object sometimes don't require context switches at all. So it seems that mixed libgit2 + git process in Magit, or Emacs in general, could benefit heavy git users.
nnreddit-user · 2022-08-27 13:37
> sounds a bit too presumptuous to me In your case there's almost no limit to what I can presume.
arthurno1 · 2022-08-27 15:10
> In your case there's almost no limit to what I can presume. Why limiting yourself to presumptions? The only limit is the imagination, as they say ...