Patchwork [evolve-ext] evolve: cache marker encoding to avoid performance degradation

login
register
mail settings
Submitter Mathias De Maré
Date March 2, 2015, 7:30 p.m.
Message ID <4e124d92c742084146ce.1425324630@mathias-Latitude-E6540>
Download mbox | patch
Permalink /patch/7880/
State Accepted
Headers show

Comments

Mathias De Maré - March 2, 2015, 7:30 p.m.
# HG changeset patch
# User Mathias De Maré <mathias.demare@gmail.com>
# Date 1425323520 -3600
#      Mon Mar 02 20:12:00 2015 +0100
# Branch stable
# Node ID 4e124d92c742084146ce13c0c23957b34c5d5fad
# Parent  47f3bdbe0d9c77f7580ca62bfd453e870e3ba325
evolve: cache marker encoding to avoid performance degradation

The main overhead in bug 4518 is caused by calculating relevant markers
and encoding markers into the correct format.

Calculating relevant markers takes (worst case) ~ 0.12 seconds.
Encoding markers takes (worst case) ~ 0.06 seconds.

Caching encoded markers takes care of the second part and
speeds up cloning in bug 4518 by about 35%.
Pierre-Yves David - March 2, 2015, 8:24 p.m.
On 03/02/2015 07:30 PM, mathias.demare@gmail.com wrote:
> # HG changeset patch
> # User Mathias De Maré <mathias.demare@gmail.com>
> # Date 1425323520 -3600
> #      Mon Mar 02 20:12:00 2015 +0100
> # Branch stable
> # Node ID 4e124d92c742084146ce13c0c23957b34c5d5fad
> # Parent  47f3bdbe0d9c77f7580ca62bfd453e870e3ba325
> evolve: cache marker encoding to avoid performance degradation

Does not hurt. Pushed to main.

Patch

diff -r 47f3bdbe0d9c -r 4e124d92c742 hgext/evolve.py
--- a/hgext/evolve.py	Fri Jan 30 22:05:07 2015 +0000
+++ b/hgext/evolve.py	Mon Mar 02 20:12:00 2015 +0100
@@ -2729,6 +2729,7 @@ 
 def _obsrelsethashtree(repo):
     cache = []
     unfi = repo.unfiltered()
+    markercache = {}
     for i in unfi:
         ctx = unfi[i]
         entry = 0
@@ -2745,7 +2746,11 @@ 
                 sha.update(p)
         tmarkers = repo.obsstore.relevantmarkers([ctx.node()])
         if tmarkers:
-            bmarkers = [obsolete._fm0encodeonemarker(m) for m in tmarkers]
+            bmarkers = []
+            for m in tmarkers:
+                if not m in markercache:
+                    markercache[m] = obsolete._fm0encodeonemarker(m)
+                bmarkers.append(markercache[m])
             bmarkers.sort()
             for m in bmarkers:
                 entry += 1