diff options
author | zeripath <art27@cantab.net> | 2021-05-02 02:16:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-02 03:16:08 +0200 |
commit | a926ff919db105f7ceed63bb858b6b80d96157dc (patch) | |
tree | 417fd759f635b89d7299e44a5b904af77cd0d972 /modules/git/last_commit_cache_nogogit.go | |
parent | fda2e4549fcfb4a08977c91520be44d6e4442f26 (diff) | |
download | gitea-a926ff919db105f7ceed63bb858b6b80d96157dc.tar.gz gitea-a926ff919db105f7ceed63bb858b6b80d96157dc.zip |
Performance improvement for last commit cache and show-ref (#15455)
* Improve performance when there are multiple commits in the last commit cache
* read refs directly if we can
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/git/last_commit_cache_nogogit.go')
-rw-r--r-- | modules/git/last_commit_cache_nogogit.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/modules/git/last_commit_cache_nogogit.go b/modules/git/last_commit_cache_nogogit.go index 0e52d16538..0a1babb112 100644 --- a/modules/git/last_commit_cache_nogogit.go +++ b/modules/git/last_commit_cache_nogogit.go @@ -7,6 +7,8 @@ package git import ( + "bufio" + "io" "path" ) @@ -34,7 +36,7 @@ func NewLastCommitCache(repoPath string, gitRepo *Repository, ttl func() int64, } // Get get the last commit information by commit id and entry path -func (c *LastCommitCache) Get(ref, entryPath string) (interface{}, error) { +func (c *LastCommitCache) Get(ref, entryPath string, wr *io.PipeWriter, rd *bufio.Reader) (interface{}, error) { v := c.cache.Get(c.getCacheKey(c.repoPath, ref, entryPath)) if vs, ok := v.(string); ok { log("LastCommitCache hit level 1: [%s:%s:%s]", ref, entryPath, vs) @@ -46,7 +48,10 @@ func (c *LastCommitCache) Get(ref, entryPath string) (interface{}, error) { if err != nil { return nil, err } - commit, err := c.repo.getCommit(id) + if _, err := wr.Write([]byte(vs + "\n")); err != nil { + return nil, err + } + commit, err := c.repo.getCommitFromBatchReader(rd, id) if err != nil { return nil, err } |