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

login
register
mail settings
Submitter Gregory Szorc
Date Sept. 25, 2016, 8:42 p.m.
Message ID <977c6ae3156075704ff6.1474836134@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/16784/
State Accepted
Headers show

Comments

Gregory Szorc - Sept. 25, 2016, 8:42 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@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.

Patch

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: