stablerange: use last recently used caching for revisions associated to ranges
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 30 May 2017 11:12:02 +0200
changeset 2504 d95006fe4dd0
parent 2503 cdf6a0e028c0
child 2505 7fd55c5efffb
stablerange: use last recently used caching for revisions associated to ranges This does not make things faster but at least it make them able to finish on large repositories.
README
hgext3rd/evolve/__init__.py
hgext3rd/evolve/stablerange.py
--- a/README	Tue May 30 11:12:12 2017 +0200
+++ b/README	Tue May 30 11:12:02 2017 +0200
@@ -122,6 +122,8 @@
  - template: add a 'precursors' template that display the closests precursors of changesets
  - template: add a 'successors' template that display the closests successors of changesets
  - template: add a 'obsfate' template that display how a changeset has evolved
+ - new discovery experiment: add options to restrict memory consumption on
+   large repository (see "hg help -e evolve" for details).
 
 6.2.2 - in progress
 -------------------
--- a/hgext3rd/evolve/__init__.py	Tue May 30 11:12:12 2017 +0200
+++ b/hgext3rd/evolve/__init__.py	Tue May 30 11:12:02 2017 +0200
@@ -78,6 +78,13 @@
     [extensions]
     blackbox =
 
+Finally some extra option are available to help tame the experimental
+implementation of some of the algorithms:
+
+    [experimental]
+    # restrict cache size to reduce memory consumption
+    obshashrange.lru-size = 2000 # default is 2000
+
 Effect Flag Experiment
 ======================
 
--- 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)