diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-07-27 14:55:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-27 14:55:47 +0200 |
commit | 8c57f96d4678087e06035095e67ad1239d6509ce (patch) | |
tree | a1468ab8a942435435c644abdc9bac3338990bc2 /storage/filesystem | |
parent | 854ffa16f650706200a6ebb5505bb448b5c64035 (diff) | |
parent | ae1c4f3df729c3a7fed4cd5a1f530c95d640497a (diff) | |
download | go-git-8c57f96d4678087e06035095e67ad1239d6509ce.tar.gz |
Merge pull request #514 from smola/use-cache-delta
cache: reuse object cache for delta resolution, use LRU policy
Diffstat (limited to 'storage/filesystem')
-rw-r--r-- | storage/filesystem/object.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/storage/filesystem/object.go b/storage/filesystem/object.go index e235b33..6dd910b 100644 --- a/storage/filesystem/object.go +++ b/storage/filesystem/object.go @@ -5,6 +5,7 @@ import ( "os" "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/cache" "gopkg.in/src-d/go-git.v4/plumbing/format/idxfile" "gopkg.in/src-d/go-git.v4/plumbing/format/objfile" "gopkg.in/src-d/go-git.v4/plumbing/format/packfile" @@ -16,14 +17,20 @@ import ( "gopkg.in/src-d/go-billy.v3" ) +const DefaultMaxDeltaBaseCacheSize = 92 * cache.MiByte + type ObjectStorage struct { + // DeltaBaseCache is an object cache uses to cache delta's bases when + DeltaBaseCache cache.Object + dir *dotgit.DotGit index map[plumbing.Hash]*packfile.Index } func newObjectStorage(dir *dotgit.DotGit) (ObjectStorage, error) { s := ObjectStorage{ - dir: dir, + DeltaBaseCache: cache.NewObjectLRU(DefaultMaxDeltaBaseCacheSize), + dir: dir, } return s, nil @@ -198,6 +205,7 @@ func (s *ObjectStorage) getFromPackfile(h plumbing.Hash) (plumbing.EncodedObject return nil, err } + d.DeltaBaseCache = s.DeltaBaseCache d.SetIndex(s.index[pack]) obj, err := d.DecodeObjectAt(offset) return obj, err |