aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2017-07-24 14:04:51 +0200
committerSantiago M. Mola <santi@mola.io>2017-07-27 14:21:51 +0200
commitb3fc7760ba332306bb1faa64c8a101a2e605077f (patch)
tree7c9ada0c0199d8b2647e677793d06c27006f7093 /storage/filesystem
parentf07672f5c3cad2e73596ab3d7ca16660f6881df6 (diff)
downloadgo-git-b3fc7760ba332306bb1faa64c8a101a2e605077f.tar.gz
storage/filesystem: reuse delta cache
Reuse delta base object cache for packfile decoders across multiple instances.
Diffstat (limited to 'storage/filesystem')
-rw-r--r--storage/filesystem/object.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/storage/filesystem/object.go b/storage/filesystem/object.go
index e235b33..4a67a00 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.NewObjectFIFO(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