phases: keep internal state as rev-num instead of node-id
Node-id are expensive to work with, dealing with revision is much simple and
faster.
The fact we still used node-id here shows how few effort have been put into
making the phase logic fast. We tend to no longer use node-id internally for
about ten years.
This has a large impact of repository with many draft roots. For example this
Mozilla-try copy have ½ Million draft roots and `perf::unbundle` see a
significant improvement.
### 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-1
before:: 1.746791 seconds
after:: 1.278379 seconds (-26.82%)
# benchmark.variants.revs = last-10
before:: 3.145774 seconds
after:: 2.103735 seconds (-33.13%)
# benchmark.variants.revs = last-100
before:: 3.487635 seconds
after:: 2.446749 seconds (-29.85%)
# benchmark.variants.revs = last-1000
before:: 5.007568 seconds
after:: 3.989923 seconds (-20.32%)
phases: do filtering at read time
This remove the need for the `filterunknown` method at all.
phases: always write with a repo
In the future change that move the internal representation of phase-roots from
node-id to rev-num, we will use a repository to translate revision numbers back
to node at write time.
Since that future change is quite complicated already, we do this small API
change beforehand.
phases: mark `phasecache.phaseroots` private
We are about to change its content from nodeid to revnum. So anyone directly
using the content might be in unexpected troubles. We start by making it private
to explicitly break any such user (and discourage them to do so).
phases: check secret presence the right way during discovery
There is an official function for this, lets use it.
This will prevent the code to break in the future while we refactor the phase
code.
phases: explicitly filter stripped revision at strip time
Explicit is better than implicit. The current logic is bit subtle and fragile.
It also get in the way of using something else than node-id as internal storage.
We replace it with a more explicit filtering while striping.
debug: add a debug::unbundle command that simulate the unbundle from a push
The code have different behavior when the unbundle comes from a push, so we
introduce a command that can simulate such unbundle.
For our copy of mozilla-try-2023-03-22, this make the unbundle jump from 2.5
seconds (with `hg unbundle`) to 15 seconds (with `hg debug::unbundle`).
That 15 seconds timings is consistent with the issue seen in production.