# HG changeset patch # User Pierre-Yves David # Date 1711327831 -3600 # 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 -r 394ea4428163 -r e0f92bd98c24 mercurial/phases.py --- a/mercurial/phases.py Thu Mar 21 12:24:42 2024 +0100 +++ b/mercurial/phases.py Mon Mar 25 01:50:31 2024 +0100 @@ -907,9 +907,10 @@ 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