diff options
author | Lars Wirzenius <liw@xander> | 2010-12-26 16:32:00 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@xander> | 2010-12-26 16:32:00 +0200 |
commit | 4ef1e4e4f478b28a6bf679f07756ecc99e7f4bbc (patch) | |
tree | 1d3563689da63a75f1e38e8085dfb8225ef29118 | |
parent | 0d7b4ae7b46f2e4ec5d3b64fe801de6015891665 (diff) | |
download | obnam-4ef1e4e4f478b28a6bf679f07756ecc99e7f4bbc.tar.gz |
Dump memory profiles while backing up files.
Also, make dumping work at end of backup run by removing now-uninteresting
information from it.
Finally, only dump if user requests it.
-rw-r--r-- | obnamlib/plugins/backup_plugin.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/obnamlib/plugins/backup_plugin.py b/obnamlib/plugins/backup_plugin.py index cddae53b..e3032e79 100644 --- a/obnamlib/plugins/backup_plugin.py +++ b/obnamlib/plugins/backup_plugin.py @@ -14,6 +14,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. +import gc import logging import os import re @@ -142,16 +143,13 @@ class BackupPlugin(obnamlib.ObnamPlugin): return rss def dump_memory_profile(self, msg): - import gc + kind = self.app.config['dump-memory-profile'] + if kind == 'none': + return logging.debug('dumping memory profiling data: %s' % msg) logging.debug('VmRSS: %s KiB' % self.vmrss()) logging.debug('# objects: %d' % len(gc.get_objects())) logging.debug('# garbage: %d' % len(gc.garbage)) - x = self.store.client.forest.node_store.cache - logging.debug('Store.client.forest.node_store.cache: ' - 'max_size=%d len(_heap)=%d' % - (x.max_size, len(x._heap))) - kind = self.app.config['dump-memory-profile'] if kind == 'heapy': from guppy import hpy h = hpy() @@ -258,11 +256,14 @@ class BackupPlugin(obnamlib.ObnamPlugin): chunkids.append(self.backup_file_chunk(data)) if len(chunkids) >= obnamlib.DEFAULT_CHUNKIDS_PER_GROUP: self.store.append_file_chunks(filename, chunkids) + self.dump_memory_profile('after appending some chunkids') chunkids = [] self.app.hooks.call('progress-data-uploaded', len(data)) f.close() if chunkids: self.store.append_file_chunks(filename, chunkids) + self.dump_memory_profile('at end of file content backup for %s' % + filename) def backup_file_chunk(self, data): '''Back up a chunk of data by putting it into the store.''' |