/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugins/fastimport/cache_manager.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-17 00:47:52 UTC
  • mfrom: (7182 work)
  • mto: This revision was merged to the branch mainline in revision 7305.
  • Revision ID: jelmer@jelmer.uk-20181117004752-6ywampe5pfywlby4
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
 
65
65
class CacheManager(object):
66
66
 
67
 
    _small_blob_threshold = 25*1024
68
 
    _sticky_cache_size = 300*1024*1024
69
 
    _sticky_flushed_size = 100*1024*1024
 
67
    _small_blob_threshold = 25 * 1024
 
68
    _sticky_cache_size = 300 * 1024 * 1024
 
69
    _sticky_flushed_size = 100 * 1024 * 1024
70
70
 
71
71
    def __init__(self, info=None, verbose=False, inventory_cache_size=10):
72
72
        """Create a manager of caches.
147
147
        self._show_stats_for(self.marks, "revision-ids", note=note)
148
148
        # These aren't interesting so omit from the output, at least for now
149
149
        #self._show_stats_for(self._blobs, "other blobs", note=note)
150
 
        #self.reftracker.dump_stats(note=note)
 
150
        # self.reftracker.dump_stats(note=note)
151
151
 
152
152
    def _show_stats_for(self, a_dict, label, note, tuple_key=False):
153
153
        """Dump statistics about a given dictionary.
169
169
                size = size / 1024
170
170
                unit = 'G'
171
171
        note("    %-12s: %8.1f %s (%d %s)" % (label, size, unit, count,
172
 
            single_plural(count, "item", "items")))
 
172
                                              single_plural(count, "item", "items")))
173
173
 
174
174
    def clear_all(self):
175
175
        """Free up any memory used by the caches."""
183
183
        blobs = list(self._sticky_blobs)
184
184
        sticky_blobs = self._sticky_blobs
185
185
        total_blobs = len(sticky_blobs)
186
 
        blobs.sort(key=lambda k:len(sticky_blobs[k]))
 
186
        blobs.sort(key=lambda k: len(sticky_blobs[k]))
187
187
        if self._tempdir is None:
188
188
            tempdir = tempfile.mkdtemp(prefix='fastimport_blobs-')
189
189
            self._tempdir = tempdir
195
195
            # destroyed 'too late' for cleanup to actually occur. Probably a
196
196
            # combination of bzr's "die directly, don't clean up" and how
197
197
            # exceptions close the running stack.
 
198
 
198
199
            def exit_cleanup():
199
200
                small_blob = small_blob_ref()
200
201
                if small_blob is not None: