Mercurial > hg
annotate mercurial/help/pager.txt @ 33171:6d678ab1b10d
revlog: C implementation of delta chain resolution
I've seen revlog._deltachain() appear in a number of performance
profiles. I suspect there are 2 reasons for this:
1. Delta chain resolution performs many index lookups, thus triggering
population of index tuples. Creating possibly tens of thousands of
PyObject will have overhead.
2. Delta chain resolution is a tight loop.
By moving delta chain resolution to C, we can defer instantiation
of full index entry tuples and make the loop faster courtesy of
not running in Python.
We can measure the impact to delta chain resolution via
`hg perflogrevision` using the mozilla-central repo with a recent
manifest having delta chain length of 33726:
$ hg perfrevlogrevision -m 364895
! full
! wall 0.367585 comb 0.370000 user 0.340000 sys 0.030000 (best of 27)
! wall 0.357581 comb 0.360000 user 0.350000 sys 0.010000 (best of 28)
! deltachain
! wall 0.010644 comb 0.010000 user 0.010000 sys 0.000000 (best of 270)
! wall 0.000292 comb 0.000000 user 0.000000 sys 0.000000 (best of 8729)
$ hg perfrevlogrevision --cache -m 364895
! deltachain
! wall 0.003904 comb 0.000000 user 0.000000 sys 0.000000 (best of 712)
! wall 0.000284 comb 0.000000 user 0.000000 sys 0.000000 (best of 9926)
The first test measures savings from both not instantiating index
entries and moving to C. The second test (which doesn't clear the
index caches) essentially isolates the benefits of moving from Python
to C. It still shows a 13.7x speedup (versus 36.4x). And there are
multiple milliseconds of savings within the critical path for resolving
revision data. I think that justifies the existence of C code.
A more striking example of the benefits of this change can be
demonstrated by timing `hg debugdeltachain -m` for the mozilla-central
repo:
$ time hg debugdeltachain -m > /dev/null
before: 1057.4s
after: 503.3s
PyPy2.7 5.8.0: 220.0s
It's worth noting that the C code isn't as optimal as it could be.
We're still instantiating a new PyObject for every revision. A future
optimization would be to reuse the PyObject on the cached index tuple.
We could potentially also get wins by using a memory array of raw
integers. There is also room for a delta chain cache on revlog
instances. Of course, the best optimization is to implement revlog
reading outside of Python so Python doesn't need to be concerned
about the relatively expensive index entries and operations on them.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 25 Jun 2017 12:41:34 -0700 |
parents | 85b978031a75 |
children |
rev | line source |
---|---|
32138
edbbd18a47ab
help: attempt to clarify that pager usage is not output length based
Matt Harbison <matt_harbison@yahoo.com>
parents:
32137
diff
changeset
|
1 Some Mercurial commands can produce a lot of output, and Mercurial will |
31061
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
2 attempt to use a pager to make those commands more pleasant. |
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
3 |
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
4 To set the pager that should be used, set the application variable:: |
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
5 |
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
6 [pager] |
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
7 pager = less -FRX |
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
8 |
32608
85b978031a75
help: clarify the choice of pager
Xavier Lepaul <xalep@google.com>
parents:
32138
diff
changeset
|
9 If no pager is set in the user or repository configuration, Mercurial uses the |
85b978031a75
help: clarify the choice of pager
Xavier Lepaul <xalep@google.com>
parents:
32138
diff
changeset
|
10 environment variable $PAGER. If $PAGER is not set, pager.pager from the default |
85b978031a75
help: clarify the choice of pager
Xavier Lepaul <xalep@google.com>
parents:
32138
diff
changeset
|
11 or system configuration is used. If none of these are set, a default pager will |
85b978031a75
help: clarify the choice of pager
Xavier Lepaul <xalep@google.com>
parents:
32138
diff
changeset
|
12 be used, typically `less` on Unix and `more` on Windows. |
31061
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
13 |
32137
c4eb23116a09
help: document color/pager pitfalls on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
32104
diff
changeset
|
14 .. container:: windows |
c4eb23116a09
help: document color/pager pitfalls on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
32104
diff
changeset
|
15 |
c4eb23116a09
help: document color/pager pitfalls on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
32104
diff
changeset
|
16 On Windows, `more` is not color aware, so using it effectively disables color. |
c4eb23116a09
help: document color/pager pitfalls on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
32104
diff
changeset
|
17 MSYS and Cygwin shells provide `less` as a pager, which can be configured to |
c4eb23116a09
help: document color/pager pitfalls on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
32104
diff
changeset
|
18 support ANSI color codes. See :hg:`help config.color.pagermode` to configure |
c4eb23116a09
help: document color/pager pitfalls on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
32104
diff
changeset
|
19 the color mode when invoking a pager. |
c4eb23116a09
help: document color/pager pitfalls on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
32104
diff
changeset
|
20 |
31061
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
21 You can disable the pager for certain commands by adding them to the |
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
22 pager.ignore list:: |
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
23 |
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
24 [pager] |
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
25 ignore = version, help, update |
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
26 |
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
27 To ignore global commands like :hg:`version` or :hg:`help`, you have |
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
28 to specify them in your user configuration file. |
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
29 |
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
30 To control whether the pager is used at all for an individual command, |
32084
091d6b9157da
help: apply bulk fixes for indentation and literal blocking issues
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32081
diff
changeset
|
31 you can use --pager=<value>: |
31061
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
32 |
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
33 - use as needed: `auto`. |
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
34 - require the pager: `yes` or `on`. |
900996da577a
pager: move most help to a new help topic and deprecate extension
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
35 - suppress the pager: `no` or `off` (any unrecognized value |
32084
091d6b9157da
help: apply bulk fixes for indentation and literal blocking issues
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32081
diff
changeset
|
36 will also work). |
31062
88203f26ea57
pager: add a config knob to just globally turn off the pager
Augie Fackler <augie@google.com>
parents:
31061
diff
changeset
|
37 |
88203f26ea57
pager: add a config knob to just globally turn off the pager
Augie Fackler <augie@google.com>
parents:
31061
diff
changeset
|
38 To globally turn off all attempts to use a pager, set:: |
88203f26ea57
pager: add a config knob to just globally turn off the pager
Augie Fackler <augie@google.com>
parents:
31061
diff
changeset
|
39 |
32104
f06d23af6cdf
pager: rename 'pager.enable' to 'ui.paginate'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32084
diff
changeset
|
40 [ui] |
f06d23af6cdf
pager: rename 'pager.enable' to 'ui.paginate'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32084
diff
changeset
|
41 paginate = never |
31062
88203f26ea57
pager: add a config knob to just globally turn off the pager
Augie Fackler <augie@google.com>
parents:
31061
diff
changeset
|
42 |
88203f26ea57
pager: add a config knob to just globally turn off the pager
Augie Fackler <augie@google.com>
parents:
31061
diff
changeset
|
43 which will prevent the pager from running. |