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

reduce stat calls during git discovery #6882

Closed
wants to merge 2 commits into from

Conversation

pascalkuthe
Copy link
Member

@pascalkuthe pascalkuthe commented Apr 26, 2023

This should help with #6867, I talked with @Byron and for our purposes checking .git should be enough and take less stat calls.

I still want to cache the repo lookup here eventually, but that needs some more considerations about resource cleanup (so we don't keep an infinite amout of repos open, probably some kind of LRU mechanism is needed). I also want to look into opening the repo asynchronously, but that's a bit awkward to synchronize, so I will look at that in a separate PR too.

@pascalkuthe pascalkuthe added this to the 23.04 milestone Apr 26, 2023
@pascalkuthe pascalkuthe added C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much S-waiting-on-review Status: Awaiting review from a maintainer. A-vcs Area: Version control system interaction labels Apr 26, 2023
Copy link
Contributor

@Byron Byron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth noting that this way the git ceiling dir isn't respected, which might have been a silent benefit of the current discovery mechanism.

If it helps, in theory GitoxideLabs/gitoxide#832 should end up doing pretty much the same work that git does as alternative.

If ceilings aren't important, I think this is about as fast as it gets.

helix-vcs/src/git.rs Outdated Show resolved Hide resolved
@pascalkuthe
Copy link
Member Author

I think it's worth noting that this way the git ceiling dir isn't respected, which might have been a silent benefit of the current discovery mechanism.

If it helps, in theory Byron/gitoxide#832 should end up doing pretty much the same work that git does as alternative.

If ceilings aren't important, I think this is about as fast as it gets.

Right now we set the ceiling dir always to None. For helix using cwd as a ceiling directory doesn't work so I couldn't really comeup with a portable ceiling dir previously. We could think about setting it to $HOME (or windows equivalent) I suppose

Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
@Byron
Copy link
Contributor

Byron commented Apr 26, 2023

True! Maybe it's the best choice anyway as it puts control over how to handle ceilings and crossing of filesystems into helix hands.

On the other hand, maybe a future step could be to adjust gix_discover::is_git|discover() to only expect worktrees for optimal FS access. Obviously its relevant to editors, maybe it's an API that should be available in gix-discover.

@@ -41,16 +48,8 @@ impl Git {
..gix::Permissions::default_for_level(gix::sec::Trust::Full)
});

let mut open_options = gix::discover::upwards::Options::default();
if let Some(ceiling_dir) = ceiling_dir {
open_options.ceiling_dirs = vec![ceiling_dir.to_owned()];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually recommend to not go ahead with this PR and instead use the new dot_git_only option. With it set to true the discovery can be optimal for this usecase, while making it easy to setup ceiling dirs and handle cross-filesystem checks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for taking this further, I will update this PR to use the new gitoxide version once that is released

@pascalkuthe pascalkuthe added S-waiting-on-pr Status: This is waiting on another PR to be merged first and removed S-waiting-on-review Status: Awaiting review from a maintainer. labels Apr 26, 2023
@pascalkuthe
Copy link
Member Author

Closing in favor of #6890

@pascalkuthe pascalkuthe removed this from the 23.04 milestone Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-vcs Area: Version control system interaction C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much S-waiting-on-pr Status: This is waiting on another PR to be merged first
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants