obshashrange: issue a warning if the cache takes a long time to load
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 30 Aug 2018 22:50:26 +0200
changeset 4055 555028f992eb
parent 4054 46cd437fd3d2
child 4056 235f15c40556
obshashrange: issue a warning if the cache takes a long time to load The -current- implementation of the obshashrange cache can get slow. This will be fixed eventually, in the mean time we inform people on large repository of what have been going on. Since we are about to enable obshashrange by default, we need to make sure nobody will have an (unexplained) bad surprise.
hgext3rd/evolve/stablerangecache.py
--- a/hgext3rd/evolve/stablerangecache.py	Fri Aug 31 14:26:37 2018 +0200
+++ b/hgext3rd/evolve/stablerangecache.py	Thu Aug 30 22:50:26 2018 +0200
@@ -31,6 +31,33 @@
 
 eh = exthelper.exthelper()
 
+LONG_WARNING_TIME = 60
+
+LONG_MESSAGE = """Stable range cache is taking a while to load
+
+Your repository is probably big.
+
+Stable range are used for discovery missing osbsolescence markers during
+exchange. While the algorithm we use can scale well for large repositories, the
+naive python implementation that you are using is not very efficient, the
+storage backend for that cache neither.
+
+This computation will finish in a finite amount of time, even for repositories
+with millions of revision and many merges. However It might take multiple tens
+of minutes to complete in such case.
+
+In the future, better implementation of the algorithm in a more appropriate
+language than Python will make it much faster. This data should also get
+exchanged between server and clients removing recomputation needs.
+
+In the mean time, got take a break while this cache is warming.
+
+See `hg help -e evolve` for details about how to control obsmarkers discovery and
+the update of related cache.
+
+--- Sorry for the delay ---
+"""
+
 class stablerangeondiskbase(stablerange.stablerangecached,
                             genericcaches.changelogsourcebase):
     """combine the generic stablerange cache usage with generic changelog one
@@ -56,7 +83,8 @@
         # progress report is showing up in the profile for small and fast
         # repository so we only update it every so often
         progress_each = 100
-        progress_last = time.time()
+        initial_time = progress_last = time.time()
+        warned_long = False
         heapify(rangeheap)
         while rangeheap:
             rangeid = heappop(rangeheap)
@@ -64,6 +92,8 @@
                 if not seen % progress_each:
                     # if a lot of time passed, report more often
                     progress_new = time.time()
+                    if not warned_long and LONG_WARNING_TIME < (progress_new - initial_time):
+                        repo.ui.warn(LONG_MESSAGE)
                     if (1 < progress_each) and (0.1 < progress_new - progress_last):
                         progress_each /= 10
                     ui.progress(_("filling stablerange cache"), seen,