Mercurial > hg
annotate contrib/hgperf @ 32697:19b9fc40cc51
revlog: skeleton support for version 2 revlogs
There are a number of improvements we want to make to revlogs
that will require a new version - version 2. It is unclear what the
full set of improvements will be or when we'll be done with them.
What I do know is that the process will likely take longer than a
single release, will require input from various stakeholders to
evaluate changes, and will have many contentious debates and
bikeshedding.
It is unrealistic to develop revlog version 2 up front: there
are just too many uncertainties that we won't know until things
are implemented and experiments are run. Some changes will also
be invasive and prone to bit rot, so sitting on dozens of patches
is not practical.
This commit introduces skeleton support for version 2 revlogs in
a way that is flexible and not bound by backwards compatibility
concerns.
An experimental repo requirement for denoting revlog v2 has been
added. The requirement string has a sub-version component to it.
This will allow us to declare multiple requirements in the course
of developing revlog v2. Whenever we change the in-development
revlog v2 format, we can tweak the string, creating a new
requirement and locking out old clients. This will allow us to
make as many backwards incompatible changes and experiments to
revlog v2 as we want. In other words, we can land code and make
meaningful progress towards revlog v2 while still maintaining
extreme format flexibility up until the point we freeze the
format and remove the experimental labels.
To enable the new repo requirement, you must supply an experimental
and undocumented config option. But not just any boolean flag
will do: you need to explicitly use a value that no sane person
should ever type. This is an additional guard against enabling
revlog v2 on an installation it shouldn't be enabled on. The
specific scenario I'm trying to prevent is say a user with a
4.4 client with a frozen format enabling the option but then
downgrading to 4.3 and accidentally creating repos with an
outdated and unsupported repo format. Requiring a "challenge"
string should prevent this.
Because the format is not yet finalized and I don't want to take
any chances, revlog v2's version is currently 0xDEAD. I figure
squatting on a value we're likely never to use as an actual revlog
version to mean "internal testing only" is acceptable. And
"dead" is easily recognized as something meaningful.
There is a bunch of cleanup that is needed before work on revlog
v2 begins in earnest. I plan on doing that work once this patch
is accepted and we're comfortable with the idea of starting down
this path.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 19 May 2017 20:29:11 -0700 |
parents | 22fbca1d11ed |
children | 78f644fdaa2a |
rev | line source |
---|---|
20839
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
2 # |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
3 # hgperf - measure performance of Mercurial commands |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
4 # |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
5 # Copyright 2014 Matt Mackall <mpm@selenic.com> |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
6 # |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
7 # This software may be used and distributed according to the terms of the |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
8 # GNU General Public License version 2 or any later version. |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
9 |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
10 '''measure performance of Mercurial commands |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
11 |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
12 Using ``hgperf`` instead of ``hg`` measures performance of the target |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
13 Mercurial command. For example, the execution below measures |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
14 performance of :hg:`heads --topo`:: |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
15 |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
16 $ hgperf heads --topo |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
17 |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
18 All command output via ``ui`` is suppressed, and just measurement |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
19 result is displayed: see also "perf" extension in "contrib". |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
20 |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
21 Costs of processing before dispatching to the command function like |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
22 below are not measured:: |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
23 |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
24 - parsing command line (e.g. option validity check) |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
25 - reading configuration files in |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
26 |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
27 But ``pre-`` and ``post-`` hook invocation for the target command is |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
28 measured, even though these are invoked before or after dispatching to |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
29 the command function, because these may be required to repeat |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
30 execution of the target command correctly. |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
31 ''' |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
32 |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
33 import os |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
34 import sys |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
35 |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
36 libdir = '@LIBDIR@' |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
37 |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
38 if libdir != '@' 'LIBDIR' '@': |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
39 if not os.path.isabs(libdir): |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
40 libdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
41 libdir) |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
42 libdir = os.path.abspath(libdir) |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
43 sys.path.insert(0, libdir) |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
44 |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
45 # enable importing on demand to reduce startup time |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
46 try: |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
47 from mercurial import demandimport; demandimport.enable() |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
48 except ImportError: |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
49 import sys |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
50 sys.stderr.write("abort: couldn't find mercurial libraries in [%s]\n" % |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
51 ' '.join(sys.path)) |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
52 sys.stderr.write("(check your install and PYTHONPATH)\n") |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
53 sys.exit(-1) |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
54 |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
55 import mercurial.util |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
56 import mercurial.dispatch |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
57 |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
58 def timer(func, title=None): |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
59 results = [] |
30975
22fbca1d11ed
mercurial: switch to util.timer for all interval timings
Simon Farnsworth <simonfar@fb.com>
parents:
20839
diff
changeset
|
60 begin = mercurial.util.timer() |
20839
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
61 count = 0 |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
62 while True: |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
63 ostart = os.times() |
30975
22fbca1d11ed
mercurial: switch to util.timer for all interval timings
Simon Farnsworth <simonfar@fb.com>
parents:
20839
diff
changeset
|
64 cstart = mercurial.util.timer() |
20839
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
65 r = func() |
30975
22fbca1d11ed
mercurial: switch to util.timer for all interval timings
Simon Farnsworth <simonfar@fb.com>
parents:
20839
diff
changeset
|
66 cstop = mercurial.util.timer() |
20839
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
67 ostop = os.times() |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
68 count += 1 |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
69 a, b = ostart, ostop |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
70 results.append((cstop - cstart, b[0] - a[0], b[1]-a[1])) |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
71 if cstop - begin > 3 and count >= 100: |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
72 break |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
73 if cstop - begin > 10 and count >= 3: |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
74 break |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
75 if title: |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
76 sys.stderr.write("! %s\n" % title) |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
77 if r: |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
78 sys.stderr.write("! result: %s\n" % r) |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
79 m = min(results) |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
80 sys.stderr.write("! wall %f comb %f user %f sys %f (best of %d)\n" |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
81 % (m[0], m[1] + m[2], m[1], m[2], count)) |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
82 |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
83 orgruncommand = mercurial.dispatch.runcommand |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
84 |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
85 def runcommand(lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions): |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
86 ui.pushbuffer() |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
87 lui.pushbuffer() |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
88 timer(lambda : orgruncommand(lui, repo, cmd, fullargs, ui, |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
89 options, d, cmdpats, cmdoptions)) |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
90 ui.popbuffer() |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
91 lui.popbuffer() |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
92 |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
93 mercurial.dispatch.runcommand = runcommand |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
94 |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
95 for fp in (sys.stdin, sys.stdout, sys.stderr): |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
96 mercurial.util.setbinary(fp) |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
97 |
377a111d1cd2
contrib: add "hgperf" command to measure performance of commands easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
98 mercurial.dispatch.run() |