Changeset - 6fb68819e58e
[Not reviewed]
default
0 1 0
Eivind Tagseth - 8 years ago 2017-07-01 21:47:30
eivindt@gmail.com
git: improve performance working with git changesets

GitRepository._repo instantiates a new dulwich.repo.Repo on every usage,
rather than once at initialization time of GitRepository. As this involves a
lot of filesystem access, this is a costly operation.

Instead, let GitRepository.__init__ instantiate a dulwich.repo.Repo once,
and let GitRepository._repo just return it.

This improves performance significantly.
On test_graphmod_git, performance improves from 6.29 seconds median to 3.06
seconds median.

[Thomas De Schampheleire: extend improvement to _all_ usage of
GitRepository._repo instead of only some. To limit the delta, retain the
_repo property but simply return self.repo.]
1 file changed with 4 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/vcs/backends/git/repository.py
Show inline comments
 
@@ -59,8 +59,8 @@ class GitRepository(BaseRepository):
 
                 update_after_clone=False, bare=False):
 

	
 
        self.path = safe_unicode(abspath(repo_path))
 
        repo = self._get_repo(create, src_url, update_after_clone, bare)
 
        self.bare = repo.bare
 
        self.repo = self._get_repo(create, src_url, update_after_clone, bare)
 
        self.bare = self.repo.bare
 

	
 
    @property
 
    def _config_files(self):
 
@@ -72,7 +72,7 @@ class GitRepository(BaseRepository):
 

	
 
    @property
 
    def _repo(self):
 
        return Repo(self.path)
 
        return self.repo
 

	
 
    @property
 
    def head(self):
 
@@ -239,7 +239,7 @@ class GitRepository(BaseRepository):
 
                else:
 
                    return Repo.init(self.path)
 
            else:
 
                return self._repo
 
                return Repo(self.path)
 
        except (NotGitRepository, OSError) as err:
 
            raise RepositoryError(err)
 

	
0 comments (0 inline, 0 general)