# HG changeset patch # User Pierre-Yves David # Date 2024-03-25 00:50:31 # Node ID e0f92bd98c24a2f87f47c9820821b6d401bbce0b # Parent 394ea442816342a7b6f872614c71a9b3c9c10fb2 phases: avoid a potentially costly dictionary interation in some case If we retract for the draft phase, there is not non-public item to be retracted and we can skip this part. This part is was apparently super costly thanks to Python. On mozilla-try-2019-02-18, a perf::unbundle call with a 10 000 changesets bundle gives give use the following timing. e57d4b868a3e: 4.6 seconds ac1c75188440: 102.5 seconds this-changeset: 30.0 seconds So we recovered about ⅔ of the regression, the next changeset will give us the rest back. diff --git a/mercurial/phases.py b/mercurial/phases.py --- a/mercurial/phases.py +++ b/mercurial/phases.py @@ -907,9 +907,10 @@ class phasecache: replaced_roots.add(r) sets = self._phasesets sets[targetphase].update(changed_revs) - for r, old in changed_revs.items(): - if old > public: - sets[old].discard(r) + if targetphase > draft: + for r, old in changed_revs.items(): + if old > public: + sets[old].discard(r) if new_roots: assert changed_revs