changeset 2503:cdf6a0e028c0

stablerange: report progress more often in slow case For small repositories the time spent in progress was problematic. However on large repository it quickly becomes negligible, so we add a way to detect this case and report more often in this case.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 30 May 2017 11:12:12 +0200
parents d5db7464676d
children d95006fe4dd0
files hgext3rd/evolve/stablerange.py
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/stablerange.py	Mon May 29 14:03:31 2017 +0200
+++ b/hgext3rd/evolve/stablerange.py	Tue May 30 11:12:12 2017 +0200
@@ -304,12 +304,21 @@
 
         original = set(rangeheap)
         seen = 0
+        # progress report is showing up in the profile for small and fast
+        # repository so we build that complicated work around.
+        progress_each = 100
+        progress_last = time.time()
         heapify(rangeheap)
         while rangeheap:
             value = heappop(rangeheap)
             if value in original:
-                if not seen % 1000:
+                if not seen % progress_each:
+                    # if a lot of time passed, report more often
+                    progress_new = time.time()
+                    if (1 < progress_each) and (0.1 < progress_new - progress_last):
+                        progress_each /= 10
                     ui.progress(_("filling stablerange cache"), seen, total=nbrevs)
+                    progress_last = progress_new
                 seen += 1
                 original.remove(value) # might have been added from other source
             __, rangeid = value