[PATCH 6 of 9 V3] manifest: change manifestlog mancache to be directory based
Durham Goode
durham at fb.com
Tue Sep 20 19:47:41 EDT 2016
Woops, this patch didn't change manifestlog.get() to actually use the
directory cache in the treemanifest code path. Will resend with that fixed.
On 9/20/16 12:36 PM, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham at fb.com>
> # Date 1474400113 25200
> # Tue Sep 20 12:35:13 2016 -0700
> # Node ID 22915866409350cbb5302289c05bb65bc1bfd308
> # Parent 52a206d772021194ab4356aeba2c73650851a624
> manifest: change manifestlog mancache to be directory based
>
> In the last patch we added a get() function that allows fetching directory level
> treemanifestctxs. It didn't handle caching at directory level though, so we need to
> change our mancache to support multiple directories.
>
> diff --git a/mercurial/manifest.py b/mercurial/manifest.py
> --- a/mercurial/manifest.py
> +++ b/mercurial/manifest.py
> @@ -1021,9 +1021,16 @@ class manifestlog(object):
> usetreemanifest = opts.get('treemanifest', usetreemanifest)
> self._treeinmem = usetreemanifest
>
> + # A dictionary containing the cache for each directory
> + self._dirmancache = {}
> +
> # We'll separate this into it's own cache once oldmanifest is no longer
> # used
> - self._mancache = repo.manifest._mancache
> + self._dirmancache[''] = repo.manifest._mancache
> +
> + # A future patch makes this use the same config value as the existing
> + # mancache
> + self.cachesize = 4
>
> @property
> def _revlog(self):
> @@ -1047,8 +1054,8 @@ class manifestlog(object):
> _("cannot ask for manifest directory '%s' in a flat "
> "manifest") % dir)
> else:
> - if node in self._mancache:
> - cachemf = self._mancache[node]
> + if node in self._dirmancache.get(dir, ()):
> + cachemf = self._dirmancache[dir][node]
> # The old manifest may put non-ctx manifests in the cache, so
> # skip those since they don't implement the full api.
> if (isinstance(cachemf, manifestctx) or
> @@ -1059,8 +1066,13 @@ class manifestlog(object):
> m = treemanifestctx(self._revlog, '', node)
> else:
> m = manifestctx(self._revlog, node)
> - if node != revlog.nullid:
> - self._mancache[node] = m
> +
> + if node != revlog.nullid:
> + mancache = self._dirmancache.get(dir)
> + if not mancache:
> + mancache = util.lrucachedict(self.cachesize)
> + self._dirmancache[dir] = mancache
> + mancache[node] = m
> return m
>
> def add(self, m, transaction, link, p1, p2, added, removed):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=DQIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=nuarHzhP1wi1T9iURRCj1A&m=VLB2IFCfd1hwkNj48uX3kSd5dnDqItOdYqexb8hkHao&s=aJp4DUf7hp6QQ0EuIT3P_I_LQ9qrcccsIM9km8X18o8&e=
More information about the Mercurial-devel
mailing list