Mercurial > hg
diff mercurial/tags.py @ 51599:b0aaffcb6fcf
tags-cache: directly perform a monimal walk for hgtagsfnodescache warming
We do something narrower than the path retrieving data. So lets use dedicated
code instead.
This provides further useful speedup:
### data-env-vars.name = mozilla-try-2023-03-22-zstd-sparse-revlog
# benchmark.name = hg.debug.debug-update-cache
# bin-env-vars.hg.flavor = default
# bin-env-vars.hg.py-re2-module = default
# benchmark.variants.pre-state = warm
before-this-series: 19.947581
skip-fnode-filter: 18.916804 (-5.17%, -1.03)
use-rev-num: 17.493725 (-12.30%, -2.45)
this-changesets: 15.919466 (-20.19%, -4.03)
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 13 Mar 2024 12:02:06 +0100 |
parents | 2664cacd2457 |
children | 493034cc3265 |
line wrap: on
line diff
--- a/mercurial/tags.py Wed Mar 13 11:51:11 2024 +0100 +++ b/mercurial/tags.py Wed Mar 13 12:02:06 2024 +0100 @@ -21,6 +21,7 @@ short, ) from .i18n import _ +from .revlogutils.constants import ENTRY_NODE_ID from . import ( encoding, error, @@ -30,6 +31,7 @@ ) from .utils import stringutil + # Tags computation can be expensive and caches exist to make it fast in # the common case. # @@ -83,7 +85,29 @@ def warm_cache(repo): """ensure the cache is properly filled""" unfi = repo.unfiltered() - _getfnodes(repo.ui, repo, revs=unfi.changelog.revs()) + fnodescache = hgtagsfnodescache(unfi) + validated_fnodes = set() + unknown_entries = set() + flog = None + + entries = enumerate(repo.changelog.index) + node_revs = ((e[ENTRY_NODE_ID], rev) for (rev, e) in entries) + + for node, rev in node_revs: + fnode = fnodescache.getfnode(node=node, rev=rev) + if fnode != repo.nullid: + if fnode not in validated_fnodes: + if flog is None: + flog = repo.file(b'.hgtags') + if flog.hasnode(fnode): + validated_fnodes.add(fnode) + else: + unknown_entries.add(node) + + if unknown_entries: + fnodescache.refresh_invalid_nodes(unknown_entries) + + fnodescache.write() def fnoderevs(ui, repo, revs):