summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-07-19 15:05:54 +0300
committerLars Wirzenius <liw@liw.fi>2015-07-19 15:05:54 +0300
commit2727bbca32cad2b0e16e6f58578e4c7e126415fd (patch)
tree381992d1d99654f398df060f1b9226203e6f64ab
parent96f3482abb08e67caebacb65a555fbf0e4d9c2ae (diff)
downloadobnam-2727bbca32cad2b0e16e6f58578e4c7e126415fd.tar.gz
Split chunk and DIR object cache sizes
-rw-r--r--obnamlib/__init__.py5
-rw-r--r--obnamlib/blob_store.py5
-rw-r--r--obnamlib/fmt_ga/chunk_store.py2
-rw-r--r--obnamlib/fmt_ga/client.py1
4 files changed, 11 insertions, 2 deletions
diff --git a/obnamlib/__init__.py b/obnamlib/__init__.py
index 74536e2f..c7eb347c 100644
--- a/obnamlib/__init__.py
+++ b/obnamlib/__init__.py
@@ -53,7 +53,10 @@ DEFAULT_LRU_SIZE = 256
DEFAULT_CHUNKIDS_PER_GROUP = 1024
DEFAULT_NAGIOS_WARN_AGE = '27h'
DEFAULT_NAGIOS_CRIT_AGE = '8d'
-DEFAULT_BAG_CACHE_BYTES = 256 * 1024**2
+
+_MEBIBYTE = 1024**2
+DEFAULT_DIR_OBJECT_CACHE_BYTES = 256 * _MEBIBYTE
+DEFAULT_CHUNK_CACHE_BYTES = 1 * _MEBIBYTE
# The following values have been determined empirically on a laptop
# with an encrypted ext4 filesystem. Other values might be better for
diff --git a/obnamlib/blob_store.py b/obnamlib/blob_store.py
index bf26dcd4..33e2d1af 100644
--- a/obnamlib/blob_store.py
+++ b/obnamlib/blob_store.py
@@ -26,7 +26,7 @@ class BlobStore(object):
self._bag = None
self._max_bag_size = 0
self._cached_blobs = BlobCache()
- self._cached_blobs.set_max_bytes(obnamlib.DEFAULT_BAG_CACHE_BYTES)
+ self._cached_blobs.set_max_bytes(0)
def set_bag_store(self, bag_store):
self._bag_store = bag_store
@@ -34,6 +34,9 @@ class BlobStore(object):
def set_max_bag_size(self, max_bag_size):
self._max_bag_size = max_bag_size
+ def set_max_cache_bytes(self, max_bytes): # pragma: no cover
+ self._cached_blobs.set_max_bytes(max_bytes)
+
def get_blob(self, blob_id):
bag_id, index = obnamlib.parse_object_id(blob_id)
if self._bag and bag_id == self._bag.get_id():
diff --git a/obnamlib/fmt_ga/chunk_store.py b/obnamlib/fmt_ga/chunk_store.py
index c0767dc0..3740d912 100644
--- a/obnamlib/fmt_ga/chunk_store.py
+++ b/obnamlib/fmt_ga/chunk_store.py
@@ -39,6 +39,8 @@ class GAChunkStore(object):
self._bag_store.set_location(fs, self._dirname)
self._blob_store = obnamlib.BlobStore()
self._blob_store.set_bag_store(self._bag_store)
+ self._blob_store.set_max_cache_bytes(
+ obnamlib.DEFAULT_CHUNK_CACHE_BYTES)
if self._max_chunk_size is not None:
self._blob_store.set_max_bag_size(self._max_chunk_size)
diff --git a/obnamlib/fmt_ga/client.py b/obnamlib/fmt_ga/client.py
index 2cca15cb..442564a1 100644
--- a/obnamlib/fmt_ga/client.py
+++ b/obnamlib/fmt_ga/client.py
@@ -78,6 +78,7 @@ class GAClient(object):
blob_store = obnamlib.BlobStore()
blob_store.set_bag_store(bag_store)
blob_store.set_max_bag_size(obnamlib.DEFAULT_NODE_SIZE)
+ blob_store.set_max_cache_bytes(obnamlib.DEFAULT_DIR_OBJECT_CACHE_BYTES)
return blob_store
def _save_per_client_data(self):