Patchwork D9235: revlog: use LRU for the chain cache

login
register
mail settings
Submitter phabricator
Date Oct. 21, 2020, 12:18 a.m.
Message ID <differential-rev-PHID-DREV-u4sjteuorulmm6jasyze-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47501/
State Superseded
Headers show

Comments

phabricator - Oct. 21, 2020, 12:18 a.m.
joerg.sonnenberger created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  For a large repository, this reduces the number of filelog instances and
  associated data a lot. For a 1% speed penalty, it reduces peak RSS by
  20% for the full NetBSD test repository.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9235

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS




To: joerg.sonnenberger, indygreg, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -668,7 +668,7 @@ 
         if not self._chunkcache:
             self._chunkclear()
         # revnum -> (chain-length, sum-delta-length)
-        self._chaininfocache = {}
+        self._chaininfocache = util.lrucachedict(500)
         # revlog header -> revlog compressor
         self._decompressors = {}
 
@@ -2557,7 +2557,7 @@ 
 
         # then reset internal state in memory to forget those revisions
         self._revisioncache = None
-        self._chaininfocache = {}
+        self._chaininfocache = util.lrucachedict(500)
         self._chunkclear()
 
         del self.index[rev:-1]