# HG changeset patch # User Pierre-Yves David # Date 1494616891 -7200 # Node ID 2241433a77e543ee068039fa2fb9ad514decca93 # Parent 4b8b7fd135eb73bcb95d367a61b8fc542a3f8ebc obshashrange: warm the cache at the end of each transaction This will help having warmed cache for read only client. The warming is still imperfect in case of markers that trigger a reset, but we are in a better place than what we used to be. diff --git a/README b/README --- a/README +++ b/README @@ -119,6 +119,9 @@ - topic: have thg display topic name if possible, - obscache: more efficient update in the (rare) case of a transaction adding markers without changesets + - obshashrange-cache: update incrementally in the (common) case of a + transaction not affecting existing range, + - obshashrange-cache: keep the cache mostly warm after each transaction. 6.1.1 - in progress ------------------- diff --git a/hgext3rd/evolve/obsdiscovery.py b/hgext3rd/evolve/obsdiscovery.py --- a/hgext3rd/evolve/obsdiscovery.py +++ b/hgext3rd/evolve/obsdiscovery.py @@ -443,7 +443,10 @@ def get(self, rangeid): # revision should be covered by out tiprev # XXX should be a programming error - assert rangeid[0] <= self._cachekey[0] + # + # XXX there are issue with cache warming, we hack around it for now + if not getattr(self, '_updating', False): + assert rangeid[0] <= self._cachekey[0] value = super(_obshashcache, self).get(rangeid) if value is None and self._con is not None: @@ -469,6 +472,8 @@ # 1) new revisions does not get their entry updated (not update) # 2) if we detect markers affecting non-new revision we reset the cache + self._updating = True + revs = set(revs) rev = repo.changelog.nodemap.get # if we have a new markers affecting a node already covered by the @@ -484,6 +489,16 @@ self.clear(reset=True) break + # XXX the current reset is too strong we could just drop the affected range + + # XXX if we reset, we should warm the cache for existing heads (draft and public) + + # warm the cache for the new revs + for r in revs: + _obshashrange(repo, (r, 0)) + + del self._updating + @property def _fullcachekey(self): return (self._schemaversion, ) + self._cachekey