Patchwork [14,of,14] obscache: skip updating outdated obscache obscache for readonly operation

login
register
mail settings
Submitter Boris Feld
Date July 9, 2017, 5:55 p.m.
Message ID <59528ec2969e10de1c3e.1499622926@FB>
Download mbox | patch
Permalink /patch/22175/
State Changes Requested
Headers show

Comments

Boris Feld - July 9, 2017, 5:55 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1496358960 -7200
#      Fri Jun 02 01:16:00 2017 +0200
# Node ID 59528ec2969e10de1c3eec16149b483083b89218
# Parent  7774ff78ef2e7433368184e7de743342b771b91c
# EXP-Topic obs-cache
obscache: skip updating outdated obscache obscache for readonly operation

During read only operation, we fallback to the old way of computing obsolescence
markers when we detect that the obscache is behind/invalid. This might happen
when both old and new clients touch the same repository.

This is a simple way to avoiding paying extra cache warming overhead without
making the cache write pattern more complex.

Patch

diff -r 7774ff78ef2e -r 59528ec2969e mercurial/obsolete.py
--- a/mercurial/obsolete.py	Sun Jul 09 03:56:12 2017 +0200
+++ b/mercurial/obsolete.py	Fri Jun 02 01:16:00 2017 +0200
@@ -1125,9 +1125,14 @@ 
     # good old version (parsing markers and checking them). We could add some
     # logic to fall back to the old way in these cases.
     obscache = repo.obsstore.obscache
-    obscache.update(repo) # ensure it is up to date:
-    isobs = obscache.get
-
+    if obscache.uptodate(repo) and repo.currenttransaction() is None:
+        hasnode = repo.obsstore.successors.__contains__
+        node = repo.changelog.node
+        def isobs(rev):
+            return hasnode(node(rev))
+    else:
+        obscache.update(repo) # ensure it is up to date:
+        isobs = obscache.get
     return set(r for r in notpublic if isobs(r))
 
 @cachefor('unstable')