Mercurial > hg
comparison mercurial/exchange.py @ 45117:b1e51ef4e536
phases: sparsify phase lists
When the internal and archived phase was added, allphase became a large,
sparsely populated list. This dramatically increased the number of
lookup operations for public relations in `phasecache.phase`. As a first
step, define allphases and related lists explicitly to contain only the
actual phases. Make phasenames a dictionary and create corresponding
dictionaries for mapping phase names back to numbers. Adjust various
list to be sparse as well with the exception of phaseroots and phasesets
members of phasecache. Keep those as a separate step as it involves
changes to the C module.
Differential Revision: https://phab.mercurial-scm.org/D8697
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Wed, 08 Jul 2020 00:15:15 +0200 |
parents | 72feaeb510b3 |
children | c93dd9d9f1e6 |
comparison
equal
deleted
inserted
replaced
45116:361a7444bc41 | 45117:b1e51ef4e536 |
---|---|
1022 return | 1022 return |
1023 b2caps = bundle2.bundle2caps(pushop.remote) | 1023 b2caps = bundle2.bundle2caps(pushop.remote) |
1024 hasphaseheads = b'heads' in b2caps.get(b'phases', ()) | 1024 hasphaseheads = b'heads' in b2caps.get(b'phases', ()) |
1025 if pushop.remotephases is not None and hasphaseheads: | 1025 if pushop.remotephases is not None and hasphaseheads: |
1026 # check that the remote phase has not changed | 1026 # check that the remote phase has not changed |
1027 checks = [[] for p in phases.allphases] | 1027 checks = {p: [] for p in phases.allphases} |
1028 checks[phases.public].extend(pushop.remotephases.publicheads) | 1028 checks[phases.public].extend(pushop.remotephases.publicheads) |
1029 checks[phases.draft].extend(pushop.remotephases.draftroots) | 1029 checks[phases.draft].extend(pushop.remotephases.draftroots) |
1030 if any(checks): | 1030 if any(pycompat.itervalues(checks)): |
1031 for nodes in checks: | 1031 for phase in checks: |
1032 nodes.sort() | 1032 checks[phase].sort() |
1033 checkdata = phases.binaryencode(checks) | 1033 checkdata = phases.binaryencode(checks) |
1034 bundler.newpart(b'check:phases', data=checkdata) | 1034 bundler.newpart(b'check:phases', data=checkdata) |
1035 | 1035 |
1036 | 1036 |
1037 @b2partsgenerator(b'changeset') | 1037 @b2partsgenerator(b'changeset') |
1102 | 1102 |
1103 def _pushb2phaseheads(pushop, bundler): | 1103 def _pushb2phaseheads(pushop, bundler): |
1104 """push phase information through a bundle2 - binary part""" | 1104 """push phase information through a bundle2 - binary part""" |
1105 pushop.stepsdone.add(b'phases') | 1105 pushop.stepsdone.add(b'phases') |
1106 if pushop.outdatedphases: | 1106 if pushop.outdatedphases: |
1107 updates = [[] for p in phases.allphases] | 1107 updates = {p: [] for p in phases.allphases} |
1108 updates[0].extend(h.node() for h in pushop.outdatedphases) | 1108 updates[0].extend(h.node() for h in pushop.outdatedphases) |
1109 phasedata = phases.binaryencode(updates) | 1109 phasedata = phases.binaryencode(updates) |
1110 bundler.newpart(b'phase-heads', data=phasedata) | 1110 bundler.newpart(b'phase-heads', data=phasedata) |
1111 | 1111 |
1112 | 1112 |
2656 extraheads = repo.revs(revset, draftheads, publicheads) | 2656 extraheads = repo.revs(revset, draftheads, publicheads) |
2657 for r in extraheads: | 2657 for r in extraheads: |
2658 headsbyphase[phases.public].add(node(r)) | 2658 headsbyphase[phases.public].add(node(r)) |
2659 | 2659 |
2660 # transform data in a format used by the encoding function | 2660 # transform data in a format used by the encoding function |
2661 phasemapping = [] | 2661 phasemapping = { |
2662 for phase in phases.allphases: | 2662 phase: sorted(headsbyphase[phase]) for phase in phases.allphases |
2663 phasemapping.append(sorted(headsbyphase[phase])) | 2663 } |
2664 | 2664 |
2665 # generate the actual part | 2665 # generate the actual part |
2666 phasedata = phases.binaryencode(phasemapping) | 2666 phasedata = phases.binaryencode(phasemapping) |
2667 bundler.newpart(b'phase-heads', data=phasedata) | 2667 bundler.newpart(b'phase-heads', data=phasedata) |
2668 | 2668 |