-
Notifications
You must be signed in to change notification settings - Fork 521
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
Performance issues with large git indexes #2938
Comments
I presented GitButler to my colleagues and they of course immediately tried to use it on our largest repository. Moving changes between virtual-branches takes over two seconds. So I started to dig into this. And ran a profiler. 92% of the time is spent in git_diff_tree_to_workdir. So I am currently reading the code and thinking about the issue. I just wanted to give feedback early. EDIT Findings
|
hey! thanks for the profiling info! how many tracked files do you have? |
something that we will try out soon, is see if can use gitoxide for the heaviest operations GitoxideLabs/gitoxide#1287 but either way we'd need to make the flow efficient the the the snappiest possible experience |
It seems like rehashing a lot, we also have a lot large snapshot-test files. (See findings) |
I think I found the problem. In git_diff_tree_to_workdir the hashes from the workdir (filesystem) are not cached. It will rehash every unchanged file. The cache seems to be missing, because we compare to a (virtual) tree. I assume it is not implemented, because the cache cannot be stored in existing git-structures. libgit2 would have to store this cache at a place currently not existing. But it also seems difficult to fix that outside libgit2. (See also edits above) |
If we use git_diff_tree_to_workdir_with_index we get a cache. I guess this means we could fix this, by reverting the effect of staged data before doing the diff. I assume users shouldn't stage anything when using GitButler anyways. diff --git a/gitbutler-app/src/git/repository.rs b/gitbutler-app/src/git/repository.rs
index 7893c12b..db025c65 100644
--- a/gitbutler-app/src/git/repository.rs
+++ b/gitbutler-app/src/git/repository.rs
@@ -148,7 +148,7 @@ impl Repository {
opts: Option<&mut git2::DiffOptions>,
) -> Result<git2::Diff<'_>> {
self.0
- .diff_tree_to_workdir(old_tree.map(Into::into), opts)
+ .diff_tree_to_workdir_with_index(old_tree.map(Into::into), opts)
.map_err(Into::into)
} |
Thank you so much for showing this @ganwell! You are right that staging is not something that is in the flow. I am gonna merge your patch to do some testing with the nightly build over the weekend 🙇 |
I saw the failure at #3158. I checked Steps
Considerations
diff --git a/gitbutler-app/src/git/repository.rs b/gitbutler-app/src/git/repository.rs
index 7893c12b..0017fe41 100644
--- a/gitbutler-app/src/git/repository.rs
+++ b/gitbutler-app/src/git/repository.rs
@@ -147,8 +147,11 @@ impl Repository {
old_tree: Option<&Tree<'_>>,
opts: Option<&mut git2::DiffOptions>,
) -> Result<git2::Diff<'_>> {
+ if let Ok(mut index) = self.0.index() {
+ index.update_all(vec!["*"], None)?;
+ }
self.0
- .diff_tree_to_workdir(old_tree.map(Into::into), opts)
+ .diff_tree_to_workdir_with_index(old_tree.map(Into::into), opts)
.map_err(Into::into)
} |
thanks! let me get that patch in - i got distracted with other things. I really appreciated your help here, i wanna buy you a beer! |
GitButler reverts staging as soon as it does its update-cycle. I to my understanding that means using the index is save. If nothing is staged |
Once again, than you for debugging and profiling this @ganwell ! I have merged your patch and if you spot anything else, you are welcome to open a PR directly too. I think i'm gonna close this issue. If you would like, ping me on [email protected] and i will make sure that multiple beers get delivered to your door 🍻! |
Repositories that have high cardinality of files (20K+ of distinct files) are slow to operate on.
Initial investigation indicates that this is related to frequent operations on a large index.
Discord thread:https://discord.com/channels/1060193121130000425/1073202153163857920/1211957896968142912
The text was updated successfully, but these errors were encountered: