Patchwork [4,of,6] revlog: move chunk cache preload from revision to _chunks

login
register
mail settings
Submitter Siddharth Agarwal
Date Sept. 7, 2013, 8:40 p.m.
Message ID <59e9548119a2921c1c4c.1378586438@dev1091.prn1.facebook.com>
Download mbox | patch
Permalink /patch/2408/
State Accepted
Commit e17976978ee46fe45aaa78a728f5a9231a68e9ee
Headers show

Comments

Siddharth Agarwal - Sept. 7, 2013, 8:40 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1378533911 25200
#      Fri Sep 06 23:05:11 2013 -0700
# Node ID 59e9548119a2921c1c4c96dff96cd303eb19fd77
# Parent  8c9c2c14cdfb0dd708c5f2fdd793035b1f6c8466
revlog: move chunk cache preload from revision to _chunks

In case we don't have a cached text already, add the base rev to the list
passed to _chunks. In the cached case this also avoids unnecessarily preloading
the chunk for the cached rev.

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -859,6 +859,8 @@ 
         '''faster version of [self._chunk(rev) for rev in revs]
 
         Assumes that revs is in ascending order.'''
+        if not revs:
+            return []
         start = self.start
         length = self.length
         inline = self._inline
@@ -868,7 +870,8 @@ 
         l = []
         ladd = l.append
 
-        # XXX assume for now that chunkcache is preloaded
+        # preload the cache
+        self._chunkraw(revs[0], revs[-1])
         offset, data = self._chunkcache
 
         for rev in revs:
@@ -946,21 +949,22 @@ 
             else:
                 iterrev -= 1
             e = index[iterrev]
-        chain.reverse()
-        base = iterrev
 
         if iterrev == cachedrev:
             # cache hit
             text = self._cache[2]
+        else:
+            chain.append(iterrev)
+        chain.reverse()
 
         # drop cache to save memory
         self._cache = None
 
-        self._chunkraw(base, rev)
+        bins = self._chunks(chain)
         if text is None:
-            text = str(self._chunkbase(base))
+            text = str(bins[0])
+            bins = bins[1:]
 
-        bins = self._chunks(chain)
         text = mdiff.patches(text, bins)
 
         text = self._checkhash(text, node, rev)