Mercurial > public > mercurial-scm > hg
annotate rust/hgcli/README.md @ 48178:f12a19d03d2c
fix: reduce number of tool executions
By grouping together (path, ctx) pairs according to the inputs they would
provide to fixer tools, we can deduplicate executions of fixer tools to
significantly reduce the amount of time spent running slow tools.
This change does not handle clean files in the working copy, which could still
be deduplicated against the files in the checked out commit. It's a little
harder to do that because the filerev is not available in the workingfilectx
(and it doesn't exist for added files).
Anecdotally, this change makes some real uses cases at Google 10x faster. I
think we were originally hesitant to do this because the benefits weren't
obvious, and implementing it efficiently is kind of tricky. If we simply
memoized the formatter execution function, we would be keeping tons of file
content in memory.
Also included is a regression test for a corner case that I broke with my first
attempt at optimizing this code.
Differential Revision: https://phab.mercurial-scm.org/D11280
author | Danny Hooper <hooper@google.com> |
---|---|
date | Thu, 02 Sep 2021 14:08:45 -0700 |
parents | d4ba4d51f85f |
children | 16c3fe46929a |
rev | line source |
---|---|
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 # Oxidized Mercurial |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 This project provides a Rust implementation of the Mercurial (`hg`) |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 version control tool. |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 Under the hood, the project uses |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 [PyOxidizer](https://github.com/indygreg/PyOxidizer) to embed a Python |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 interpreter in a binary built with Rust. At run-time, the Rust `fn main()` |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 is called and Rust code handles initial process startup. An in-process |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
10 Python interpreter is started (if needed) to provide additional |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
11 functionality. |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
12 |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
13 # Building |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
14 |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
15 This project currently requires an unreleased version of PyOxidizer |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
16 (0.7.0-pre). For best results, build the exact PyOxidizer commit |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
17 as defined in the `pyoxidizer.bzl` file: |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
18 |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
19 $ git clone https://github.com/indygreg/PyOxidizer.git |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
20 $ cd PyOxidizer |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
21 $ git checkout <Git commit from pyoxidizer.bzl> |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
22 $ cargo build --release |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
23 |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
24 Then build this Rust project using the built `pyoxidizer` executable:: |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
25 |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
26 $ /path/to/pyoxidizer/target/release/pyoxidizer build |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
27 |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
28 If all goes according to plan, there should be an assembled application |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
29 under `build/<arch>/debug/app/` with an `hg` executable: |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
30 |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
31 $ build/x86_64-unknown-linux-gnu/debug/app/hg version |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
32 Mercurial Distributed SCM (version 5.3.1+433-f99cd77d53dc+20200331) |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
33 (see https://mercurial-scm.org for more information) |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
34 |
46819
d4ba4d51f85f
contributor: change mentions of mpm to olivia
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44639
diff
changeset
|
35 Copyright (C) 2005-2020 Olivia Mackall and others |
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
36 This is free software; see the source for copying conditions. There is NO |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
37 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
38 |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
39 # Running Tests |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
40 |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
41 To run tests with a built `hg` executable, you can use the `--with-hg` |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
42 argument to `run-tests.py`. But there's a wrinkle: many tests run custom |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
43 Python scripts that need to `import` modules provided by Mercurial. Since |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
44 these modules are embedded in the produced `hg` executable, a regular |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
45 Python interpreter can't access them! To work around this, set `PYTHONPATH` |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
46 to the Mercurial source directory. e.g.: |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
47 |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
48 $ cd /path/to/hg/src/tests |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
49 $ PYTHONPATH=`pwd`/.. python3.7 run-tests.py \ |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
50 --with-hg `pwd`/../rust/hgcli/build/x86_64-unknown-linux-gnu/debug/app/hg |