hgext3rd/evolve/stablerange.py
changeset 2504 d95006fe4dd0
parent 2503 cdf6a0e028c0
child 2505 7fd55c5efffb
--- a/hgext3rd/evolve/stablerange.py	Tue May 30 11:12:12 2017 +0200
+++ b/hgext3rd/evolve/stablerange.py	Tue May 30 11:12:02 2017 +0200
@@ -241,7 +241,7 @@
 
 class stablerange(object):
 
-    def __init__(self):
+    def __init__(self, lrusize=2000):
         # The point up to which we have data in cache
         self._tiprev = None
         self._tipnode = None
@@ -254,10 +254,10 @@
         # and then use the relevant top most part. This order is going to be
         # the same for all ranges headed at the same merge. So we cache these
         # value to reuse them accross the same invocation.
-        self._stablesortcache = {}
+        self._stablesortcache = util.lrucachedict(lrusize)
         # something useful to compute the above
         # mergerev -> stablesort, length
-        self._stablesortprepared = {}
+        self._stablesortprepared = util.lrucachedict(lrusize)
         # caching parent call # as we do so many of them
         self._parentscache = {}
         # The first part of the stable sorted list of revision of a merge will
@@ -740,7 +740,9 @@
     _schemaversion = 0
 
     def __init__(self, repo):
-        super(sqlstablerange, self).__init__()
+        lrusize = repo.ui.configint('experimental', 'obshashrange.lru-size',
+                                    2000)
+        super(sqlstablerange, self).__init__(lrusize=lrusize)
         self._vfs = repo.vfs
         self._path = repo.vfs.join('cache/evoext_stablerange_v0.sqlite')
         self._cl = repo.unfiltered().changelog # (okay to keep an old one)