Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoC: Use gitoxide for rev walk #2269

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cruessler
Copy link
Contributor

@cruessler cruessler commented Jun 16, 2024

This is a PoC, mainly intended to explore two things:

  1. how easy/difficult it is to switch git2 for gix for a single use case,
  2. compare both approaches with respect to performance.

Findings

This version uses repo.rev_walk(). We could also try implementing the existing algorithm using gitx primitives, but I think it makes sense to optimize repo.rev_walk() so that every consumer benefits from improvements.

It seems as if using gix instead of git2 is fairly straightforward. There are a few changes necessary, but none of them major. Also, it seems as if the changes can mostly be contained in LogWalker, in particular without the need to change LogWalker::read’s API. (LogWalker::new needs to slightly be changed, but this does not look like an issue.)

Performance-wise, it seems as if the gix implementation is slower than the git2 implementation by about 30 %. I tested how long it took to open the app in my copy of the Linux kernel until the loading indicator stopped spinning, indicating that the full list of commit ids had been loaded. My copy of the Linux kernel contains 1_014_089 commits.

gix with use_commit_graph(true): about 22 s
gix with use_commit_graph(false): about 22 s
git2 (at commit 038c4a5): about 17 s

Keep in mind that these are very rough numbers. It’s also possible that the gix API can be used in a way that is faster.

gix with features = ["max-performance"]

When using features = ["max-performance"], gix is about 25 % faster on my machine than the implementation based on git2.

gix with use_commit_graph(false): about 13 s
gix with use_commit_graph(true): about 13 s

git2 without hash verification or caching

I added the following lines to repo in asyncgit::sync::repository, right before Repository::open_ext, and it was even faster.

enable_caching(false);
strict_hash_verification(false);

git2 without hash verification or caching: about 10 s

Edit 2024-06-16: I also got flamegraphs for both implementations that I could share.
Edit 2024-06-17: I added numbers for features = ["max-performance"]. I’ll later also add a flamegraph and will test use_commit_graph(true).
Edit 2024-06-18: I added numbers for git2 without hash verification or caching.

@cruessler cruessler changed the title Use gitoxide for rev walk PoC: Use gitoxide for rev walk Jun 16, 2024
@cruessler
Copy link
Contributor Author

cruessler commented Jun 17, 2024

Flamegraph using gitx

flamegraph

Flamegraph using gitx with features = ["max-performance"]

flamegraph

Flamegraph using git2

flamegraph

Flamegraph using git2 without hash verification or caching

flamegraph

@Byron
Copy link

Byron commented Jun 17, 2024

That's all very exciting, thanks for getting started with gix in gitui :)!

I think it's worth noting that gix does not validate the objects it reads right now, which makes it less safe than git2, but as safe as Git (as far as I could tell).

This git2 behaviour can be deactivated with strict_hash_verification, and maybe more performance can be obtained by disabling object caching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants