From 1e1a7d0623459807d6f1e871492147f971f7540c Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 30 Aug 2018 15:29:51 +0200 Subject: git: add Static option to PlainOpen Also adds Static configuration to Storage and DotGit. This option means that the git repository is not expected to be modified while open and enables some optimizations. Each time a file is accessed the storer tries to open an object file for the requested hash. When this is done for a lot of objects it is expensive. With Static option a list of object files is generated the first time an object is accessed and used to check if exists instead of using system calls. A similar optimization is done for packfiles. Signed-off-by: Javi Fontan --- storage/filesystem/storage_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'storage/filesystem/storage_test.go') diff --git a/storage/filesystem/storage_test.go b/storage/filesystem/storage_test.go index 4d9ba6f..d7ebf71 100644 --- a/storage/filesystem/storage_test.go +++ b/storage/filesystem/storage_test.go @@ -26,6 +26,10 @@ func (s *StorageSuite) SetUpTest(c *C) { storage, err := NewStorage(osfs.New(s.dir)) c.Assert(err, IsNil) + setUpTest(s, c, storage) +} + +func setUpTest(s *StorageSuite, c *C, storage *Storage) { // ensure that right interfaces are implemented var _ storer.EncodedObjectStorer = storage var _ storer.IndexStorer = storage @@ -51,3 +55,17 @@ func (s *StorageSuite) TestNewStorageShouldNotAddAnyContentsToDir(c *C) { c.Assert(err, IsNil) c.Assert(fis, HasLen, 0) } + +type StorageStaticSuite struct { + StorageSuite +} + +var _ = Suite(&StorageStaticSuite{}) + +func (s *StorageStaticSuite) SetUpTest(c *C) { + s.dir = c.MkDir() + storage, err := NewStorageWithOptions(osfs.New(s.dir), StorageOptions{Static: true}) + c.Assert(err, IsNil) + + setUpTest(&s.StorageSuite, c, storage) +} -- cgit From 82945e31dd8bce5fc51d4fd16d696a6d326e5f44 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 30 Aug 2018 18:33:37 +0200 Subject: git, storer: use a common storer.Options for storer and PlainOpen Signed-off-by: Javi Fontan --- storage/filesystem/storage_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'storage/filesystem/storage_test.go') diff --git a/storage/filesystem/storage_test.go b/storage/filesystem/storage_test.go index d7ebf71..23628c7 100644 --- a/storage/filesystem/storage_test.go +++ b/storage/filesystem/storage_test.go @@ -64,7 +64,9 @@ var _ = Suite(&StorageStaticSuite{}) func (s *StorageStaticSuite) SetUpTest(c *C) { s.dir = c.MkDir() - storage, err := NewStorageWithOptions(osfs.New(s.dir), StorageOptions{Static: true}) + storage, err := NewStorageWithOptions( + osfs.New(s.dir), + storer.Options{Static: true}) c.Assert(err, IsNil) setUpTest(&s.StorageSuite, c, storage) -- cgit From cf626677508238893c7c88c3c786a02f17afcc4c Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Fri, 31 Aug 2018 14:56:23 +0200 Subject: plumbing/storer: rename Static option to ExclusiveAccess Signed-off-by: Javi Fontan --- storage/filesystem/storage_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage/filesystem/storage_test.go') diff --git a/storage/filesystem/storage_test.go b/storage/filesystem/storage_test.go index 23628c7..11bf4fc 100644 --- a/storage/filesystem/storage_test.go +++ b/storage/filesystem/storage_test.go @@ -66,7 +66,7 @@ func (s *StorageStaticSuite) SetUpTest(c *C) { s.dir = c.MkDir() storage, err := NewStorageWithOptions( osfs.New(s.dir), - storer.Options{Static: true}) + storer.Options{ExclusiveAccess: true}) c.Assert(err, IsNil) setUpTest(&s.StorageSuite, c, storage) -- cgit From 874f669becc25489081306bbbcbbc27b970f6295 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Mon, 3 Sep 2018 19:40:22 +0200 Subject: storage/filesystem: move Options to filesytem and dotgit Signed-off-by: Javi Fontan --- storage/filesystem/storage_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'storage/filesystem/storage_test.go') diff --git a/storage/filesystem/storage_test.go b/storage/filesystem/storage_test.go index 11bf4fc..7f85ef5 100644 --- a/storage/filesystem/storage_test.go +++ b/storage/filesystem/storage_test.go @@ -56,17 +56,17 @@ func (s *StorageSuite) TestNewStorageShouldNotAddAnyContentsToDir(c *C) { c.Assert(fis, HasLen, 0) } -type StorageStaticSuite struct { +type StorageExclusiveSuite struct { StorageSuite } -var _ = Suite(&StorageStaticSuite{}) +var _ = Suite(&StorageExclusiveSuite{}) -func (s *StorageStaticSuite) SetUpTest(c *C) { +func (s *StorageExclusiveSuite) SetUpTest(c *C) { s.dir = c.MkDir() storage, err := NewStorageWithOptions( osfs.New(s.dir), - storer.Options{ExclusiveAccess: true}) + Options{ExclusiveAccess: true}) c.Assert(err, IsNil) setUpTest(&s.StorageSuite, c, storage) -- cgit