phases: update the phase set as we go during retract boundary
Apparently iterating over the `changed_revs` dictionary is very expensive.
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
prev-changeset: 30.0 seconds
this-changeset: 4.6 seconds
So, the performance regression is gone.
Once again: thanks to marvelous Python!
--- a/mercurial/phases.py Mon Mar 25 01:50:31 2024 +0100
+++ b/mercurial/phases.py Mon Mar 25 02:09:15 2024 +0100
@@ -869,6 +869,8 @@
start = min(new_revs)
end = len(cl)
rev_phases = [None] * (end - start)
+
+ this_phase_set = self._phasesets[targetphase]
for r in range(start, end):
# gather information about the current_rev
@@ -893,6 +895,7 @@
new_roots.add(r)
rev_phases[r - start] = targetphase
changed_revs[r] = r_phase
+ this_phase_set.add(r)
elif p_phase is None:
rev_phases[r - start] = r_phase
else:
@@ -903,10 +906,10 @@
if p_phase == targetphase:
if p_phase > r_phase:
changed_revs[r] = r_phase
+ this_phase_set.add(r)
elif r in currentroots:
replaced_roots.add(r)
sets = self._phasesets
- sets[targetphase].update(changed_revs)
if targetphase > draft:
for r, old in changed_revs.items():
if old > public: