1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-16 00:38:38 +01:00
phorge-phorge/src/applications/diffusion/query/lowlevel
epriestley 65f13b156f Improve "refengine" performance for testing large numbers of Mercurial branches
Summary:
See PHI158. In the RefEngine, we test if any old branch positions have been removed from the repository. This is uncommon (but not impossible) in Mercurial, and corresponds to users deleting branches in Git.

Currently, we end up running `hg log` for each position, in parallel. Because of Python's large startup overhead, this can be resource intensive for repositories with a large number of branches.

We have to do this in the general case because the caller may be asking us to resolve `tip`, `newfeature`, `tip~3`, `9`, etc. However, in the specific case where the refs are 40-digit hashes, we can bulk resolve them if they exist, like this:

```
hg log ... --rev (abcd or def0 or ab12 or ...)
```

In the general case, we could probably do less of this than we currently do (instead of testing all old heads, we could prune the list by removing commits which we know are still pointed to by current heads) but that's a slightly more involved change and the effect here is already dramatic.

Test Plan:
Verified that CPU usage drops from ~110s -> ~0.9s:

Before:

```
epriestley@orbital ~/dev/phabricator $ time ./bin/repository refs nss
Updating refs in "nss"...
Done.

real	0m14.676s
user	1m24.714s
sys	0m21.645s
```

After:

```
epriestley@orbital ~/dev/phabricator $ time ./bin/repository refs nss
Updating refs in "nss"...
Done.

real	0m0.861s
user	0m0.882s
sys	0m0.213s
```

  - Manually resolved `blue`, `tip`, `9`, etc., got expected results.
  - Tried to resolve invalid hashes, got expected result (no resolution).

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D18717
2017-10-20 11:09:14 -07:00
..
DiffusionLowLevelCommitFieldsQuery.php Reduce callsites to "ArcanistDifferentialRevisionStatus" in Phabricator 2017-08-09 11:04:52 -07:00
DiffusionLowLevelCommitQuery.php Parse and display commit authorship date in Git in Diffusion 2016-01-11 09:32:37 -08:00
DiffusionLowLevelGitRefQuery.php Ignore unrecognized refs in "refs/remotes/" 2016-06-16 16:03:36 -07:00
DiffusionLowLevelMercurialBranchesQuery.php Track closed branches in Mercurial 2015-04-27 03:50:45 -07:00
DiffusionLowLevelMercurialPathsQuery.php Move Phabricator to use PhutilBinaryAnalyzer and show binary versions 2017-08-01 07:14:48 -07:00
DiffusionLowLevelParentsQuery.php Extract repository command construction from Repositories 2016-04-19 04:51:48 -07:00
DiffusionLowLevelQuery.php Use PhutilInvalidStateException 2015-05-14 07:53:52 +10:00
DiffusionLowLevelResolveRefsQuery.php Improve "refengine" performance for testing large numbers of Mercurial branches 2017-10-20 11:09:14 -07:00