Mercurial > hg-stable
comparison mercurial/phases.py @ 51418:ac1c75188440
phases: invalidate the phases set less often on retract boundary
We already have the information to update the phase set, so we do so directly
instead of invalidating the cache.
This show a sizeable speedup in our `perf::unbundle` benchmark on the
many-draft mozilla-try repository.
### data-env-vars.name = mozilla-try-2023-03-22-zstd-sparse-revlog
# benchmark.name = hg.perf.perf-unbundle
# bin-env-vars.hg.flavor = no-rust
# bin-env-vars.hg.py-re2-module = default
# benchmark.variants.issue6528 = disabled
# benchmark.variants.revs = last-10
before: 2.055259 seconds
after: 1.887064 seconds (-8.18%)
# benchmark.variants.revs = last-100
before: 2.409239 seconds
after: 2.222429 seconds (-7.75%)
# benchmark.variants.revs = last-1000
before: 3.945648 seconds
after: 3.762480 seconds (-4.64%)
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 21 Feb 2024 13:05:29 +0100 |
parents | e57d4b868a3e |
children | 2eb93812d2a5 |
comparison
equal
deleted
inserted
replaced
51417:e57d4b868a3e | 51418:ac1c75188440 |
---|---|
622 for r in sorted(roots): | 622 for r in sorted(roots): |
623 h = to_node(r) | 623 h = to_node(r) |
624 fp.write(b'%i %s\n' % (phase, hex(h))) | 624 fp.write(b'%i %s\n' % (phase, hex(h))) |
625 self.dirty = False | 625 self.dirty = False |
626 | 626 |
627 def _updateroots(self, repo, phase, newroots, tr): | 627 def _updateroots(self, repo, phase, newroots, tr, invalidate=True): |
628 self._phaseroots[phase] = newroots | 628 self._phaseroots[phase] = newroots |
629 self.invalidate() | |
630 self.dirty = True | 629 self.dirty = True |
630 if invalidate: | |
631 self.invalidate() | |
631 | 632 |
632 assert repo.filtername is None | 633 assert repo.filtername is None |
633 wrepo = weakref.ref(repo) | 634 wrepo = weakref.ref(repo) |
634 | 635 |
635 def tr_write(fp): | 636 def tr_write(fp): |
809 if p_phase == targetphase: | 810 if p_phase == targetphase: |
810 if p_phase > r_phase: | 811 if p_phase > r_phase: |
811 changed_revs[r] = r_phase | 812 changed_revs[r] = r_phase |
812 elif r in currentroots: | 813 elif r in currentroots: |
813 replaced_roots.add(r) | 814 replaced_roots.add(r) |
815 sets = self._phasesets | |
816 sets[targetphase].update(changed_revs) | |
817 for r, old in changed_revs.items(): | |
818 if old > public: | |
819 sets[old].discard(r) | |
814 | 820 |
815 if new_roots: | 821 if new_roots: |
816 assert changed_revs | 822 assert changed_revs |
823 | |
817 final_roots = new_roots | currentroots - replaced_roots | 824 final_roots = new_roots | currentroots - replaced_roots |
818 self._updateroots(repo, targetphase, final_roots, tr) | 825 self._updateroots( |
826 repo, | |
827 targetphase, | |
828 final_roots, | |
829 tr, | |
830 invalidate=False, | |
831 ) | |
819 if targetphase > 1: | 832 if targetphase > 1: |
820 retracted = set(changed_revs) | 833 retracted = set(changed_revs) |
821 for lower_phase in range(1, targetphase): | 834 for lower_phase in range(1, targetphase): |
822 lower_roots = self._phaseroots.get(lower_phase) | 835 lower_roots = self._phaseroots.get(lower_phase) |
823 if lower_roots is None: | 836 if lower_roots is None: |
824 continue | 837 continue |
825 if lower_roots & retracted: | 838 if lower_roots & retracted: |
826 simpler_roots = lower_roots - retracted | 839 simpler_roots = lower_roots - retracted |
827 self._updateroots(repo, lower_phase, simpler_roots, tr) | 840 self._updateroots( |
841 repo, | |
842 lower_phase, | |
843 simpler_roots, | |
844 tr, | |
845 invalidate=False, | |
846 ) | |
828 return changed_revs | 847 return changed_revs |
829 else: | 848 else: |
830 assert not changed_revs | 849 assert not changed_revs |
831 assert not replaced_roots | 850 assert not replaced_roots |
832 return {} | 851 return {} |