From cce46a3d8ba1bf2118da028b4c14b518cc03bfe1 Mon Sep 17 00:00:00 2001 From: cloudhead Date: Mon, 13 May 2024 12:58:38 +0200 Subject: [PATCH] Try to improve performance of repository open By using `open_ext` with `BARE`, we defer loading of the Git config, which has been shown to be expensive. --- radicle/src/storage/git.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/radicle/src/storage/git.rs b/radicle/src/storage/git.rs index 1fb596f3..9a196b84 100644 --- a/radicle/src/storage/git.rs +++ b/radicle/src/storage/git.rs @@ -374,7 +374,14 @@ pub enum Validation { impl Repository { /// Open an existing repository. pub fn open>(path: P, id: RepoId) -> Result { - let backend = git2::Repository::open_bare(path.as_ref())?; + let backend = git2::Repository::open_ext( + path.as_ref(), + git2::RepositoryOpenFlags::empty() + | git2::RepositoryOpenFlags::BARE + | git2::RepositoryOpenFlags::NO_DOTGIT + | git2::RepositoryOpenFlags::NO_SEARCH, + &[] as &[&std::ffi::OsStr], + )?; Ok(Self { id, backend }) }