# HG changeset patch # User Pierre-Yves David # Date 1687377464 -7200 # Node ID 75d3306fbc9aabc9c575d3b747e15816b31fdebd # Parent 4323af38e3f2eeb20adb015ef66c6a5869532d89 tags: avoid expensive access to repo.changelog in a loop repo.changelog needs some cache invalidation when run on filtered repository. Accessing it in that loop can be expensive when there is many heads (e.g. mozilla try and it 25 000 heads). Note that the loop itself seems useless, but after this patch it no longer take about ⅛ of the time we spend computing cache for mozilla try. before : ! wall 0.350994 comb 0.350000 user 0.330000 sys 0.020000 (median of 28) after : ! wall 0.319520 comb 0.310000 user 0.290000 sys 0.020000 (median of 30) diff -r 4323af38e3f2 -r 75d3306fbc9a mercurial/tags.py --- a/mercurial/tags.py Thu Jun 22 19:41:26 2023 +0200 +++ b/mercurial/tags.py Wed Jun 21 21:57:44 2023 +0200 @@ -190,10 +190,9 @@ _updatetags(cachetags, alltags) return alltags + has_node = repo.changelog.index.has_node for head in reversed(heads): # oldest to newest - assert repo.changelog.index.has_node( - head - ), b"tag cache returned bogus head %s" % short(head) + assert has_node(head), b"tag cache returned bogus head %s" % short(head) fnodes = _filterfnodes(tagfnode, reversed(heads)) alltags = _tagsfromfnodes(ui, repo, fnodes)