From d8039d3432118597555a249d22e5f75b6808792a Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 2 Jul 2016 18:00:16 +0000 Subject: Drop r/o caches while forgetting to reduce memory use --- obnamlib/delegator.py | 4 ++++ obnamlib/fmt_ga/client.py | 9 +++++++++ obnamlib/fmt_ga/tree.py | 3 +++ obnamlib/repo_interface.py | 10 ++++++++++ 4 files changed, 26 insertions(+) diff --git a/obnamlib/delegator.py b/obnamlib/delegator.py index e5cf9b66..26840774 100644 --- a/obnamlib/delegator.py +++ b/obnamlib/delegator.py @@ -178,6 +178,10 @@ class RepositoryDelegator(obnamlib.RepositoryInterface): client = self._lookup_client(client_name) client.flush() + def flush_ro_client(self, client_name): + client = self._lookup_client(client_name) + client.flush_ro() + def commit_client(self, client_name): self._require_got_client_lock(client_name) client = self._lookup_client(client_name) diff --git a/obnamlib/fmt_ga/client.py b/obnamlib/fmt_ga/client.py index 85417d04..f60afb59 100644 --- a/obnamlib/fmt_ga/client.py +++ b/obnamlib/fmt_ga/client.py @@ -77,6 +77,12 @@ class GAClient(object): def flush(self): self._save_file_metadata() + def flush_ro(self): + for gen in self._generations: + metadata = gen.get_file_metadata() + metadata.flush_ro() + gen.set_root_object_id(metadata.get_root_object_id()) + def commit(self): self._load_data() self._finish_current_generation_if_any() @@ -509,6 +515,9 @@ class GAFileMetadata(object): assert len(self._added_files) == 0 self._tree.flush() + def flush_ro(self): + self._tree.flush_ro() + def __iter__(self): for filename in self._added_files: yield filename diff --git a/obnamlib/fmt_ga/tree.py b/obnamlib/fmt_ga/tree.py index a10a7c48..dc5cdf9b 100644 --- a/obnamlib/fmt_ga/tree.py +++ b/obnamlib/fmt_ga/tree.py @@ -136,6 +136,9 @@ class GATree(object): self._blob_store.flush() self._cache.clear() + def flush_ro(self): # pragma: no cover + self._cache.clear() + def _fixup_subdir_refs(self, pathname): dir_obj = self._cache.get(pathname) assert dir_obj is not None, 'expected %s in cache' % pathname diff --git a/obnamlib/repo_interface.py b/obnamlib/repo_interface.py index 26bc1d34..ab8d6960 100644 --- a/obnamlib/repo_interface.py +++ b/obnamlib/repo_interface.py @@ -553,6 +553,16 @@ class RepositoryInterface(object): ''' + def flush_ro_client(self, client_name): + '''Flush cached read-only data from client. + + This does not require the client to be locked. + + This is a NOP, unless the a specific repository format gives + it meaning. + + ''' + def commit_client(self, client_name): '''Commit changes to client and DO NOT unlock it. -- cgit v1.2.1