[PATCH 2 of 5] revlog: document high frequency of code execution

Gregory Szorc gregory.szorc at gmail.com
Sun Sep 25 16:42:14 EDT 2016


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1472095138 25200
#      Wed Aug 24 20:18:58 2016 -0700
# Node ID 977c6ae3156075704ff6b925733e726587f3f983
# Parent  74301e44b7398b9c6e3baf4944d0aa99c5979ac4
revlog: document high frequency of code execution

Recording my notes while working on performance optimization.

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1466,16 +1466,20 @@ class revlog(object):
             textlen = mdiff.patchedsize(self.rawsize(cachedelta[0]),
                                         cachedelta[1])
         else:
             textlen = len(text)
 
         # should we try to build a delta?
         if prev != nullrev:
             tested = set()
+            # This condition is true most of the time when processing
+            # changegroup data into a generaldelta repo. The only time it
+            # isn't true is if this is the first revision in a delta chain
+            # or if ``format.generaldelta=true`` disabled ``lazydeltabase``.
             if cachedelta and self._generaldelta and self._lazydeltabase:
                 # Assume what we received from the server is a good choice
                 # build delta will reuse the cache
                 candidatedelta = builddelta(cachedelta[0])
                 tested.add(cachedelta[0])
                 if self._isgooddelta(candidatedelta, textlen):
                     delta = candidatedelta
             if delta is None and self._generaldelta:


More information about the Mercurial-devel mailing list