changeset 51009:ffb393dd5999

perf: ensure all readlog's reading is done within a `reading` context We are about to enforce this at the revlog level, so we update the perf code in advance.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 25 Sep 2023 11:23:38 +0200
parents 2f1967ffefb1
children c690d2cc7f36
files contrib/perf.py
diffstat 1 files changed, 32 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/perf.py	Mon Sep 25 11:13:44 2023 +0200
+++ b/contrib/perf.py	Mon Sep 25 11:23:38 2023 +0200
@@ -3759,10 +3759,24 @@
             datafile = getattr(rl, 'datafile', getattr(rl, 'datafile'))
             yield getsvfs(repo)(datafile)
 
+    if getattr(rl, 'reading', None) is not None:
+
+        @contextlib.contextmanager
+        def lazy_reading(rl):
+            with rl.reading():
+                yield
+
+    else:
+
+        @contextlib.contextmanager
+        def lazy_reading(rl):
+            yield
+
     def doread():
         rl.clearcaches()
         for rev in revs:
-            segmentforrevs(rev, rev)
+            with lazy_reading(rl):
+                segmentforrevs(rev, rev)
 
     def doreadcachedfh():
         rl.clearcaches()
@@ -3776,7 +3790,8 @@
 
     def doreadbatch():
         rl.clearcaches()
-        segmentforrevs(revs[0], revs[-1])
+        with lazy_reading(rl):
+            segmentforrevs(revs[0], revs[-1])
 
     def doreadbatchcachedfh():
         rl.clearcaches()
@@ -3883,6 +3898,19 @@
     node = r.lookup(rev)
     rev = r.rev(node)
 
+    if getattr(r, 'reading', None) is not None:
+
+        @contextlib.contextmanager
+        def lazy_reading(r):
+            with r.reading():
+                yield
+
+    else:
+
+        @contextlib.contextmanager
+        def lazy_reading(r):
+            yield
+
     def getrawchunks(data, chain):
         start = r.start
         length = r.length
@@ -3916,7 +3944,8 @@
         if not cache:
             r.clearcaches()
         for item in slicedchain:
-            segmentforrevs(item[0], item[-1])
+            with lazy_reading(r):
+                segmentforrevs(item[0], item[-1])
 
     def doslice(r, chain, size):
         for s in slicechunk(r, chain, targetsize=size):