Patchwork [3,of,5,RFC] revlog: compute length of compressed deltas along with chain length

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 12, 2014, 11:09 p.m.
Message ID <69954f49716d0bdd3094.1415833750@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/6694/
State Accepted
Commit 40e0067899d471a06e931b33fda7dd27e8a8bacc
Headers show

Comments

Siddharth Agarwal - Nov. 12, 2014, 11:09 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1415764476 28800
#      Tue Nov 11 19:54:36 2014 -0800
# Node ID 69954f49716d0bdd3094be4b4b7b06da155a7704
# Parent  0b81a4a0fe70072919c1f3fd4b6cb6f9dbeb4e53
revlog: compute length of compressed deltas along with chain length

In upcoming patches to the revlog, we're going to split up the notions of
bounding I/O and bounding CPU.

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -354,19 +354,25 @@ 
             base = index[rev][3]
         return base
     def chainlen(self, rev):
+        return self._chaininfo(rev)[0]
+    def _chaininfo(self, rev):
         index = self.index
         generaldelta = self._generaldelta
         iterrev = rev
         e = index[iterrev]
         clen = 0
+        compresseddeltalen = 0
         while iterrev != e[3]:
             clen += 1
+            compresseddeltalen += e[1]
             if generaldelta:
                 iterrev = e[3]
             else:
                 iterrev -= 1
             e = index[iterrev]
-        return clen
+        # add text length of base since decompressing that also takes work
+        compresseddeltalen += e[1]
+        return clen, compresseddeltalen
     def flags(self, rev):
         return self.index[rev][0] & 0xFFFF
     def rawsize(self, rev):