author | Pierre-Yves David <pierre-yves.david@octobus.net> |
Tue, 26 Mar 2024 13:34:05 +0000 | |
changeset 51551 | 6e4c8366c5ce |
parent 51546 | f376c4d5c4b6 |
child 51556 | f1512dbfee9f |
permissions | -rw-r--r-- |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1 |
# perf.py - performance test routines |
42015
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
2 |
'''helper extension to measure performance |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
3 |
|
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
4 |
Configurations |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
5 |
============== |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
6 |
|
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
7 |
``perf`` |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
8 |
-------- |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
9 |
|
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
10 |
``all-timing`` |
42021
4c700c847aa2
perf: copyedit a few documentation strings
Augie Fackler <augie@google.com>
parents:
42019
diff
changeset
|
11 |
When set, additional statistics will be reported for each benchmark: best, |
42015
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
12 |
worst, median average. If not set only the best timing is reported |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
13 |
(default: off). |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
14 |
|
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
15 |
``presleep`` |
42021
4c700c847aa2
perf: copyedit a few documentation strings
Augie Fackler <augie@google.com>
parents:
42019
diff
changeset
|
16 |
number of second to wait before any group of runs (default: 1) |
42015
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
17 |
|
42359
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
18 |
``pre-run`` |
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
19 |
number of run to perform before starting measurement. |
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
20 |
|
42360
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
21 |
``profile-benchmark`` |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
22 |
Enable profiling for the benchmarked section. |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
23 |
(The first iteration is benchmarked) |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
24 |
|
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
25 |
``run-limits`` |
42021
4c700c847aa2
perf: copyedit a few documentation strings
Augie Fackler <augie@google.com>
parents:
42019
diff
changeset
|
26 |
Control the number of runs each benchmark will perform. The option value |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
27 |
should be a list of `<time>-<numberofrun>` pairs. After each run the |
42021
4c700c847aa2
perf: copyedit a few documentation strings
Augie Fackler <augie@google.com>
parents:
42019
diff
changeset
|
28 |
conditions are considered in order with the following logic: |
4c700c847aa2
perf: copyedit a few documentation strings
Augie Fackler <augie@google.com>
parents:
42019
diff
changeset
|
29 |
|
4c700c847aa2
perf: copyedit a few documentation strings
Augie Fackler <augie@google.com>
parents:
42019
diff
changeset
|
30 |
If benchmark has been running for <time> seconds, and we have performed |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
31 |
<numberofrun> iterations, stop the benchmark, |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
32 |
|
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
33 |
The default value is: `3.0-100, 10.0-3` |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
34 |
|
42015
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
35 |
``stub`` |
42021
4c700c847aa2
perf: copyedit a few documentation strings
Augie Fackler <augie@google.com>
parents:
42019
diff
changeset
|
36 |
When set, benchmarks will only be run once, useful for testing |
4c700c847aa2
perf: copyedit a few documentation strings
Augie Fackler <augie@google.com>
parents:
42019
diff
changeset
|
37 |
(default: off) |
42015
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
38 |
''' |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
39 |
|
29493
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
40 |
# "historical portability" policy of perf.py: |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
41 |
# |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
42 |
# We have to do: |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
43 |
# - make perf.py "loadable" with as wide Mercurial version as possible |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
44 |
# This doesn't mean that perf commands work correctly with that Mercurial. |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
45 |
# BTW, perf.py itself has been available since 1.1 (or eb240755386d). |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
46 |
# - make historical perf command work correctly with as wide Mercurial |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
47 |
# version as possible |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
48 |
# |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
49 |
# We have to do, if possible with reasonable cost: |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
50 |
# - make recent perf command for historical feature work correctly |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
51 |
# with early Mercurial |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
52 |
# |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
53 |
# We don't have to do: |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
54 |
# - make perf command for recent feature work correctly with early |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
55 |
# Mercurial |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
56 |
|
40144
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
57 |
import contextlib |
28561
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
58 |
import functools |
31397
8f5ed8fa39f8
perf: perform a garbage collection before each iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30977
diff
changeset
|
59 |
import gc |
28561
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
60 |
import os |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
61 |
import random |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
62 |
import shutil |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
63 |
import struct |
28561
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
64 |
import sys |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
65 |
import tempfile |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
66 |
import threading |
28561
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
67 |
import time |
47072
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47036
diff
changeset
|
68 |
|
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47036
diff
changeset
|
69 |
import mercurial.revlog |
28561
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
70 |
from mercurial import ( |
30018
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
71 |
changegroup, |
28561
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
72 |
cmdutil, |
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
73 |
commands, |
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
74 |
copies, |
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
75 |
error, |
29495
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
76 |
extensions, |
40941
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
77 |
hg, |
28561
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
78 |
mdiff, |
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
79 |
merge, |
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
80 |
util, |
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
81 |
) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
82 |
|
29494
3b5389ef5cfe
perf: define util.safehasattr forcibly for Mercurial earlier than 1.9.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29493
diff
changeset
|
83 |
# for "historical portability": |
29567
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
84 |
# try to import modules separately (in dict order), and ignore |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
85 |
# failure, because these aren't available with early Mercurial |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
86 |
try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
87 |
from mercurial import branchmap # since 2.5 (or bcee63733aad) |
29567
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
88 |
except ImportError: |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
89 |
pass |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
90 |
try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
91 |
from mercurial import obsolete # since 2.3 (or ad0d6c2b3279) |
29567
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
92 |
except ImportError: |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
93 |
pass |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
94 |
try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
95 |
from mercurial import registrar # since 3.7 (or 37d50250b696) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
96 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
97 |
dir(registrar) # forcibly load it |
32337
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32297
diff
changeset
|
98 |
except ImportError: |
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32297
diff
changeset
|
99 |
registrar = None |
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32297
diff
changeset
|
100 |
try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
101 |
from mercurial import repoview # since 2.5 (or 3a6ddacb7198) |
29567
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
102 |
except ImportError: |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
103 |
pass |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
104 |
try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
105 |
from mercurial.utils import repoviewutil # since 5.0 |
42138
caebe5e7f4bd
repoview: move subsettable in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42063
diff
changeset
|
106 |
except ImportError: |
caebe5e7f4bd
repoview: move subsettable in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42063
diff
changeset
|
107 |
repoviewutil = None |
caebe5e7f4bd
repoview: move subsettable in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42063
diff
changeset
|
108 |
try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
109 |
from mercurial import scmutil # since 1.9 (or 8b252e826c68) |
29567
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
110 |
except ImportError: |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
111 |
pass |
40941
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
112 |
try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
113 |
from mercurial import setdiscovery # since 1.9 (or cb98fed52495) |
40941
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
114 |
except ImportError: |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
115 |
pass |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
116 |
|
42360
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
117 |
try: |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
118 |
from mercurial import profiling |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
119 |
except ImportError: |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
120 |
profiling = None |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
121 |
|
47072
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47036
diff
changeset
|
122 |
try: |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47036
diff
changeset
|
123 |
from mercurial.revlogutils import constants as revlog_constants |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47036
diff
changeset
|
124 |
|
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47036
diff
changeset
|
125 |
perf_rl_kind = (revlog_constants.KIND_OTHER, b'created-by-perf') |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47036
diff
changeset
|
126 |
|
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47036
diff
changeset
|
127 |
def revlog(opener, *args, **kwargs): |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47036
diff
changeset
|
128 |
return mercurial.revlog.revlog(opener, perf_rl_kind, *args, **kwargs) |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47036
diff
changeset
|
129 |
|
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47036
diff
changeset
|
130 |
|
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47036
diff
changeset
|
131 |
except (ImportError, AttributeError): |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47036
diff
changeset
|
132 |
perf_rl_kind = None |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47036
diff
changeset
|
133 |
|
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47036
diff
changeset
|
134 |
def revlog(opener, *args, **kwargs): |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47036
diff
changeset
|
135 |
return mercurial.revlog.revlog(opener, *args, **kwargs) |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47036
diff
changeset
|
136 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
137 |
|
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
138 |
def identity(a): |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
139 |
return a |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
140 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
141 |
|
36178
646002338365
py3: introduce and use pycompat.getargspec
Augie Fackler <augie@google.com>
parents:
35951
diff
changeset
|
142 |
try: |
646002338365
py3: introduce and use pycompat.getargspec
Augie Fackler <augie@google.com>
parents:
35951
diff
changeset
|
143 |
from mercurial import pycompat |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
144 |
|
36178
646002338365
py3: introduce and use pycompat.getargspec
Augie Fackler <augie@google.com>
parents:
35951
diff
changeset
|
145 |
getargspec = pycompat.getargspec # added to module after 4.5 |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
146 |
_byteskwargs = pycompat.byteskwargs # since 4.1 (or fbc3f73dc802) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
147 |
_sysstr = pycompat.sysstr # since 4.0 (or 2219f4f82ede) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
148 |
_bytestr = pycompat.bytestr # since 4.2 (or b70407bd84d5) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
149 |
_xrange = pycompat.xrange # since 4.8 (or 7eba8f83129b) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
150 |
fsencode = pycompat.fsencode # since 3.9 (or f4a5e0e86a7e) |
39823
c4ab9fa81377
py3: work around the lack of sys.maxint in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39822
diff
changeset
|
151 |
if pycompat.ispy3: |
c4ab9fa81377
py3: work around the lack of sys.maxint in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39822
diff
changeset
|
152 |
_maxint = sys.maxsize # per py3 docs for replacing maxint |
c4ab9fa81377
py3: work around the lack of sys.maxint in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39822
diff
changeset
|
153 |
else: |
c4ab9fa81377
py3: work around the lack of sys.maxint in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39822
diff
changeset
|
154 |
_maxint = sys.maxint |
42783
c8d3af9c7e65
perf: handle NameError for `pycompat.foo` when pycompat wasn't imported
Martin von Zweigbergk <martinvonz@google.com>
parents:
42760
diff
changeset
|
155 |
except (NameError, ImportError, AttributeError): |
36178
646002338365
py3: introduce and use pycompat.getargspec
Augie Fackler <augie@google.com>
parents:
35951
diff
changeset
|
156 |
import inspect |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
157 |
|
36178
646002338365
py3: introduce and use pycompat.getargspec
Augie Fackler <augie@google.com>
parents:
35951
diff
changeset
|
158 |
getargspec = inspect.getargspec |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
159 |
_byteskwargs = identity |
42785
c00005975c91
perf: don't depend on pycompat for older Mercurial versions
Martin von Zweigbergk <martinvonz@google.com>
parents:
42784
diff
changeset
|
160 |
_bytestr = str |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
161 |
fsencode = identity # no py3 support |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
162 |
_maxint = sys.maxint # no py3 support |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
163 |
_sysstr = lambda x: x # no py3 support |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
164 |
_xrange = xrange |
29567
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
165 |
|
37844
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
166 |
try: |
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
167 |
# 4.7+ |
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
168 |
queue = pycompat.queue.Queue |
42783
c8d3af9c7e65
perf: handle NameError for `pycompat.foo` when pycompat wasn't imported
Martin von Zweigbergk <martinvonz@google.com>
parents:
42760
diff
changeset
|
169 |
except (NameError, AttributeError, ImportError): |
37844
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
170 |
# <4.7. |
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
171 |
try: |
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
172 |
queue = pycompat.queue |
42783
c8d3af9c7e65
perf: handle NameError for `pycompat.foo` when pycompat wasn't imported
Martin von Zweigbergk <martinvonz@google.com>
parents:
42760
diff
changeset
|
173 |
except (NameError, AttributeError, ImportError): |
42784
777a9df5a1ef
perf: don't try to call `util.queue` on Mercurial version before it existed
Martin von Zweigbergk <martinvonz@google.com>
parents:
42783
diff
changeset
|
174 |
import Queue as queue |
37844
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
175 |
|
38257
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
176 |
try: |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
177 |
from mercurial import logcmdutil |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
178 |
|
38257
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
179 |
makelogtemplater = logcmdutil.maketemplater |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
180 |
except (AttributeError, ImportError): |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
181 |
try: |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
182 |
makelogtemplater = cmdutil.makelogtemplater |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
183 |
except (AttributeError, ImportError): |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
184 |
makelogtemplater = None |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
185 |
|
29567
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
186 |
# for "historical portability": |
29494
3b5389ef5cfe
perf: define util.safehasattr forcibly for Mercurial earlier than 1.9.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29493
diff
changeset
|
187 |
# define util.safehasattr forcibly, because util.safehasattr has been |
3b5389ef5cfe
perf: define util.safehasattr forcibly for Mercurial earlier than 1.9.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29493
diff
changeset
|
188 |
# available since 1.9.3 (or 94b200a11cf7) |
3b5389ef5cfe
perf: define util.safehasattr forcibly for Mercurial earlier than 1.9.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29493
diff
changeset
|
189 |
_undefined = object() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
190 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
191 |
|
29494
3b5389ef5cfe
perf: define util.safehasattr forcibly for Mercurial earlier than 1.9.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29493
diff
changeset
|
192 |
def safehasattr(thing, attr): |
39821
6787dc1b93a9
py3: handle sysstr conversion around get/set attr in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39763
diff
changeset
|
193 |
return getattr(thing, _sysstr(attr), _undefined) is not _undefined |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
194 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
195 |
|
29494
3b5389ef5cfe
perf: define util.safehasattr forcibly for Mercurial earlier than 1.9.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29493
diff
changeset
|
196 |
setattr(util, 'safehasattr', safehasattr) |
3b5389ef5cfe
perf: define util.safehasattr forcibly for Mercurial earlier than 1.9.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29493
diff
changeset
|
197 |
|
29496
7299370cf304
perf: avoid using formatteropts for Mercurial earlier than 3.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29495
diff
changeset
|
198 |
# for "historical portability": |
31823
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
199 |
# define util.timer forcibly, because util.timer has been available |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
200 |
# since ae5d60bb70c9 |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
201 |
if safehasattr(time, 'perf_counter'): |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
202 |
util.timer = time.perf_counter |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
203 |
elif os.name == b'nt': |
31823
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
204 |
util.timer = time.clock |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
205 |
else: |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
206 |
util.timer = time.time |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
207 |
|
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
208 |
# for "historical portability": |
29496
7299370cf304
perf: avoid using formatteropts for Mercurial earlier than 3.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29495
diff
changeset
|
209 |
# use locally defined empty option list, if formatteropts isn't |
7299370cf304
perf: avoid using formatteropts for Mercurial earlier than 3.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29495
diff
changeset
|
210 |
# available, because commands.formatteropts has been available since |
7299370cf304
perf: avoid using formatteropts for Mercurial earlier than 3.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29495
diff
changeset
|
211 |
# 3.2 (or 7a7eed5176a4), even though formatting itself has been |
7299370cf304
perf: avoid using formatteropts for Mercurial earlier than 3.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29495
diff
changeset
|
212 |
# available since 2.2 (or ae5f92e154d3) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
213 |
formatteropts = getattr( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
214 |
cmdutil, "formatteropts", getattr(commands, "formatteropts", []) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
215 |
) |
29495
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
216 |
|
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
217 |
# for "historical portability": |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
218 |
# use locally defined option list, if debugrevlogopts isn't available, |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
219 |
# because commands.debugrevlogopts has been available since 3.7 (or |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
220 |
# 5606f7d0d063), even though cmdutil.openrevlog() has been available |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
221 |
# since 1.9 (or a79fea6b3e77). |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
222 |
revlogopts = getattr( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
223 |
cmdutil, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
224 |
"debugrevlogopts", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
225 |
getattr( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
226 |
commands, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
227 |
"debugrevlogopts", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
228 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
229 |
(b'c', b'changelog', False, b'open changelog'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
230 |
(b'm', b'manifest', False, b'open manifest'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
231 |
(b'', b'dir', False, b'open directory manifest'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
232 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
233 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
234 |
) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
235 |
|
18237
4132dc9bd5c4
perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18236
diff
changeset
|
236 |
cmdtable = {} |
29497
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
237 |
|
50008
e859f440daa9
locking: grab the wlock before touching the dirstate in `perfdirstatewrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49737
diff
changeset
|
238 |
|
29497
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
239 |
# for "historical portability": |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
240 |
# define parsealiases locally, because cmdutil.parsealiases has been |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
241 |
# available since 1.5 (or 6252852b4332) |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
242 |
def parsealiases(cmd): |
40295
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40214
diff
changeset
|
243 |
return cmd.split(b"|") |
29497
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
244 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
245 |
|
32337
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32297
diff
changeset
|
246 |
if safehasattr(registrar, 'command'): |
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32297
diff
changeset
|
247 |
command = registrar.command(cmdtable) |
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32297
diff
changeset
|
248 |
elif safehasattr(cmdutil, 'command'): |
29497
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
249 |
command = cmdutil.command(cmdtable) |
45632
7d0e54056586
py3: use native string when comparing with a function's argspec
Raphaël Gomès <rgomes@octobus.net>
parents:
44996
diff
changeset
|
250 |
if 'norepo' not in getargspec(command).args: |
29497
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
251 |
# for "historical portability": |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
252 |
# wrap original cmdutil.command, because "norepo" option has |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
253 |
# been available since 3.1 (or 75a96326cecb) |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
254 |
_command = command |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
255 |
|
29497
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
256 |
def command(name, options=(), synopsis=None, norepo=False): |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
257 |
if norepo: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
258 |
commands.norepo += b' %s' % b' '.join(parsealiases(name)) |
29497
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
259 |
return _command(name, list(options), synopsis) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
260 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
261 |
|
29497
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
262 |
else: |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
263 |
# for "historical portability": |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
264 |
# define "@command" annotation locally, because cmdutil.command |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
265 |
# has been available since 1.9 (or 2daa5179e73f) |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
266 |
def command(name, options=(), synopsis=None, norepo=False): |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
267 |
def decorator(func): |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
268 |
if synopsis: |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
269 |
cmdtable[name] = func, list(options), synopsis |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
270 |
else: |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
271 |
cmdtable[name] = func, list(options) |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
272 |
if norepo: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
273 |
commands.norepo += b' %s' % b' '.join(parsealiases(name)) |
29497
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
274 |
return func |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
275 |
|
29497
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
276 |
return decorator |
18237
4132dc9bd5c4
perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18236
diff
changeset
|
277 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
278 |
|
34494
bbb5687e5140
configitems: register the 'perf.stub' config
Boris Feld <boris.feld@octobus.net>
parents:
34343
diff
changeset
|
279 |
try: |
34749
acdc574cb8d7
contrib-perf: update the config registration
Boris Feld <boris.feld@octobus.net>
parents:
34678
diff
changeset
|
280 |
import mercurial.registrar |
acdc574cb8d7
contrib-perf: update the config registration
Boris Feld <boris.feld@octobus.net>
parents:
34678
diff
changeset
|
281 |
import mercurial.configitems |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
282 |
|
34494
bbb5687e5140
configitems: register the 'perf.stub' config
Boris Feld <boris.feld@octobus.net>
parents:
34343
diff
changeset
|
283 |
configtable = {} |
34749
acdc574cb8d7
contrib-perf: update the config registration
Boris Feld <boris.feld@octobus.net>
parents:
34678
diff
changeset
|
284 |
configitem = mercurial.registrar.configitem(configtable) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
285 |
configitem( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
286 |
b'perf', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
287 |
b'presleep', |
34749
acdc574cb8d7
contrib-perf: update the config registration
Boris Feld <boris.feld@octobus.net>
parents:
34678
diff
changeset
|
288 |
default=mercurial.configitems.dynamicdefault, |
42760
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42462
diff
changeset
|
289 |
experimental=True, |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42462
diff
changeset
|
290 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
291 |
configitem( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
292 |
b'perf', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
293 |
b'stub', |
42760
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42462
diff
changeset
|
294 |
default=mercurial.configitems.dynamicdefault, |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42462
diff
changeset
|
295 |
experimental=True, |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42462
diff
changeset
|
296 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
297 |
configitem( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
298 |
b'perf', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
299 |
b'parentscount', |
42760
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42462
diff
changeset
|
300 |
default=mercurial.configitems.dynamicdefault, |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42462
diff
changeset
|
301 |
experimental=True, |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42462
diff
changeset
|
302 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
303 |
configitem( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
304 |
b'perf', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
305 |
b'all-timing', |
42760
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42462
diff
changeset
|
306 |
default=mercurial.configitems.dynamicdefault, |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42462
diff
changeset
|
307 |
experimental=True, |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42462
diff
changeset
|
308 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
309 |
configitem( |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
310 |
b'perf', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
311 |
b'pre-run', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
312 |
default=mercurial.configitems.dynamicdefault, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
313 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
314 |
configitem( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
315 |
b'perf', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
316 |
b'profile-benchmark', |
42760
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42462
diff
changeset
|
317 |
default=mercurial.configitems.dynamicdefault, |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42462
diff
changeset
|
318 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
319 |
configitem( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
320 |
b'perf', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
321 |
b'run-limits', |
42760
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42462
diff
changeset
|
322 |
default=mercurial.configitems.dynamicdefault, |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42462
diff
changeset
|
323 |
experimental=True, |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42462
diff
changeset
|
324 |
) |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42462
diff
changeset
|
325 |
except (ImportError, AttributeError): |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42462
diff
changeset
|
326 |
pass |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42462
diff
changeset
|
327 |
except TypeError: |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42462
diff
changeset
|
328 |
# compatibility fix for a11fd395e83f |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42462
diff
changeset
|
329 |
# hg version: 5.2 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
330 |
configitem( |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
331 |
b'perf', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
332 |
b'presleep', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
333 |
default=mercurial.configitems.dynamicdefault, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
334 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
335 |
configitem( |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
336 |
b'perf', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
337 |
b'stub', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
338 |
default=mercurial.configitems.dynamicdefault, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
339 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
340 |
configitem( |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
341 |
b'perf', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
342 |
b'parentscount', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
343 |
default=mercurial.configitems.dynamicdefault, |
34749
acdc574cb8d7
contrib-perf: update the config registration
Boris Feld <boris.feld@octobus.net>
parents:
34678
diff
changeset
|
344 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
345 |
configitem( |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
346 |
b'perf', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
347 |
b'all-timing', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
348 |
default=mercurial.configitems.dynamicdefault, |
34494
bbb5687e5140
configitems: register the 'perf.stub' config
Boris Feld <boris.feld@octobus.net>
parents:
34343
diff
changeset
|
349 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
350 |
configitem( |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
351 |
b'perf', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
352 |
b'pre-run', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
353 |
default=mercurial.configitems.dynamicdefault, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
354 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
355 |
configitem( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
356 |
b'perf', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
357 |
b'profile-benchmark', |
34750
caf6c446cbe3
contrib-perf: register the 'parentscount' config item
Boris Feld <boris.feld@octobus.net>
parents:
34749
diff
changeset
|
358 |
default=mercurial.configitems.dynamicdefault, |
caf6c446cbe3
contrib-perf: register the 'parentscount' config item
Boris Feld <boris.feld@octobus.net>
parents:
34749
diff
changeset
|
359 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
360 |
configitem( |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
361 |
b'perf', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
362 |
b'run-limits', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
363 |
default=mercurial.configitems.dynamicdefault, |
42359
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
364 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
365 |
|
34494
bbb5687e5140
configitems: register the 'perf.stub' config
Boris Feld <boris.feld@octobus.net>
parents:
34343
diff
changeset
|
366 |
|
27307 | 367 |
def getlen(ui): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
368 |
if ui.configbool(b"perf", b"stub", False): |
27307 | 369 |
return lambda x: 1 |
370 |
return len |
|
371 |
||
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
372 |
|
48946
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
373 |
class noop: |
42360
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
374 |
"""dummy context manager""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
375 |
|
42360
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
376 |
def __enter__(self): |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
377 |
pass |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
378 |
|
42360
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
379 |
def __exit__(self, *args): |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
380 |
pass |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
381 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
382 |
|
42364
a09829e14fc0
perf: make sure to explicitly disable any profiler after the first iteration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42360
diff
changeset
|
383 |
NOOPCTX = noop() |
a09829e14fc0
perf: make sure to explicitly disable any profiler after the first iteration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42360
diff
changeset
|
384 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
385 |
|
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
386 |
def gettimer(ui, opts=None): |
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
387 |
"""return a timer function and formatter: (timer, formatter) |
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
388 |
|
27303
57bd9c5431a5
perf: improve grammar of gettimer comment
timeless <timeless@mozdev.org>
parents:
27286
diff
changeset
|
389 |
This function exists to gather the creation of formatter in a single |
57bd9c5431a5
perf: improve grammar of gettimer comment
timeless <timeless@mozdev.org>
parents:
27286
diff
changeset
|
390 |
place instead of duplicating it in all performance commands.""" |
23788
316ad725a1dd
perf: add a configurable sleep on startup
Matt Mackall <mpm@selenic.com>
parents:
23537
diff
changeset
|
391 |
|
316ad725a1dd
perf: add a configurable sleep on startup
Matt Mackall <mpm@selenic.com>
parents:
23537
diff
changeset
|
392 |
# enforce an idle period before execution to counteract power management |
25850
b130764e3eb5
perf: mark experimental option presleep
Matt Mackall <mpm@selenic.com>
parents:
25494
diff
changeset
|
393 |
# experimental config: perf.presleep |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
394 |
time.sleep(getint(ui, b"perf", b"presleep", 1)) |
23788
316ad725a1dd
perf: add a configurable sleep on startup
Matt Mackall <mpm@selenic.com>
parents:
23537
diff
changeset
|
395 |
|
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
396 |
if opts is None: |
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
397 |
opts = {} |
30405
e77e8876886f
perf: omit copying ui and redirect to ferr if buffer API is in use
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
30370
diff
changeset
|
398 |
# redirect all to stderr unless buffer api is in use |
e77e8876886f
perf: omit copying ui and redirect to ferr if buffer API is in use
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
30370
diff
changeset
|
399 |
if not ui._buffers: |
e77e8876886f
perf: omit copying ui and redirect to ferr if buffer API is in use
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
30370
diff
changeset
|
400 |
ui = ui.copy() |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
401 |
uifout = safeattrsetter(ui, b'fout', ignoremissing=True) |
30405
e77e8876886f
perf: omit copying ui and redirect to ferr if buffer API is in use
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
30370
diff
changeset
|
402 |
if uifout: |
e77e8876886f
perf: omit copying ui and redirect to ferr if buffer API is in use
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
30370
diff
changeset
|
403 |
# for "historical portability": |
e77e8876886f
perf: omit copying ui and redirect to ferr if buffer API is in use
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
30370
diff
changeset
|
404 |
# ui.fout/ferr have been available since 1.9 (or 4e1ccd4c2b6d) |
e77e8876886f
perf: omit copying ui and redirect to ferr if buffer API is in use
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
30370
diff
changeset
|
405 |
uifout.set(ui.ferr) |
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
406 |
|
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
407 |
# get a formatter |
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
408 |
uiformatter = getattr(ui, 'formatter', None) |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
409 |
if uiformatter: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
410 |
fm = uiformatter(b'perf', opts) |
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
411 |
else: |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
412 |
# for "historical portability": |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
413 |
# define formatter locally, because ui.formatter has been |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
414 |
# available since 2.2 (or ae5f92e154d3) |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
415 |
from mercurial import node |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
416 |
|
48946
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
417 |
class defaultformatter: |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
418 |
"""Minimized composition of baseformatter and plainformatter""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
419 |
|
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
420 |
def __init__(self, ui, topic, opts): |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
421 |
self._ui = ui |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
422 |
if ui.debugflag: |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
423 |
self.hexfunc = node.hex |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
424 |
else: |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
425 |
self.hexfunc = node.short |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
426 |
|
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
427 |
def __nonzero__(self): |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
428 |
return False |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
429 |
|
31476
413b44003462
py3: add __bool__ to every class defining __nonzero__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31397
diff
changeset
|
430 |
__bool__ = __nonzero__ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
431 |
|
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
432 |
def startitem(self): |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
433 |
pass |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
434 |
|
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
435 |
def data(self, **data): |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
436 |
pass |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
437 |
|
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
438 |
def write(self, fields, deftext, *fielddata, **opts): |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
439 |
self._ui.write(deftext % fielddata, **opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
440 |
|
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
441 |
def condwrite(self, cond, fields, deftext, *fielddata, **opts): |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
442 |
if cond: |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
443 |
self._ui.write(deftext % fielddata, **opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
444 |
|
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
445 |
def plain(self, text, **opts): |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
446 |
self._ui.write(text, **opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
447 |
|
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
448 |
def end(self): |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
449 |
pass |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
450 |
|
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
451 |
fm = defaultformatter(ui, b'perf', opts) |
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
452 |
|
27304
a6fd79495770
perf: offer perf.stub to only run one loop
timeless <timeless@mozdev.org>
parents:
27303
diff
changeset
|
453 |
# stub function, runs code only once instead of in a loop |
a6fd79495770
perf: offer perf.stub to only run one loop
timeless <timeless@mozdev.org>
parents:
27303
diff
changeset
|
454 |
# experimental config: perf.stub |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
455 |
if ui.configbool(b"perf", b"stub", False): |
27304
a6fd79495770
perf: offer perf.stub to only run one loop
timeless <timeless@mozdev.org>
parents:
27303
diff
changeset
|
456 |
return functools.partial(stub_timer, fm), fm |
38694
55101513ed94
perf: add a 'perf.all-timing' option to display more than best time
Boris Feld <boris.feld@octobus.net>
parents:
38693
diff
changeset
|
457 |
|
55101513ed94
perf: add a 'perf.all-timing' option to display more than best time
Boris Feld <boris.feld@octobus.net>
parents:
38693
diff
changeset
|
458 |
# experimental config: perf.all-timing |
50802
cf0502231d56
perf: display all timing by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50795
diff
changeset
|
459 |
displayall = ui.configbool(b"perf", b"all-timing", True) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
460 |
|
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
461 |
# experimental config: perf.run-limits |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
462 |
limitspec = ui.configlist(b"perf", b"run-limits", []) |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
463 |
limits = [] |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
464 |
for item in limitspec: |
42063
912d82daeda3
perf: make perf.run-limits code work with Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42021
diff
changeset
|
465 |
parts = item.split(b'-', 1) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
466 |
if len(parts) < 2: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
467 |
ui.warn((b'malformatted run limit entry, missing "-": %s\n' % item)) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
468 |
continue |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
469 |
try: |
42785
c00005975c91
perf: don't depend on pycompat for older Mercurial versions
Martin von Zweigbergk <martinvonz@google.com>
parents:
42784
diff
changeset
|
470 |
time_limit = float(_sysstr(parts[0])) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
471 |
except ValueError as e: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
472 |
ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
473 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
474 |
b'malformatted run limit entry, %s: %s\n' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
475 |
% (_bytestr(e), item) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
476 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
477 |
) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
478 |
continue |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
479 |
try: |
42785
c00005975c91
perf: don't depend on pycompat for older Mercurial versions
Martin von Zweigbergk <martinvonz@google.com>
parents:
42784
diff
changeset
|
480 |
run_limit = int(_sysstr(parts[1])) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
481 |
except ValueError as e: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
482 |
ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
483 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
484 |
b'malformatted run limit entry, %s: %s\n' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
485 |
% (_bytestr(e), item) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
486 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
487 |
) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
488 |
continue |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
489 |
limits.append((time_limit, run_limit)) |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
490 |
if not limits: |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
491 |
limits = DEFAULTLIMITS |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
492 |
|
42360
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
493 |
profiler = None |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
494 |
if profiling is not None: |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
495 |
if ui.configbool(b"perf", b"profile-benchmark", False): |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
496 |
profiler = profiling.profile(ui) |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
497 |
|
42359
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
498 |
prerun = getint(ui, b"perf", b"pre-run", 0) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
499 |
t = functools.partial( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
500 |
_timer, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
501 |
fm, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
502 |
displayall=displayall, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
503 |
limits=limits, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
504 |
prerun=prerun, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
505 |
profiler=profiler, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
506 |
) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
507 |
return t, fm |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
508 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
509 |
|
40680
9d88ae5c635b
perf: add a `setup` argument to run code outside of the timed section
Boris Feld <boris.feld@octobus.net>
parents:
40679
diff
changeset
|
510 |
def stub_timer(fm, func, setup=None, title=None): |
40721
0adc2c0a0792
perf: run 'setup' function during stub run
Boris Feld <boris.feld@octobus.net>
parents:
40720
diff
changeset
|
511 |
if setup is not None: |
0adc2c0a0792
perf: run 'setup' function during stub run
Boris Feld <boris.feld@octobus.net>
parents:
40720
diff
changeset
|
512 |
setup() |
27304
a6fd79495770
perf: offer perf.stub to only run one loop
timeless <timeless@mozdev.org>
parents:
27303
diff
changeset
|
513 |
func() |
a6fd79495770
perf: offer perf.stub to only run one loop
timeless <timeless@mozdev.org>
parents:
27303
diff
changeset
|
514 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
515 |
|
40144
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
516 |
@contextlib.contextmanager |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
517 |
def timeone(): |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
518 |
r = [] |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
519 |
ostart = os.times() |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
520 |
cstart = util.timer() |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
521 |
yield r |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
522 |
cstop = util.timer() |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
523 |
ostop = os.times() |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
524 |
a, b = ostart, ostop |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
525 |
r.append((cstop - cstart, b[0] - a[0], b[1] - a[1])) |
40144
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
526 |
|
42017
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
527 |
|
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
528 |
# list of stop condition (elapsed time, minimal run count) |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
529 |
DEFAULTLIMITS = ( |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
530 |
(3.0, 100), |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
531 |
(10.0, 3), |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
532 |
) |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
533 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
534 |
|
50676
28620be88da9
perf: add a new "context" argument to timer
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50675
diff
changeset
|
535 |
@contextlib.contextmanager |
28620be88da9
perf: add a new "context" argument to timer
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50675
diff
changeset
|
536 |
def noop_context(): |
28620be88da9
perf: add a new "context" argument to timer
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50675
diff
changeset
|
537 |
yield |
28620be88da9
perf: add a new "context" argument to timer
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50675
diff
changeset
|
538 |
|
28620be88da9
perf: add a new "context" argument to timer
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50675
diff
changeset
|
539 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
540 |
def _timer( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
541 |
fm, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
542 |
func, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
543 |
setup=None, |
50676
28620be88da9
perf: add a new "context" argument to timer
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50675
diff
changeset
|
544 |
context=noop_context, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
545 |
title=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
546 |
displayall=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
547 |
limits=DEFAULTLIMITS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
548 |
prerun=0, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
549 |
profiler=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
550 |
): |
31397
8f5ed8fa39f8
perf: perform a garbage collection before each iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30977
diff
changeset
|
551 |
gc.collect() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
552 |
results = [] |
30975
22fbca1d11ed
mercurial: switch to util.timer for all interval timings
Simon Farnsworth <simonfar@fb.com>
parents:
30882
diff
changeset
|
553 |
begin = util.timer() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
554 |
count = 0 |
42360
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
555 |
if profiler is None: |
42364
a09829e14fc0
perf: make sure to explicitly disable any profiler after the first iteration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42360
diff
changeset
|
556 |
profiler = NOOPCTX |
42370
c2d10506725c
py3: use range() instead of xrange()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42364
diff
changeset
|
557 |
for i in range(prerun): |
42359
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
558 |
if setup is not None: |
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
559 |
setup() |
50676
28620be88da9
perf: add a new "context" argument to timer
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50675
diff
changeset
|
560 |
with context(): |
28620be88da9
perf: add a new "context" argument to timer
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50675
diff
changeset
|
561 |
func() |
42017
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
562 |
keepgoing = True |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
563 |
while keepgoing: |
40680
9d88ae5c635b
perf: add a `setup` argument to run code outside of the timed section
Boris Feld <boris.feld@octobus.net>
parents:
40679
diff
changeset
|
564 |
if setup is not None: |
9d88ae5c635b
perf: add a `setup` argument to run code outside of the timed section
Boris Feld <boris.feld@octobus.net>
parents:
40679
diff
changeset
|
565 |
setup() |
50676
28620be88da9
perf: add a new "context" argument to timer
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50675
diff
changeset
|
566 |
with context(): |
28620be88da9
perf: add a new "context" argument to timer
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50675
diff
changeset
|
567 |
with profiler: |
28620be88da9
perf: add a new "context" argument to timer
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50675
diff
changeset
|
568 |
with timeone() as item: |
28620be88da9
perf: add a new "context" argument to timer
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50675
diff
changeset
|
569 |
r = func() |
42364
a09829e14fc0
perf: make sure to explicitly disable any profiler after the first iteration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42360
diff
changeset
|
570 |
profiler = NOOPCTX |
40144
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
571 |
count += 1 |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
572 |
results.append(item[0]) |
30975
22fbca1d11ed
mercurial: switch to util.timer for all interval timings
Simon Farnsworth <simonfar@fb.com>
parents:
30882
diff
changeset
|
573 |
cstop = util.timer() |
42017
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
574 |
# Look for a stop condition. |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
575 |
elapsed = cstop - begin |
42018
0e6422942c84
perf: pass limits as a function argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42017
diff
changeset
|
576 |
for t, mincount in limits: |
42017
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
577 |
if elapsed >= t and count >= mincount: |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
578 |
keepgoing = False |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
579 |
break |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
580 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
581 |
formatone(fm, results, title=title, result=r, displayall=displayall) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
582 |
|
40145
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
583 |
|
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
584 |
def formatone(fm, timings, title=None, result=None, displayall=False): |
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
585 |
count = len(timings) |
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
586 |
|
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
587 |
fm.startitem() |
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
588 |
|
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
589 |
if title: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
590 |
fm.write(b'title', b'! %s\n', title) |
40145
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
591 |
if result: |
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
592 |
fm.write(b'result', b'! result: %s\n', result) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
593 |
|
38694
55101513ed94
perf: add a 'perf.all-timing' option to display more than best time
Boris Feld <boris.feld@octobus.net>
parents:
38693
diff
changeset
|
594 |
def display(role, entry): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
595 |
prefix = b'' |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
596 |
if role != b'best': |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
597 |
prefix = b'%s.' % role |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
598 |
fm.plain(b'!') |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
599 |
fm.write(prefix + b'wall', b' wall %f', entry[0]) |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
600 |
fm.write(prefix + b'comb', b' comb %f', entry[1] + entry[2]) |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
601 |
fm.write(prefix + b'user', b' user %f', entry[1]) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
602 |
fm.write(prefix + b'sys', b' sys %f', entry[2]) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
603 |
fm.write(prefix + b'count', b' (%s of %%d)' % role, count) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
604 |
fm.plain(b'\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
605 |
|
40145
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
606 |
timings.sort() |
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
607 |
min_val = timings[0] |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
608 |
display(b'best', min_val) |
38694
55101513ed94
perf: add a 'perf.all-timing' option to display more than best time
Boris Feld <boris.feld@octobus.net>
parents:
38693
diff
changeset
|
609 |
if displayall: |
40145
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
610 |
max_val = timings[-1] |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
611 |
display(b'max', max_val) |
40145
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
612 |
avg = tuple([sum(x) / count for x in zip(*timings)]) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
613 |
display(b'avg', avg) |
40145
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
614 |
median = timings[len(timings) // 2] |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
615 |
display(b'median', median) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
616 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
617 |
|
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
618 |
# utilities for historical portability |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
619 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
620 |
|
30149
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
621 |
def getint(ui, section, name, default): |
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
622 |
# for "historical portability": |
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
623 |
# ui.configint has been available since 1.9 (or fa2b596db182) |
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
624 |
v = ui.config(section, name, None) |
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
625 |
if v is None: |
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
626 |
return default |
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
627 |
try: |
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
628 |
return int(v) |
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
629 |
except ValueError: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
630 |
raise error.ConfigError( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
631 |
b"%s.%s is not an integer ('%s')" % (section, name, v) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
632 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
633 |
|
30149
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
634 |
|
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
635 |
def safeattrsetter(obj, name, ignoremissing=False): |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
636 |
"""Ensure that 'obj' has 'name' attribute before subsequent setattr |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
637 |
|
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
638 |
This function is aborted, if 'obj' doesn't have 'name' attribute |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
639 |
at runtime. This avoids overlooking removal of an attribute, which |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
640 |
breaks assumption of performance measurement, in the future. |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
641 |
|
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
642 |
This function returns the object to (1) assign a new value, and |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
643 |
(2) restore an original value to the attribute. |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
644 |
|
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
645 |
If 'ignoremissing' is true, missing 'name' attribute doesn't cause |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
646 |
abortion, and this function returns None. This is useful to |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
647 |
examine an attribute, which isn't ensured in all Mercurial |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
648 |
versions. |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
649 |
""" |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
650 |
if not util.safehasattr(obj, name): |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
651 |
if ignoremissing: |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
652 |
return None |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
653 |
raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
654 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
655 |
b"missing attribute %s of %s might break assumption" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
656 |
b" of performance measurement" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
657 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
658 |
% (name, obj) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
659 |
) |
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
660 |
|
39821
6787dc1b93a9
py3: handle sysstr conversion around get/set attr in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39763
diff
changeset
|
661 |
origvalue = getattr(obj, _sysstr(name)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
662 |
|
48946
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
663 |
class attrutil: |
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
664 |
def set(self, newvalue): |
39821
6787dc1b93a9
py3: handle sysstr conversion around get/set attr in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39763
diff
changeset
|
665 |
setattr(obj, _sysstr(name), newvalue) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
666 |
|
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
667 |
def restore(self): |
39821
6787dc1b93a9
py3: handle sysstr conversion around get/set attr in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39763
diff
changeset
|
668 |
setattr(obj, _sysstr(name), origvalue) |
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
669 |
|
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
670 |
return attrutil() |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
671 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
672 |
|
30144
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
673 |
# utilities to examine each internal API changes |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
674 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
675 |
|
30144
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
676 |
def getbranchmapsubsettable(): |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
677 |
# for "historical portability": |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
678 |
# subsettable is defined in: |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
679 |
# - branchmap since 2.9 (or 175c6fd8cacc) |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
680 |
# - repoview since 2.5 (or 59a9f18d4587) |
42138
caebe5e7f4bd
repoview: move subsettable in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42063
diff
changeset
|
681 |
# - repoviewutil since 5.0 |
caebe5e7f4bd
repoview: move subsettable in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42063
diff
changeset
|
682 |
for mod in (branchmap, repoview, repoviewutil): |
30144
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
683 |
subsettable = getattr(mod, 'subsettable', None) |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
684 |
if subsettable: |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
685 |
return subsettable |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
686 |
|
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
687 |
# bisecting in bcee63733aad::59a9f18d4587 can reach here (both |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
688 |
# branchmap and repoview modules exist, but subsettable attribute |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
689 |
# doesn't) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
690 |
raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
691 |
b"perfbranchmap not available with this Mercurial", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
692 |
hint=b"use 2.5 or later", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
693 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
694 |
|
30144
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
695 |
|
30146
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
696 |
def getsvfs(repo): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
697 |
"""Return appropriate object to access files under .hg/store""" |
30146
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
698 |
# for "historical portability": |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
699 |
# repo.svfs has been available since 2.3 (or 7034365089bf) |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
700 |
svfs = getattr(repo, 'svfs', None) |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
701 |
if svfs: |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
702 |
return svfs |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
703 |
else: |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
704 |
return getattr(repo, 'sopener') |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
705 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
706 |
|
30146
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
707 |
def getvfs(repo): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
708 |
"""Return appropriate object to access files under .hg""" |
30146
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
709 |
# for "historical portability": |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
710 |
# repo.vfs has been available since 2.3 (or 7034365089bf) |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
711 |
vfs = getattr(repo, 'vfs', None) |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
712 |
if vfs: |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
713 |
return vfs |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
714 |
else: |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
715 |
return getattr(repo, 'opener') |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
716 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
717 |
|
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
718 |
def repocleartagscachefunc(repo): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
719 |
"""Return the function to clear tags cache according to repo internal API""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
720 |
if util.safehasattr(repo, b'_tagscache'): # since 2.0 (or 9dca7653b525) |
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
721 |
# in this case, setattr(repo, '_tagscache', None) or so isn't |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
722 |
# correct way to clear tags cache, because existing code paths |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
723 |
# expect _tagscache to be a structured object. |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
724 |
def clearcache(): |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
725 |
# _tagscache has been filteredpropertycache since 2.5 (or |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
726 |
# 98c867ac1330), and delattr() can't work in such case |
43421
be384a2052aa
py3: don't use bytes with vars() or __dict__
Martin von Zweigbergk <martinvonz@google.com>
parents:
43197
diff
changeset
|
727 |
if '_tagscache' in vars(repo): |
be384a2052aa
py3: don't use bytes with vars() or __dict__
Martin von Zweigbergk <martinvonz@google.com>
parents:
43197
diff
changeset
|
728 |
del repo.__dict__['_tagscache'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
729 |
|
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
730 |
return clearcache |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
731 |
|
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
732 |
repotags = safeattrsetter(repo, b'_tags', ignoremissing=True) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
733 |
if repotags: # since 1.4 (or 5614a628d173) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
734 |
return lambda: repotags.set(None) |
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
735 |
|
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
736 |
repotagscache = safeattrsetter(repo, b'tagscache', ignoremissing=True) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
737 |
if repotagscache: # since 0.6 (or d7df759d0e97) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
738 |
return lambda: repotagscache.set(None) |
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
739 |
|
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
740 |
# Mercurial earlier than 0.6 (or d7df759d0e97) logically reaches |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
741 |
# this point, but it isn't so problematic, because: |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
742 |
# - repo.tags of such Mercurial isn't "callable", and repo.tags() |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
743 |
# in perftags() causes failure soon |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
744 |
# - perf.py itself has been available since 1.1 (or eb240755386d) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
745 |
raise error.Abort(b"tags API of this hg command is unknown") |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
746 |
|
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
747 |
|
32731
6f791ca70640
perf: have a generic "clearstorecache" function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32710
diff
changeset
|
748 |
# utilities to clear cache |
6f791ca70640
perf: have a generic "clearstorecache" function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32710
diff
changeset
|
749 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
750 |
|
40683
d7936a9dad47
perf: make `clearfilecache` helper work with any object
Boris Feld <boris.feld@octobus.net>
parents:
40682
diff
changeset
|
751 |
def clearfilecache(obj, attrname): |
d7936a9dad47
perf: make `clearfilecache` helper work with any object
Boris Feld <boris.feld@octobus.net>
parents:
40682
diff
changeset
|
752 |
unfiltered = getattr(obj, 'unfiltered', None) |
d7936a9dad47
perf: make `clearfilecache` helper work with any object
Boris Feld <boris.feld@octobus.net>
parents:
40682
diff
changeset
|
753 |
if unfiltered is not None: |
d7936a9dad47
perf: make `clearfilecache` helper work with any object
Boris Feld <boris.feld@octobus.net>
parents:
40682
diff
changeset
|
754 |
obj = obj.unfiltered() |
d7936a9dad47
perf: make `clearfilecache` helper work with any object
Boris Feld <boris.feld@octobus.net>
parents:
40682
diff
changeset
|
755 |
if attrname in vars(obj): |
d7936a9dad47
perf: make `clearfilecache` helper work with any object
Boris Feld <boris.feld@octobus.net>
parents:
40682
diff
changeset
|
756 |
delattr(obj, attrname) |
d7936a9dad47
perf: make `clearfilecache` helper work with any object
Boris Feld <boris.feld@octobus.net>
parents:
40682
diff
changeset
|
757 |
obj._filecache.pop(attrname, None) |
32731
6f791ca70640
perf: have a generic "clearstorecache" function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32710
diff
changeset
|
758 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
759 |
|
40701
e4ea63855d5a
perf: introduce a function to fully "unload" a changelog
Boris Feld <boris.feld@octobus.net>
parents:
40700
diff
changeset
|
760 |
def clearchangelog(repo): |
e4ea63855d5a
perf: introduce a function to fully "unload" a changelog
Boris Feld <boris.feld@octobus.net>
parents:
40700
diff
changeset
|
761 |
if repo is not repo.unfiltered(): |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
762 |
object.__setattr__(repo, '_clcachekey', None) |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
763 |
object.__setattr__(repo, '_clcache', None) |
40701
e4ea63855d5a
perf: introduce a function to fully "unload" a changelog
Boris Feld <boris.feld@octobus.net>
parents:
40700
diff
changeset
|
764 |
clearfilecache(repo.unfiltered(), 'changelog') |
e4ea63855d5a
perf: introduce a function to fully "unload" a changelog
Boris Feld <boris.feld@octobus.net>
parents:
40700
diff
changeset
|
765 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
766 |
|
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
767 |
# perf commands |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
768 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
769 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
770 |
@command(b'perf::walk|perfwalk', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
771 |
def perfwalk(ui, repo, *pats, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
772 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
773 |
timer, fm = gettimer(ui, opts) |
34342
b3538c03a804
perf: remove fallbacks to ancient versions of dirstate.walk()
Martin von Zweigbergk <martinvonz@google.com>
parents:
32888
diff
changeset
|
774 |
m = scmutil.match(repo[None], pats, {}) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
775 |
timer( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
776 |
lambda: len( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
777 |
list( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
778 |
repo.dirstate.walk(m, subrepos=[], unknown=True, ignored=False) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
779 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
780 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
781 |
) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
782 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
783 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
784 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
785 |
@command(b'perf::annotate|perfannotate', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
786 |
def perfannotate(ui, repo, f, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
787 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
788 |
timer, fm = gettimer(ui, opts) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
789 |
fc = repo[b'.'][f] |
19292
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
18877
diff
changeset
|
790 |
timer(lambda: len(fc.annotate(True))) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
791 |
fm.end() |
19292
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
18877
diff
changeset
|
792 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
793 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
794 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
795 |
b'perf::status|perfstatus', |
43436
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
796 |
[ |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
797 |
(b'u', b'unknown', False, b'ask status to look for unknown files'), |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
798 |
(b'', b'dirstate', False, b'benchmark the internal dirstate call'), |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
799 |
] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
800 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
801 |
) |
18033
00ac420f24ee
perf: add option to perfstatus to get the status of unknown files
Siddharth Agarwal <sid0@fb.com>
parents:
17780
diff
changeset
|
802 |
def perfstatus(ui, repo, **opts): |
43120
97f80dd21312
perf: document `perfstatus`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
803 |
"""benchmark the performance of a single status call |
97f80dd21312
perf: document `perfstatus`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
804 |
|
97f80dd21312
perf: document `perfstatus`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
805 |
The repository data are preserved between each call. |
97f80dd21312
perf: document `perfstatus`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
806 |
|
97f80dd21312
perf: document `perfstatus`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
807 |
By default, only the status of the tracked file are requested. If |
97f80dd21312
perf: document `perfstatus`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
808 |
`--unknown` is passed, the "unknown" files are also tracked. |
97f80dd21312
perf: document `perfstatus`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
809 |
""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
810 |
opts = _byteskwargs(opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
811 |
# m = match.always(repo.root, repo.getcwd()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
812 |
# timer(lambda: sum(map(len, repo.dirstate.status(m, [], False, False, |
16683 | 813 |
# False)))) |
27017
cdc3e437b481
perf: un-bitrot perfstatus
Matt Mackall <mpm@selenic.com>
parents:
26748
diff
changeset
|
814 |
timer, fm = gettimer(ui, opts) |
43436
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
815 |
if opts[b'dirstate']: |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
816 |
dirstate = repo.dirstate |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
817 |
m = scmutil.matchall(repo) |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
818 |
unknown = opts[b'unknown'] |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
819 |
|
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
820 |
def status_dirstate(): |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
821 |
s = dirstate.status( |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
822 |
m, subrepos=[], ignored=False, clean=False, unknown=unknown |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
823 |
) |
43653
6186c2a53ea5
perf: bool() elements of dirstate.status return instead of len()
Augie Fackler <augie@google.com>
parents:
43572
diff
changeset
|
824 |
sum(map(bool, s)) |
43436
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
825 |
|
50143
ec3631290eb7
contrib-perf: use `running_status` in `perf::status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50008
diff
changeset
|
826 |
if util.safehasattr(dirstate, 'running_status'): |
ec3631290eb7
contrib-perf: use `running_status` in `perf::status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50008
diff
changeset
|
827 |
with dirstate.running_status(repo): |
ec3631290eb7
contrib-perf: use `running_status` in `perf::status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50008
diff
changeset
|
828 |
timer(status_dirstate) |
ec3631290eb7
contrib-perf: use `running_status` in `perf::status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50008
diff
changeset
|
829 |
dirstate.invalidate() |
ec3631290eb7
contrib-perf: use `running_status` in `perf::status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50008
diff
changeset
|
830 |
else: |
ec3631290eb7
contrib-perf: use `running_status` in `perf::status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50008
diff
changeset
|
831 |
timer(status_dirstate) |
43436
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
832 |
else: |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
833 |
timer(lambda: sum(map(len, repo.status(unknown=opts[b'unknown'])))) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
834 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
835 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
836 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
837 |
@command(b'perf::addremove|perfaddremove', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
838 |
def perfaddremove(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
839 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
840 |
timer, fm = gettimer(ui, opts) |
18871
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
841 |
try: |
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
842 |
oldquiet = repo.ui.quiet |
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
843 |
repo.ui.quiet = True |
23533
891aaa7c0c70
scmutil: pass a matcher to scmutil.addremove() instead of a list of patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
23485
diff
changeset
|
844 |
matcher = scmutil.match(repo[None]) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
845 |
opts[b'dry_run'] = True |
45632
7d0e54056586
py3: use native string when comparing with a function's argspec
Raphaël Gomès <rgomes@octobus.net>
parents:
44996
diff
changeset
|
846 |
if 'uipathfn' in getargspec(scmutil.addremove).args: |
41652
6a447a3d1bd0
addremove: pass around uipathfn and use instead of m.uipath() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41615
diff
changeset
|
847 |
uipathfn = scmutil.getuipathfn(repo) |
6a447a3d1bd0
addremove: pass around uipathfn and use instead of m.uipath() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41615
diff
changeset
|
848 |
timer(lambda: scmutil.addremove(repo, matcher, b"", uipathfn, opts)) |
6a447a3d1bd0
addremove: pass around uipathfn and use instead of m.uipath() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41615
diff
changeset
|
849 |
else: |
6a447a3d1bd0
addremove: pass around uipathfn and use instead of m.uipath() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41615
diff
changeset
|
850 |
timer(lambda: scmutil.addremove(repo, matcher, b"", opts)) |
18871
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
851 |
finally: |
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
852 |
repo.ui.quiet = oldquiet |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
853 |
fm.end() |
18871
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
854 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
855 |
|
16785
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
856 |
def clearcaches(cl): |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
857 |
# behave somewhat consistently across internal API changes |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
858 |
if util.safehasattr(cl, b'clearcaches'): |
16785
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
859 |
cl.clearcaches() |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
860 |
elif util.safehasattr(cl, b'_nodecache'): |
43527
43424f03d9a4
revlog: clarify which version use the older API in perf
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43526
diff
changeset
|
861 |
# <= hg-5.2 |
16785
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
862 |
from mercurial.node import nullid, nullrev |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
863 |
|
16785
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
864 |
cl._nodecache = {nullid: nullrev} |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
865 |
cl._nodepos = None |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
866 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
867 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
868 |
@command(b'perf::heads|perfheads', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
869 |
def perfheads(ui, repo, **opts): |
41434
48394923fbdc
perf: document perfheads
Boris Feld <boris.feld@octobus.net>
parents:
41365
diff
changeset
|
870 |
"""benchmark the computation of a changelog heads""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
871 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
872 |
timer, fm = gettimer(ui, opts) |
16785
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
873 |
cl = repo.changelog |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
874 |
|
41436
ab6d1f82be32
perf: move cache clearing in the `setup` step of `perfheads`
Boris Feld <boris.feld@octobus.net>
parents:
41434
diff
changeset
|
875 |
def s(): |
ab6d1f82be32
perf: move cache clearing in the `setup` step of `perfheads`
Boris Feld <boris.feld@octobus.net>
parents:
41434
diff
changeset
|
876 |
clearcaches(cl) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
877 |
|
16785
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
878 |
def d(): |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
879 |
len(cl.headrevs()) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
880 |
|
41436
ab6d1f82be32
perf: move cache clearing in the `setup` step of `perfheads`
Boris Feld <boris.feld@octobus.net>
parents:
41434
diff
changeset
|
881 |
timer(d, setup=s) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
882 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
883 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
884 |
|
50938
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
885 |
def _default_clear_on_disk_tags_cache(repo): |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
886 |
from mercurial import tags |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
887 |
|
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
888 |
repo.cachevfs.tryunlink(tags._filename(repo)) |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
889 |
|
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
890 |
|
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
891 |
def _default_clear_on_disk_tags_fnodes_cache(repo): |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
892 |
from mercurial import tags |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
893 |
|
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
894 |
repo.cachevfs.tryunlink(tags._fnodescachefile) |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
895 |
|
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
896 |
|
50939
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
897 |
def _default_forget_fnodes(repo, revs): |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
898 |
"""function used by the perf extension to prune some entries from the |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
899 |
fnodes cache""" |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
900 |
from mercurial import tags |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
901 |
|
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
902 |
missing_1 = b'\xff' * 4 |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
903 |
missing_2 = b'\xff' * 20 |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
904 |
cache = tags.hgtagsfnodescache(repo.unfiltered()) |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
905 |
for r in revs: |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
906 |
cache._writeentry(r * tags._fnodesrecsize, missing_1, missing_2) |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
907 |
cache.write() |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
908 |
|
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
909 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
910 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
911 |
b'perf::tags|perftags', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
912 |
formatteropts |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
913 |
+ [ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
914 |
(b'', b'clear-revlogs', False, b'refresh changelog and manifest'), |
50938
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
915 |
( |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
916 |
b'', |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
917 |
b'clear-on-disk-cache', |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
918 |
False, |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
919 |
b'clear on disk tags cache (DESTRUCTIVE)', |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
920 |
), |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
921 |
( |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
922 |
b'', |
50939
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
923 |
b'clear-fnode-cache-all', |
50938
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
924 |
False, |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
925 |
b'clear on disk file node cache (DESTRUCTIVE),', |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
926 |
), |
50939
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
927 |
( |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
928 |
b'', |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
929 |
b'clear-fnode-cache-rev', |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
930 |
[], |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
931 |
b'clear on disk file node cache (DESTRUCTIVE),', |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
932 |
b'REVS', |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
933 |
), |
50940
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
934 |
( |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
935 |
b'', |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
936 |
b'update-last', |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
937 |
b'', |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
938 |
b'simulate an update over the last N revisions (DESTRUCTIVE),', |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
939 |
b'N', |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
940 |
), |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
941 |
], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
942 |
) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
943 |
def perftags(ui, repo, **opts): |
50938
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
944 |
"""Benchmark tags retrieval in various situation |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
945 |
|
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
946 |
The option marked as (DESTRUCTIVE) will alter the on-disk cache, possibly |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
947 |
altering performance after the command was run. However, it does not |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
948 |
destroy any stored data. |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
949 |
""" |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
950 |
from mercurial import tags |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
951 |
|
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
952 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
953 |
timer, fm = gettimer(ui, opts) |
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
954 |
repocleartagscache = repocleartagscachefunc(repo) |
40744
594e84a2e574
perf: add a `clear-revlogs` flag to `perftags`
Boris Feld <boris.feld@octobus.net>
parents:
40743
diff
changeset
|
955 |
clearrevlogs = opts[b'clear_revlogs'] |
50938
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
956 |
clear_disk = opts[b'clear_on_disk_cache'] |
50939
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
957 |
clear_fnode = opts[b'clear_fnode_cache_all'] |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
958 |
|
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
959 |
clear_fnode_revs = opts[b'clear_fnode_cache_rev'] |
50940
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
960 |
update_last_str = opts[b'update_last'] |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
961 |
update_last = None |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
962 |
if update_last_str: |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
963 |
try: |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
964 |
update_last = int(update_last_str) |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
965 |
except ValueError: |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
966 |
msg = b'could not parse value for update-last: "%s"' |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
967 |
msg %= update_last_str |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
968 |
hint = b'value should be an integer' |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
969 |
raise error.Abort(msg, hint=hint) |
50938
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
970 |
|
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
971 |
clear_disk_fn = getattr( |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
972 |
tags, |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
973 |
"clear_cache_on_disk", |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
974 |
_default_clear_on_disk_tags_cache, |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
975 |
) |
51152
6a78b5a1d1ab
perf-tags: fix clear_cache_fnodes to actually clear that cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51151
diff
changeset
|
976 |
if getattr(tags, 'clear_cache_fnodes_is_working', False): |
6a78b5a1d1ab
perf-tags: fix clear_cache_fnodes to actually clear that cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51151
diff
changeset
|
977 |
clear_fnodes_fn = tags.clear_cache_fnodes |
6a78b5a1d1ab
perf-tags: fix clear_cache_fnodes to actually clear that cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51151
diff
changeset
|
978 |
else: |
6a78b5a1d1ab
perf-tags: fix clear_cache_fnodes to actually clear that cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51151
diff
changeset
|
979 |
clear_fnodes_fn = _default_clear_on_disk_tags_fnodes_cache |
50939
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
980 |
clear_fnodes_rev_fn = getattr( |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
981 |
tags, |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
982 |
"forget_fnodes", |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
983 |
_default_forget_fnodes, |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
984 |
) |
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
985 |
|
50940
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
986 |
clear_revs = [] |
50939
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
987 |
if clear_fnode_revs: |
51151
2705748ba166
perf-tags: fix the --clear-fnode-cache-rev code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51094
diff
changeset
|
988 |
clear_revs.extend(scmutil.revrange(repo, clear_fnode_revs)) |
50940
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
989 |
|
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
990 |
if update_last: |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
991 |
revset = b'last(all(), %d)' % update_last |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
992 |
last_revs = repo.unfiltered().revs(revset) |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
993 |
clear_revs.extend(last_revs) |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
994 |
|
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
995 |
from mercurial import repoview |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
996 |
|
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
997 |
rev_filter = {(b'experimental', b'extra-filter-revs'): revset} |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
998 |
with repo.ui.configoverride(rev_filter, source=b"perf"): |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
999 |
filter_id = repoview.extrafilter(repo.ui) |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
1000 |
|
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
1001 |
filter_name = b'%s%%%s' % (repo.filtername, filter_id) |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
1002 |
pre_repo = repo.filtered(filter_name) |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
1003 |
pre_repo.tags() # warm the cache |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
1004 |
old_tags_path = repo.cachevfs.join(tags._filename(pre_repo)) |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
1005 |
new_tags_path = repo.cachevfs.join(tags._filename(repo)) |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
1006 |
|
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
1007 |
clear_revs = sorted(set(clear_revs)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1008 |
|
40682
4369c00a8ee1
perf: move some of the perftags benchmark to the setup function
Boris Feld <boris.feld@octobus.net>
parents:
40681
diff
changeset
|
1009 |
def s(): |
50940
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
1010 |
if update_last: |
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
1011 |
util.copyfile(old_tags_path, new_tags_path) |
40744
594e84a2e574
perf: add a `clear-revlogs` flag to `perftags`
Boris Feld <boris.feld@octobus.net>
parents:
40743
diff
changeset
|
1012 |
if clearrevlogs: |
594e84a2e574
perf: add a `clear-revlogs` flag to `perftags`
Boris Feld <boris.feld@octobus.net>
parents:
40743
diff
changeset
|
1013 |
clearchangelog(repo) |
594e84a2e574
perf: add a `clear-revlogs` flag to `perftags`
Boris Feld <boris.feld@octobus.net>
parents:
40743
diff
changeset
|
1014 |
clearfilecache(repo.unfiltered(), 'manifest') |
50938
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
1015 |
if clear_disk: |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
1016 |
clear_disk_fn(repo) |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
1017 |
if clear_fnode: |
f02b62b7b056
perf: introduce more cache invalidation option in perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50815
diff
changeset
|
1018 |
clear_fnodes_fn(repo) |
50940
98a7f325eb5d
perf: add a --update-last flag to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50939
diff
changeset
|
1019 |
elif clear_revs: |
50939
e4c4adb694f5
perf: add a `--clear-fnode-cache-rev` argument to perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50938
diff
changeset
|
1020 |
clear_fnodes_rev_fn(repo, clear_revs) |
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
1021 |
repocleartagscache() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1022 |
|
40682
4369c00a8ee1
perf: move some of the perftags benchmark to the setup function
Boris Feld <boris.feld@octobus.net>
parents:
40681
diff
changeset
|
1023 |
def t(): |
50815
d2f72f702de2
perf: fix perf::tags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50705
diff
changeset
|
1024 |
len(repo.tags()) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1025 |
|
40682
4369c00a8ee1
perf: move some of the perftags benchmark to the setup function
Boris Feld <boris.feld@octobus.net>
parents:
40681
diff
changeset
|
1026 |
timer(t, setup=s) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1027 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1028 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1029 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1030 |
@command(b'perf::ancestors|perfancestors', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1031 |
def perfancestors(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1032 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1033 |
timer, fm = gettimer(ui, opts) |
16802
7e5d94381cd1
perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16788
diff
changeset
|
1034 |
heads = repo.changelog.headrevs() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1035 |
|
16802
7e5d94381cd1
perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16788
diff
changeset
|
1036 |
def d(): |
16866
91f3ac205816
revlog: ancestors(*revs) becomes ancestors(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents:
16858
diff
changeset
|
1037 |
for a in repo.changelog.ancestors(heads): |
16802
7e5d94381cd1
perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16788
diff
changeset
|
1038 |
pass |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1039 |
|
16802
7e5d94381cd1
perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16788
diff
changeset
|
1040 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1041 |
fm.end() |
16802
7e5d94381cd1
perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16788
diff
changeset
|
1042 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1043 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1044 |
@command(b'perf::ancestorset|perfancestorset', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1045 |
def perfancestorset(ui, repo, revset, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1046 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1047 |
timer, fm = gettimer(ui, opts) |
18080
486bfb200b3f
perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents:
18062
diff
changeset
|
1048 |
revs = repo.revs(revset) |
486bfb200b3f
perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents:
18062
diff
changeset
|
1049 |
heads = repo.changelog.headrevs() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1050 |
|
18080
486bfb200b3f
perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents:
18062
diff
changeset
|
1051 |
def d(): |
18091
f7f8159caad3
ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents:
18080
diff
changeset
|
1052 |
s = repo.changelog.ancestors(heads) |
18080
486bfb200b3f
perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents:
18062
diff
changeset
|
1053 |
for rev in revs: |
486bfb200b3f
perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents:
18062
diff
changeset
|
1054 |
rev in s |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1055 |
|
18080
486bfb200b3f
perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents:
18062
diff
changeset
|
1056 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1057 |
fm.end() |
18080
486bfb200b3f
perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents:
18062
diff
changeset
|
1058 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1059 |
|
49438
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1060 |
@command( |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1061 |
b'perf::delta-find', |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1062 |
revlogopts + formatteropts, |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1063 |
b'-c|-m|FILE REV', |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1064 |
) |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1065 |
def perf_delta_find(ui, repo, arg_1, arg_2=None, **opts): |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1066 |
"""benchmark the process of finding a valid delta for a revlog revision |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1067 |
|
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1068 |
When a revlog receives a new revision (e.g. from a commit, or from an |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1069 |
incoming bundle), it searches for a suitable delta-base to produce a delta. |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1070 |
This perf command measures how much time we spend in this process. It |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1071 |
operates on an already stored revision. |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1072 |
|
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1073 |
See `hg help debug-delta-find` for another related command. |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1074 |
""" |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1075 |
from mercurial import revlogutils |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1076 |
import mercurial.revlogutils.deltas as deltautil |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1077 |
|
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1078 |
opts = _byteskwargs(opts) |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1079 |
if arg_2 is None: |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1080 |
file_ = None |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1081 |
rev = arg_1 |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1082 |
else: |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1083 |
file_ = arg_1 |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1084 |
rev = arg_2 |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1085 |
|
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1086 |
repo = repo.unfiltered() |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1087 |
|
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1088 |
timer, fm = gettimer(ui, opts) |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1089 |
|
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1090 |
rev = int(rev) |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1091 |
|
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1092 |
revlog = cmdutil.openrevlog(repo, b'perf::delta-find', file_, opts) |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1093 |
|
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1094 |
deltacomputer = deltautil.deltacomputer(revlog) |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1095 |
|
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1096 |
node = revlog.node(rev) |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1097 |
p1r, p2r = revlog.parentrevs(rev) |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1098 |
p1 = revlog.node(p1r) |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1099 |
p2 = revlog.node(p2r) |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1100 |
full_text = revlog.revision(rev) |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1101 |
textlen = len(full_text) |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1102 |
cachedelta = None |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1103 |
flags = revlog.flags(rev) |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1104 |
|
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1105 |
revinfo = revlogutils.revisioninfo( |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1106 |
node, |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1107 |
p1, |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1108 |
p2, |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1109 |
[full_text], # btext |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1110 |
textlen, |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1111 |
cachedelta, |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1112 |
flags, |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1113 |
) |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1114 |
|
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1115 |
# Note: we should probably purge the potential caches (like the full |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1116 |
# manifest cache) between runs. |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1117 |
def find_one(): |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1118 |
with revlog._datafp() as fh: |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1119 |
deltacomputer.finddeltainfo(revinfo, fh, target_rev=rev) |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1120 |
|
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1121 |
timer(find_one) |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1122 |
fm.end() |
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1123 |
|
44d4fd09982f
perf: introduce a benchmark for delta-find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49414
diff
changeset
|
1124 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1125 |
@command(b'perf::discovery|perfdiscovery', formatteropts, b'PATH') |
40941
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
1126 |
def perfdiscovery(ui, repo, path, **opts): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
1127 |
"""benchmark discovery between local repo and the peer at given path""" |
40941
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
1128 |
repos = [repo, None] |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
1129 |
timer, fm = gettimer(ui, opts) |
46973
92029a43debb
perf-discovery: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46780
diff
changeset
|
1130 |
|
92029a43debb
perf-discovery: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46780
diff
changeset
|
1131 |
try: |
49737
4cedae992ed1
path: pass `path` to `peer` in `hg perf::discovery`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49705
diff
changeset
|
1132 |
from mercurial.utils.urlutil import get_unique_pull_path_obj |
4cedae992ed1
path: pass `path` to `peer` in `hg perf::discovery`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49705
diff
changeset
|
1133 |
|
4cedae992ed1
path: pass `path` to `peer` in `hg perf::discovery`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49705
diff
changeset
|
1134 |
path = get_unique_pull_path_obj(b'perfdiscovery', ui, path) |
46973
92029a43debb
perf-discovery: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46780
diff
changeset
|
1135 |
except ImportError: |
49737
4cedae992ed1
path: pass `path` to `peer` in `hg perf::discovery`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49705
diff
changeset
|
1136 |
try: |
4cedae992ed1
path: pass `path` to `peer` in `hg perf::discovery`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49705
diff
changeset
|
1137 |
from mercurial.utils.urlutil import get_unique_pull_path |
4cedae992ed1
path: pass `path` to `peer` in `hg perf::discovery`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49705
diff
changeset
|
1138 |
|
4cedae992ed1
path: pass `path` to `peer` in `hg perf::discovery`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49705
diff
changeset
|
1139 |
path = get_unique_pull_path(b'perfdiscovery', repo, ui, path)[0] |
4cedae992ed1
path: pass `path` to `peer` in `hg perf::discovery`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49705
diff
changeset
|
1140 |
except ImportError: |
4cedae992ed1
path: pass `path` to `peer` in `hg perf::discovery`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49705
diff
changeset
|
1141 |
path = ui.expandpath(path) |
40941
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
1142 |
|
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
1143 |
def s(): |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
1144 |
repos[1] = hg.peer(ui, opts, path) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1145 |
|
40941
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
1146 |
def d(): |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
1147 |
setdiscovery.findcommonheads(ui, *repos) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1148 |
|
40941
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
1149 |
timer(d, setup=s) |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
1150 |
fm.end() |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
1151 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1152 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1153 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1154 |
b'perf::bookmarks|perfbookmarks', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1155 |
formatteropts |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
1156 |
+ [ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
1157 |
(b'', b'clear-revlogs', False, b'refresh changelog and manifest'), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
1158 |
], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1159 |
) |
32733
2b0a8b0f3435
perf: add a perfbookmarks command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32732
diff
changeset
|
1160 |
def perfbookmarks(ui, repo, **opts): |
2b0a8b0f3435
perf: add a perfbookmarks command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32732
diff
changeset
|
1161 |
"""benchmark parsing bookmarks from disk to memory""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1162 |
opts = _byteskwargs(opts) |
32733
2b0a8b0f3435
perf: add a perfbookmarks command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32732
diff
changeset
|
1163 |
timer, fm = gettimer(ui, opts) |
40681
c0a1686d9391
perf: use the new setup function in "perfbookmarks"
Boris Feld <boris.feld@octobus.net>
parents:
40680
diff
changeset
|
1164 |
|
40746
82c189c511bd
perf: add a `clear-revlogs` flag to `perfbookmarks`
Boris Feld <boris.feld@octobus.net>
parents:
40744
diff
changeset
|
1165 |
clearrevlogs = opts[b'clear_revlogs'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1166 |
|
40681
c0a1686d9391
perf: use the new setup function in "perfbookmarks"
Boris Feld <boris.feld@octobus.net>
parents:
40680
diff
changeset
|
1167 |
def s(): |
40746
82c189c511bd
perf: add a `clear-revlogs` flag to `perfbookmarks`
Boris Feld <boris.feld@octobus.net>
parents:
40744
diff
changeset
|
1168 |
if clearrevlogs: |
82c189c511bd
perf: add a `clear-revlogs` flag to `perfbookmarks`
Boris Feld <boris.feld@octobus.net>
parents:
40744
diff
changeset
|
1169 |
clearchangelog(repo) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1170 |
clearfilecache(repo, b'_bookmarks') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1171 |
|
40681
c0a1686d9391
perf: use the new setup function in "perfbookmarks"
Boris Feld <boris.feld@octobus.net>
parents:
40680
diff
changeset
|
1172 |
def d(): |
32733
2b0a8b0f3435
perf: add a perfbookmarks command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32732
diff
changeset
|
1173 |
repo._bookmarks |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1174 |
|
40681
c0a1686d9391
perf: use the new setup function in "perfbookmarks"
Boris Feld <boris.feld@octobus.net>
parents:
40680
diff
changeset
|
1175 |
timer(d, setup=s) |
32733
2b0a8b0f3435
perf: add a perfbookmarks command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32732
diff
changeset
|
1176 |
fm.end() |
2b0a8b0f3435
perf: add a perfbookmarks command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32732
diff
changeset
|
1177 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1178 |
|
49412
3635aae8b2e9
perf-bundle: accept --rev arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49411
diff
changeset
|
1179 |
@command( |
3635aae8b2e9
perf-bundle: accept --rev arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49411
diff
changeset
|
1180 |
b'perf::bundle', |
3635aae8b2e9
perf-bundle: accept --rev arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49411
diff
changeset
|
1181 |
[ |
3635aae8b2e9
perf-bundle: accept --rev arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49411
diff
changeset
|
1182 |
( |
3635aae8b2e9
perf-bundle: accept --rev arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49411
diff
changeset
|
1183 |
b'r', |
3635aae8b2e9
perf-bundle: accept --rev arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49411
diff
changeset
|
1184 |
b'rev', |
3635aae8b2e9
perf-bundle: accept --rev arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49411
diff
changeset
|
1185 |
[], |
3635aae8b2e9
perf-bundle: accept --rev arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49411
diff
changeset
|
1186 |
b'changesets to bundle', |
3635aae8b2e9
perf-bundle: accept --rev arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49411
diff
changeset
|
1187 |
b'REV', |
3635aae8b2e9
perf-bundle: accept --rev arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49411
diff
changeset
|
1188 |
), |
49413
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1189 |
( |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1190 |
b't', |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1191 |
b'type', |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1192 |
b'none', |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1193 |
b'bundlespec to use (see `hg help bundlespec`)', |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1194 |
b'TYPE', |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1195 |
), |
49412
3635aae8b2e9
perf-bundle: accept --rev arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49411
diff
changeset
|
1196 |
] |
3635aae8b2e9
perf-bundle: accept --rev arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49411
diff
changeset
|
1197 |
+ formatteropts, |
3635aae8b2e9
perf-bundle: accept --rev arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49411
diff
changeset
|
1198 |
b'REVS', |
3635aae8b2e9
perf-bundle: accept --rev arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49411
diff
changeset
|
1199 |
) |
49411
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1200 |
def perfbundle(ui, repo, *revs, **opts): |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1201 |
"""benchmark the creation of a bundle from a repository |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1202 |
|
49413
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1203 |
For now, this only supports "none" compression. |
49411
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1204 |
""" |
49475
d513ae93dff3
perf: make perf::bundle compatible down to 5.2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49474
diff
changeset
|
1205 |
try: |
d513ae93dff3
perf: make perf::bundle compatible down to 5.2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49474
diff
changeset
|
1206 |
from mercurial import bundlecaches |
d513ae93dff3
perf: make perf::bundle compatible down to 5.2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49474
diff
changeset
|
1207 |
|
d513ae93dff3
perf: make perf::bundle compatible down to 5.2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49474
diff
changeset
|
1208 |
parsebundlespec = bundlecaches.parsebundlespec |
d513ae93dff3
perf: make perf::bundle compatible down to 5.2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49474
diff
changeset
|
1209 |
except ImportError: |
d513ae93dff3
perf: make perf::bundle compatible down to 5.2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49474
diff
changeset
|
1210 |
from mercurial import exchange |
d513ae93dff3
perf: make perf::bundle compatible down to 5.2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49474
diff
changeset
|
1211 |
|
d513ae93dff3
perf: make perf::bundle compatible down to 5.2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49474
diff
changeset
|
1212 |
parsebundlespec = exchange.parsebundlespec |
d513ae93dff3
perf: make perf::bundle compatible down to 5.2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49474
diff
changeset
|
1213 |
|
49411
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1214 |
from mercurial import discovery |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1215 |
from mercurial import bundle2 |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1216 |
|
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1217 |
opts = _byteskwargs(opts) |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1218 |
timer, fm = gettimer(ui, opts) |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1219 |
|
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1220 |
cl = repo.changelog |
49412
3635aae8b2e9
perf-bundle: accept --rev arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49411
diff
changeset
|
1221 |
revs = list(revs) |
3635aae8b2e9
perf-bundle: accept --rev arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49411
diff
changeset
|
1222 |
revs.extend(opts.get(b'rev', ())) |
49411
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1223 |
revs = scmutil.revrange(repo, revs) |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1224 |
if not revs: |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1225 |
raise error.Abort(b"not revision specified") |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1226 |
# make it a consistent set (ie: without topological gaps) |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1227 |
old_len = len(revs) |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1228 |
revs = list(repo.revs(b"%ld::%ld", revs, revs)) |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1229 |
if old_len != len(revs): |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1230 |
new_count = len(revs) - old_len |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1231 |
msg = b"add %d new revisions to make it a consistent set\n" |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1232 |
ui.write_err(msg % new_count) |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1233 |
|
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1234 |
targets = [cl.node(r) for r in repo.revs(b"heads(::%ld)", revs)] |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1235 |
bases = [cl.node(r) for r in repo.revs(b"heads(::%ld - %ld)", revs, revs)] |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1236 |
outgoing = discovery.outgoing(repo, bases, targets) |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1237 |
|
49413
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1238 |
bundle_spec = opts.get(b'type') |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1239 |
|
49474
a7a5740b322a
perf: make perf::bundle compatible before 61ba04693d65
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49445
diff
changeset
|
1240 |
bundle_spec = parsebundlespec(repo, bundle_spec, strict=False) |
a7a5740b322a
perf: make perf::bundle compatible before 61ba04693d65
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49445
diff
changeset
|
1241 |
|
a7a5740b322a
perf: make perf::bundle compatible before 61ba04693d65
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49445
diff
changeset
|
1242 |
cgversion = bundle_spec.params.get(b"cg.version") |
a7a5740b322a
perf: make perf::bundle compatible before 61ba04693d65
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49445
diff
changeset
|
1243 |
if cgversion is None: |
a7a5740b322a
perf: make perf::bundle compatible before 61ba04693d65
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49445
diff
changeset
|
1244 |
if bundle_spec.version == b'v1': |
a7a5740b322a
perf: make perf::bundle compatible before 61ba04693d65
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49445
diff
changeset
|
1245 |
cgversion = b'01' |
a7a5740b322a
perf: make perf::bundle compatible before 61ba04693d65
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49445
diff
changeset
|
1246 |
if bundle_spec.version == b'v2': |
a7a5740b322a
perf: make perf::bundle compatible before 61ba04693d65
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49445
diff
changeset
|
1247 |
cgversion = b'02' |
49413
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1248 |
if cgversion not in changegroup.supportedoutgoingversions(repo): |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1249 |
err = b"repository does not support bundle version %s" |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1250 |
raise error.Abort(err % cgversion) |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1251 |
|
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1252 |
if cgversion == b'01': # bundle1 |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1253 |
bversion = b'HG10' + bundle_spec.wirecompression |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1254 |
bcompression = None |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1255 |
elif cgversion in (b'02', b'03'): |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1256 |
bversion = b'HG20' |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1257 |
bcompression = bundle_spec.wirecompression |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1258 |
else: |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1259 |
err = b'perf::bundle: unexpected changegroup version %s' |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1260 |
raise error.ProgrammingError(err % cgversion) |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1261 |
|
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1262 |
if bcompression is None: |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1263 |
bcompression = b'UN' |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1264 |
|
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1265 |
if bcompression != b'UN': |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1266 |
err = b'perf::bundle: compression currently unsupported: %s' |
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1267 |
raise error.ProgrammingError(err % bcompression) |
49411
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1268 |
|
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1269 |
def do_bundle(): |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1270 |
bundle2.writenewbundle( |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1271 |
ui, |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1272 |
repo, |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1273 |
b'perf::bundle', |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1274 |
os.devnull, |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1275 |
bversion, |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1276 |
outgoing, |
49413
b380583ad2f5
perf-bundle: accept --type argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49412
diff
changeset
|
1277 |
bundle_spec.params, |
49411
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1278 |
) |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1279 |
|
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1280 |
timer(do_bundle) |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1281 |
fm.end() |
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1282 |
|
b081a5aab782
perf-bundle: add a new command to benchmark bundle creation time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
1283 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1284 |
@command(b'perf::bundleread|perfbundleread', formatteropts, b'BUNDLE') |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1285 |
def perfbundleread(ui, repo, bundlepath, **opts): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1286 |
"""Benchmark reading of bundle files. |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1287 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1288 |
This command is meant to isolate the I/O part of bundle reading as |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1289 |
much as possible. |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1290 |
""" |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1291 |
from mercurial import ( |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1292 |
bundle2, |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1293 |
exchange, |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1294 |
streamclone, |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1295 |
) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1296 |
|
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1297 |
opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1298 |
|
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1299 |
def makebench(fn): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1300 |
def run(): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1301 |
with open(bundlepath, b'rb') as fh: |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1302 |
bundle = exchange.readbundle(ui, fh, bundlepath) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1303 |
fn(bundle) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1304 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1305 |
return run |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1306 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1307 |
def makereadnbytes(size): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1308 |
def run(): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1309 |
with open(bundlepath, b'rb') as fh: |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1310 |
bundle = exchange.readbundle(ui, fh, bundlepath) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1311 |
while bundle.read(size): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1312 |
pass |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1313 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1314 |
return run |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1315 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1316 |
def makestdioread(size): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1317 |
def run(): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1318 |
with open(bundlepath, b'rb') as fh: |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1319 |
while fh.read(size): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1320 |
pass |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1321 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1322 |
return run |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1323 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1324 |
# bundle1 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1325 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1326 |
def deltaiter(bundle): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1327 |
for delta in bundle.deltaiter(): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1328 |
pass |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1329 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1330 |
def iterchunks(bundle): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1331 |
for chunk in bundle.getchunks(): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1332 |
pass |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1333 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1334 |
# bundle2 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1335 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1336 |
def forwardchunks(bundle): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1337 |
for chunk in bundle._forwardchunks(): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1338 |
pass |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1339 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1340 |
def iterparts(bundle): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1341 |
for part in bundle.iterparts(): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1342 |
pass |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1343 |
|
35116
da91e7309daf
bundle2: don't use seekable bundle2 parts by default (issue5691)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35109
diff
changeset
|
1344 |
def iterpartsseekable(bundle): |
da91e7309daf
bundle2: don't use seekable bundle2 parts by default (issue5691)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35109
diff
changeset
|
1345 |
for part in bundle.iterparts(seekable=True): |
da91e7309daf
bundle2: don't use seekable bundle2 parts by default (issue5691)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35109
diff
changeset
|
1346 |
pass |
da91e7309daf
bundle2: don't use seekable bundle2 parts by default (issue5691)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35109
diff
changeset
|
1347 |
|
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1348 |
def seek(bundle): |
35116
da91e7309daf
bundle2: don't use seekable bundle2 parts by default (issue5691)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35109
diff
changeset
|
1349 |
for part in bundle.iterparts(seekable=True): |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1350 |
part.seek(0, os.SEEK_END) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1351 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1352 |
def makepartreadnbytes(size): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1353 |
def run(): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1354 |
with open(bundlepath, b'rb') as fh: |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1355 |
bundle = exchange.readbundle(ui, fh, bundlepath) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1356 |
for part in bundle.iterparts(): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1357 |
while part.read(size): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1358 |
pass |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1359 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1360 |
return run |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1361 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1362 |
benches = [ |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1363 |
(makestdioread(8192), b'read(8k)'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1364 |
(makestdioread(16384), b'read(16k)'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1365 |
(makestdioread(32768), b'read(32k)'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1366 |
(makestdioread(131072), b'read(128k)'), |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1367 |
] |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1368 |
|
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1369 |
with open(bundlepath, b'rb') as fh: |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1370 |
bundle = exchange.readbundle(ui, fh, bundlepath) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1371 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1372 |
if isinstance(bundle, changegroup.cg1unpacker): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1373 |
benches.extend( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1374 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1375 |
(makebench(deltaiter), b'cg1 deltaiter()'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1376 |
(makebench(iterchunks), b'cg1 getchunks()'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1377 |
(makereadnbytes(8192), b'cg1 read(8k)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1378 |
(makereadnbytes(16384), b'cg1 read(16k)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1379 |
(makereadnbytes(32768), b'cg1 read(32k)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1380 |
(makereadnbytes(131072), b'cg1 read(128k)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1381 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1382 |
) |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1383 |
elif isinstance(bundle, bundle2.unbundle20): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1384 |
benches.extend( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1385 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1386 |
(makebench(forwardchunks), b'bundle2 forwardchunks()'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1387 |
(makebench(iterparts), b'bundle2 iterparts()'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1388 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1389 |
makebench(iterpartsseekable), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1390 |
b'bundle2 iterparts() seekable', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1391 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1392 |
(makebench(seek), b'bundle2 part seek()'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1393 |
(makepartreadnbytes(8192), b'bundle2 part read(8k)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1394 |
(makepartreadnbytes(16384), b'bundle2 part read(16k)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1395 |
(makepartreadnbytes(32768), b'bundle2 part read(32k)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1396 |
(makepartreadnbytes(131072), b'bundle2 part read(128k)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1397 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1398 |
) |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1399 |
elif isinstance(bundle, streamclone.streamcloneapplier): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1400 |
raise error.Abort(b'stream clone bundles not supported') |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1401 |
else: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1402 |
raise error.Abort(b'unhandled bundle type: %s' % type(bundle)) |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1403 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1404 |
for fn, title in benches: |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1405 |
timer, fm = gettimer(ui, opts) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1406 |
timer(fn, title=title) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1407 |
fm.end() |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
1408 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1409 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1410 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1411 |
b'perf::changegroupchangelog|perfchangegroupchangelog', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1412 |
formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1413 |
+ [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1414 |
(b'', b'cgversion', b'02', b'changegroup version'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1415 |
(b'r', b'rev', b'', b'revisions to add to changegroup'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1416 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1417 |
) |
40713
cfaf3843491b
perf: rename version flag of perfchangegroupchangelog to cgversion
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40702
diff
changeset
|
1418 |
def perfchangegroupchangelog(ui, repo, cgversion=b'02', rev=None, **opts): |
30018
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
1419 |
"""Benchmark producing a changelog group for a changegroup. |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
1420 |
|
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
1421 |
This measures the time spent processing the changelog during a |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
1422 |
bundle operation. This occurs during `hg bundle` and on a server |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
1423 |
processing a `getbundle` wire protocol request (handles clones |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
1424 |
and pull requests). |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
1425 |
|
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
1426 |
By default, all revisions are added to the changegroup. |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
1427 |
""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1428 |
opts = _byteskwargs(opts) |
30018
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
1429 |
cl = repo.changelog |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1430 |
nodes = [cl.lookup(r) for r in repo.revs(rev or b'all()')] |
40713
cfaf3843491b
perf: rename version flag of perfchangegroupchangelog to cgversion
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40702
diff
changeset
|
1431 |
bundler = changegroup.getbundler(cgversion, repo) |
30018
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
1432 |
|
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
1433 |
def d(): |
38977
a1f694779b2f
perf: call _generatechangelog() instead of group()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38969
diff
changeset
|
1434 |
state, chunks = bundler._generatechangelog(cl, nodes) |
a1f694779b2f
perf: call _generatechangelog() instead of group()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38969
diff
changeset
|
1435 |
for chunk in chunks: |
30018
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
1436 |
pass |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
1437 |
|
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
1438 |
timer, fm = gettimer(ui, opts) |
38977
a1f694779b2f
perf: call _generatechangelog() instead of group()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38969
diff
changeset
|
1439 |
|
a1f694779b2f
perf: call _generatechangelog() instead of group()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38969
diff
changeset
|
1440 |
# Terminal printing can interfere with timing. So disable it. |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1441 |
with ui.configoverride({(b'progress', b'disable'): True}): |
38977
a1f694779b2f
perf: call _generatechangelog() instead of group()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38969
diff
changeset
|
1442 |
timer(d) |
a1f694779b2f
perf: call _generatechangelog() instead of group()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38969
diff
changeset
|
1443 |
|
30018
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
1444 |
fm.end() |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
1445 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1446 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1447 |
@command(b'perf::dirs|perfdirs', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1448 |
def perfdirs(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1449 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1450 |
timer, fm = gettimer(ui, opts) |
18845
c1f416e4bc80
perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents:
18837
diff
changeset
|
1451 |
dirstate = repo.dirstate |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1452 |
b'a' in dirstate |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1453 |
|
18845
c1f416e4bc80
perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents:
18837
diff
changeset
|
1454 |
def d(): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1455 |
dirstate.hasdir(b'a') |
47477
eb416759af7e
dirstate: Removed unused instances of `DirsMultiset`
Simon Sapin <simon.sapin@octobus.net>
parents:
47150
diff
changeset
|
1456 |
try: |
eb416759af7e
dirstate: Removed unused instances of `DirsMultiset`
Simon Sapin <simon.sapin@octobus.net>
parents:
47150
diff
changeset
|
1457 |
del dirstate._map._dirs |
eb416759af7e
dirstate: Removed unused instances of `DirsMultiset`
Simon Sapin <simon.sapin@octobus.net>
parents:
47150
diff
changeset
|
1458 |
except AttributeError: |
eb416759af7e
dirstate: Removed unused instances of `DirsMultiset`
Simon Sapin <simon.sapin@octobus.net>
parents:
47150
diff
changeset
|
1459 |
pass |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1460 |
|
18845
c1f416e4bc80
perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents:
18837
diff
changeset
|
1461 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1462 |
fm.end() |
18845
c1f416e4bc80
perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents:
18837
diff
changeset
|
1463 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1464 |
|
43197
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1465 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1466 |
b'perf::dirstate|perfdirstate', |
43197
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1467 |
[ |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1468 |
( |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1469 |
b'', |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1470 |
b'iteration', |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1471 |
None, |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1472 |
b'benchmark a full iteration for the dirstate', |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1473 |
), |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1474 |
( |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1475 |
b'', |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1476 |
b'contains', |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1477 |
None, |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1478 |
b'benchmark a large amount of `nf in dirstate` calls', |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1479 |
), |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1480 |
] |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1481 |
+ formatteropts, |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1482 |
) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1483 |
def perfdirstate(ui, repo, **opts): |
43196
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1484 |
"""benchmap the time of various distate operations |
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1485 |
|
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1486 |
By default benchmark the time necessary to load a dirstate from scratch. |
43121
ce315b1fc9a7
perf: document `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43120
diff
changeset
|
1487 |
The dirstate is loaded to the point were a "contains" request can be |
ce315b1fc9a7
perf: document `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43120
diff
changeset
|
1488 |
answered. |
ce315b1fc9a7
perf: document `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43120
diff
changeset
|
1489 |
""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1490 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1491 |
timer, fm = gettimer(ui, opts) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1492 |
b"a" in repo.dirstate |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1493 |
|
43197
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1494 |
if opts[b'iteration'] and opts[b'contains']: |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1495 |
msg = b'only specify one of --iteration or --contains' |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1496 |
raise error.Abort(msg) |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1497 |
|
43196
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1498 |
if opts[b'iteration']: |
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1499 |
setup = None |
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1500 |
dirstate = repo.dirstate |
43197
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1501 |
|
43196
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1502 |
def d(): |
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1503 |
for f in dirstate: |
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1504 |
pass |
43197
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1505 |
|
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1506 |
elif opts[b'contains']: |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1507 |
setup = None |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1508 |
dirstate = repo.dirstate |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1509 |
allfiles = list(dirstate) |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1510 |
# also add file path that will be "missing" from the dirstate |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1511 |
allfiles.extend([f[::-1] for f in allfiles]) |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1512 |
|
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1513 |
def d(): |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1514 |
for f in allfiles: |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1515 |
f in dirstate |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1516 |
|
43196
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1517 |
else: |
43197
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1518 |
|
43196
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1519 |
def setup(): |
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1520 |
repo.dirstate.invalidate() |
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1521 |
|
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1522 |
def d(): |
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1523 |
b"a" in repo.dirstate |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1524 |
|
43122
436a6a31df38
perf: use `setup` function in `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43121
diff
changeset
|
1525 |
timer(d, setup=setup) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1526 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1527 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1528 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1529 |
@command(b'perf::dirstatedirs|perfdirstatedirs', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1530 |
def perfdirstatedirs(ui, repo, **opts): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
1531 |
"""benchmap a 'dirstate.hasdir' call from an empty `dirs` cache""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1532 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1533 |
timer, fm = gettimer(ui, opts) |
43124
100e7e0cdaad
perf: use `setup` function in `perfdirstatedirs`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43123
diff
changeset
|
1534 |
repo.dirstate.hasdir(b"a") |
100e7e0cdaad
perf: use `setup` function in `perfdirstatedirs`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43123
diff
changeset
|
1535 |
|
100e7e0cdaad
perf: use `setup` function in `perfdirstatedirs`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43123
diff
changeset
|
1536 |
def setup(): |
47477
eb416759af7e
dirstate: Removed unused instances of `DirsMultiset`
Simon Sapin <simon.sapin@octobus.net>
parents:
47150
diff
changeset
|
1537 |
try: |
eb416759af7e
dirstate: Removed unused instances of `DirsMultiset`
Simon Sapin <simon.sapin@octobus.net>
parents:
47150
diff
changeset
|
1538 |
del repo.dirstate._map._dirs |
eb416759af7e
dirstate: Removed unused instances of `DirsMultiset`
Simon Sapin <simon.sapin@octobus.net>
parents:
47150
diff
changeset
|
1539 |
except AttributeError: |
eb416759af7e
dirstate: Removed unused instances of `DirsMultiset`
Simon Sapin <simon.sapin@octobus.net>
parents:
47150
diff
changeset
|
1540 |
pass |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1541 |
|
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1542 |
def d(): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1543 |
repo.dirstate.hasdir(b"a") |
43124
100e7e0cdaad
perf: use `setup` function in `perfdirstatedirs`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43123
diff
changeset
|
1544 |
|
100e7e0cdaad
perf: use `setup` function in `perfdirstatedirs`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43123
diff
changeset
|
1545 |
timer(d, setup=setup) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1546 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1547 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1548 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1549 |
@command(b'perf::dirstatefoldmap|perfdirstatefoldmap', formatteropts) |
27095
aaf4e2d77148
contrib/perf: name functions to match decorators
timeless <timeless@mozdev.org>
parents:
27072
diff
changeset
|
1550 |
def perfdirstatefoldmap(ui, repo, **opts): |
43125
56494a2bfe2f
perf: document `perfdirstatefoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43124
diff
changeset
|
1551 |
"""benchmap a `dirstate._map.filefoldmap.get()` request |
56494a2bfe2f
perf: document `perfdirstatefoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43124
diff
changeset
|
1552 |
|
56494a2bfe2f
perf: document `perfdirstatefoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43124
diff
changeset
|
1553 |
The dirstate filefoldmap cache is dropped between every request. |
56494a2bfe2f
perf: document `perfdirstatefoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43124
diff
changeset
|
1554 |
""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1555 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1556 |
timer, fm = gettimer(ui, opts) |
22780
d8ff1f671aed
perf: add a way to measure the perf of constructing the foldmap
Siddharth Agarwal <sid0@fb.com>
parents:
20846
diff
changeset
|
1557 |
dirstate = repo.dirstate |
43126
e337d8247375
perf: use `setup` function in `perfdirstatefoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43125
diff
changeset
|
1558 |
dirstate._map.filefoldmap.get(b'a') |
e337d8247375
perf: use `setup` function in `perfdirstatefoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43125
diff
changeset
|
1559 |
|
e337d8247375
perf: use `setup` function in `perfdirstatefoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43125
diff
changeset
|
1560 |
def setup(): |
e337d8247375
perf: use `setup` function in `perfdirstatefoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43125
diff
changeset
|
1561 |
del dirstate._map.filefoldmap |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1562 |
|
22780
d8ff1f671aed
perf: add a way to measure the perf of constructing the foldmap
Siddharth Agarwal <sid0@fb.com>
parents:
20846
diff
changeset
|
1563 |
def d(): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1564 |
dirstate._map.filefoldmap.get(b'a') |
43126
e337d8247375
perf: use `setup` function in `perfdirstatefoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43125
diff
changeset
|
1565 |
|
e337d8247375
perf: use `setup` function in `perfdirstatefoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43125
diff
changeset
|
1566 |
timer(d, setup=setup) |
24607
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
1567 |
fm.end() |
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
1568 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1569 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1570 |
@command(b'perf::dirfoldmap|perfdirfoldmap', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1571 |
def perfdirfoldmap(ui, repo, **opts): |
43127
0b32206c3c86
perf: document `perfdirfoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43126
diff
changeset
|
1572 |
"""benchmap a `dirstate._map.dirfoldmap.get()` request |
0b32206c3c86
perf: document `perfdirfoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43126
diff
changeset
|
1573 |
|
0b32206c3c86
perf: document `perfdirfoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43126
diff
changeset
|
1574 |
The dirstate dirfoldmap cache is dropped between every request. |
0b32206c3c86
perf: document `perfdirfoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43126
diff
changeset
|
1575 |
""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1576 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1577 |
timer, fm = gettimer(ui, opts) |
24607
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
1578 |
dirstate = repo.dirstate |
43128
ad801d4af7cd
perf: use `setup` function in `perfdirfoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43127
diff
changeset
|
1579 |
dirstate._map.dirfoldmap.get(b'a') |
ad801d4af7cd
perf: use `setup` function in `perfdirfoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43127
diff
changeset
|
1580 |
|
ad801d4af7cd
perf: use `setup` function in `perfdirfoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43127
diff
changeset
|
1581 |
def setup(): |
ad801d4af7cd
perf: use `setup` function in `perfdirfoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43127
diff
changeset
|
1582 |
del dirstate._map.dirfoldmap |
47477
eb416759af7e
dirstate: Removed unused instances of `DirsMultiset`
Simon Sapin <simon.sapin@octobus.net>
parents:
47150
diff
changeset
|
1583 |
try: |
eb416759af7e
dirstate: Removed unused instances of `DirsMultiset`
Simon Sapin <simon.sapin@octobus.net>
parents:
47150
diff
changeset
|
1584 |
del dirstate._map._dirs |
eb416759af7e
dirstate: Removed unused instances of `DirsMultiset`
Simon Sapin <simon.sapin@octobus.net>
parents:
47150
diff
changeset
|
1585 |
except AttributeError: |
eb416759af7e
dirstate: Removed unused instances of `DirsMultiset`
Simon Sapin <simon.sapin@octobus.net>
parents:
47150
diff
changeset
|
1586 |
pass |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1587 |
|
24607
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
1588 |
def d(): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1589 |
dirstate._map.dirfoldmap.get(b'a') |
43128
ad801d4af7cd
perf: use `setup` function in `perfdirfoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43127
diff
changeset
|
1590 |
|
ad801d4af7cd
perf: use `setup` function in `perfdirfoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43127
diff
changeset
|
1591 |
timer(d, setup=setup) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1592 |
fm.end() |
22780
d8ff1f671aed
perf: add a way to measure the perf of constructing the foldmap
Siddharth Agarwal <sid0@fb.com>
parents:
20846
diff
changeset
|
1593 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1594 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1595 |
@command(b'perf::dirstatewrite|perfdirstatewrite', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1596 |
def perfdirstatewrite(ui, repo, **opts): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
1597 |
"""benchmap the time it take to write a dirstate on disk""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1598 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1599 |
timer, fm = gettimer(ui, opts) |
16788
7e72c1609862
perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16785
diff
changeset
|
1600 |
ds = repo.dirstate |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1601 |
b"a" in ds |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1602 |
|
43130
c88075eb28e3
perf: use `setup` function in `perfdirstatewrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43129
diff
changeset
|
1603 |
def setup(): |
c88075eb28e3
perf: use `setup` function in `perfdirstatewrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43129
diff
changeset
|
1604 |
ds._dirty = True |
c88075eb28e3
perf: use `setup` function in `perfdirstatewrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43129
diff
changeset
|
1605 |
|
16788
7e72c1609862
perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16785
diff
changeset
|
1606 |
def d(): |
26748
5ba0a99ff27f
dirstate: make dirstate.write() callers pass transaction object to it
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25850
diff
changeset
|
1607 |
ds.write(repo.currenttransaction()) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1608 |
|
50008
e859f440daa9
locking: grab the wlock before touching the dirstate in `perfdirstatewrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49737
diff
changeset
|
1609 |
with repo.wlock(): |
e859f440daa9
locking: grab the wlock before touching the dirstate in `perfdirstatewrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49737
diff
changeset
|
1610 |
timer(d, setup=setup) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1611 |
fm.end() |
16788
7e72c1609862
perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16785
diff
changeset
|
1612 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1613 |
|
42383
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
1614 |
def _getmergerevs(repo, opts): |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
1615 |
"""parse command argument to return rev involved in merge |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
1616 |
|
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
1617 |
input: options dictionnary with `rev`, `from` and `bse` |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
1618 |
output: (localctx, otherctx, basectx) |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
1619 |
""" |
42392
4372d56112c9
perf: fix some missing b prefixes
Augie Fackler <augie@google.com>
parents:
42385
diff
changeset
|
1620 |
if opts[b'from']: |
4372d56112c9
perf: fix some missing b prefixes
Augie Fackler <augie@google.com>
parents:
42385
diff
changeset
|
1621 |
fromrev = scmutil.revsingle(repo, opts[b'from']) |
42381
e3ee707d42ad
perf: add a --from flag to perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42370
diff
changeset
|
1622 |
wctx = repo[fromrev] |
e3ee707d42ad
perf: add a --from flag to perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42370
diff
changeset
|
1623 |
else: |
e3ee707d42ad
perf: add a --from flag to perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42370
diff
changeset
|
1624 |
wctx = repo[None] |
e3ee707d42ad
perf: add a --from flag to perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42370
diff
changeset
|
1625 |
# we don't want working dir files to be stat'd in the benchmark, so |
e3ee707d42ad
perf: add a --from flag to perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42370
diff
changeset
|
1626 |
# prime that cache |
e3ee707d42ad
perf: add a --from flag to perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42370
diff
changeset
|
1627 |
wctx.dirty() |
42392
4372d56112c9
perf: fix some missing b prefixes
Augie Fackler <augie@google.com>
parents:
42385
diff
changeset
|
1628 |
rctx = scmutil.revsingle(repo, opts[b'rev'], opts[b'rev']) |
4372d56112c9
perf: fix some missing b prefixes
Augie Fackler <augie@google.com>
parents:
42385
diff
changeset
|
1629 |
if opts[b'base']: |
4372d56112c9
perf: fix some missing b prefixes
Augie Fackler <augie@google.com>
parents:
42385
diff
changeset
|
1630 |
fromrev = scmutil.revsingle(repo, opts[b'base']) |
42382
f0bcbbb6541c
perf: allow to specify the base of the merge in perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
1631 |
ancestor = repo[fromrev] |
f0bcbbb6541c
perf: allow to specify the base of the merge in perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
1632 |
else: |
f0bcbbb6541c
perf: allow to specify the base of the merge in perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
1633 |
ancestor = wctx.ancestor(rctx) |
42383
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
1634 |
return (wctx, rctx, ancestor) |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
1635 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1636 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1637 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1638 |
b'perf::mergecalculate|perfmergecalculate', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1639 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1640 |
(b'r', b'rev', b'.', b'rev to merge against'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1641 |
(b'', b'from', b'', b'rev to merge from'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1642 |
(b'', b'base', b'', b'the revision to use as base'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1643 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1644 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1645 |
) |
42383
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
1646 |
def perfmergecalculate(ui, repo, **opts): |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
1647 |
opts = _byteskwargs(opts) |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
1648 |
timer, fm = gettimer(ui, opts) |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
1649 |
|
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
1650 |
wctx, rctx, ancestor = _getmergerevs(repo, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1651 |
|
18817
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
1652 |
def d(): |
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
1653 |
# acceptremote is True because we don't want prompts in the middle of |
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
1654 |
# our benchmark |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1655 |
merge.calculateupdates( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1656 |
repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1657 |
wctx, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1658 |
rctx, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1659 |
[ancestor], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1660 |
branchmerge=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1661 |
force=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1662 |
acceptremote=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1663 |
followcopies=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1664 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1665 |
|
18817
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
1666 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1667 |
fm.end() |
18817
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
1668 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1669 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1670 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1671 |
b'perf::mergecopies|perfmergecopies', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1672 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1673 |
(b'r', b'rev', b'.', b'rev to merge against'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1674 |
(b'', b'from', b'', b'rev to merge from'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1675 |
(b'', b'base', b'', b'the revision to use as base'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1676 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1677 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1678 |
) |
42384
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1679 |
def perfmergecopies(ui, repo, **opts): |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1680 |
"""measure runtime of `copies.mergecopies`""" |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1681 |
opts = _byteskwargs(opts) |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1682 |
timer, fm = gettimer(ui, opts) |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1683 |
wctx, rctx, ancestor = _getmergerevs(repo, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1684 |
|
42384
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1685 |
def d(): |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1686 |
# acceptremote is True because we don't want prompts in the middle of |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1687 |
# our benchmark |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1688 |
copies.mergecopies(repo, wctx, rctx, ancestor) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1689 |
|
42384
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1690 |
timer(d) |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1691 |
fm.end() |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1692 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1693 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1694 |
@command(b'perf::pathcopies|perfpathcopies', [], b"REV REV") |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1695 |
def perfpathcopies(ui, repo, rev1, rev2, **opts): |
40739
dc3ab5e5fe64
perf: add a docstring to `perfpathcopies`
Boris Feld <boris.feld@octobus.net>
parents:
40731
diff
changeset
|
1696 |
"""benchmark the copy tracing logic""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1697 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1698 |
timer, fm = gettimer(ui, opts) |
18877
2e9fe9e2671f
perf: add a command to test copies.pathcopies perf
Siddharth Agarwal <sid0@fb.com>
parents:
18871
diff
changeset
|
1699 |
ctx1 = scmutil.revsingle(repo, rev1, rev1) |
2e9fe9e2671f
perf: add a command to test copies.pathcopies perf
Siddharth Agarwal <sid0@fb.com>
parents:
18871
diff
changeset
|
1700 |
ctx2 = scmutil.revsingle(repo, rev2, rev2) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1701 |
|
18877
2e9fe9e2671f
perf: add a command to test copies.pathcopies perf
Siddharth Agarwal <sid0@fb.com>
parents:
18871
diff
changeset
|
1702 |
def d(): |
2e9fe9e2671f
perf: add a command to test copies.pathcopies perf
Siddharth Agarwal <sid0@fb.com>
parents:
18871
diff
changeset
|
1703 |
copies.pathcopies(ctx1, ctx2) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1704 |
|
18877
2e9fe9e2671f
perf: add a command to test copies.pathcopies perf
Siddharth Agarwal <sid0@fb.com>
parents:
18871
diff
changeset
|
1705 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1706 |
fm.end() |
18877
2e9fe9e2671f
perf: add a command to test copies.pathcopies perf
Siddharth Agarwal <sid0@fb.com>
parents:
18871
diff
changeset
|
1707 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1708 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1709 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1710 |
b'perf::phases|perfphases', |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
1711 |
[ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
1712 |
(b'', b'full', False, b'include file reading time too'), |
51399
46fed351e451
perf: support --template on perf::phases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51152
diff
changeset
|
1713 |
] |
46fed351e451
perf: support --template on perf::phases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51152
diff
changeset
|
1714 |
+ formatteropts, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1715 |
b"", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1716 |
) |
32467
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
1717 |
def perfphases(ui, repo, **opts): |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
1718 |
"""benchmark phasesets computation""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1719 |
opts = _byteskwargs(opts) |
32467
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
1720 |
timer, fm = gettimer(ui, opts) |
32732
e36569bd9e28
perfphases: add a flag to also include file access time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32731
diff
changeset
|
1721 |
_phases = repo._phasecache |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1722 |
full = opts.get(b'full') |
51413
8fc92193a2cf
phases: use a more generic way to trigger a phases computation for perf
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51152
diff
changeset
|
1723 |
tip_rev = repo.changelog.tiprev() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1724 |
|
32467
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
1725 |
def d(): |
32732
e36569bd9e28
perfphases: add a flag to also include file access time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32731
diff
changeset
|
1726 |
phases = _phases |
e36569bd9e28
perfphases: add a flag to also include file access time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32731
diff
changeset
|
1727 |
if full: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1728 |
clearfilecache(repo, b'_phasecache') |
32732
e36569bd9e28
perfphases: add a flag to also include file access time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32731
diff
changeset
|
1729 |
phases = repo._phasecache |
32467
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
1730 |
phases.invalidate() |
51413
8fc92193a2cf
phases: use a more generic way to trigger a phases computation for perf
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51152
diff
changeset
|
1731 |
phases.phase(repo, tip_rev) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1732 |
|
32467
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
1733 |
timer(d) |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
1734 |
fm.end() |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
1735 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1736 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1737 |
@command(b'perf::phasesremote|perfphasesremote', [], b"[DEST]") |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1738 |
def perfphasesremote(ui, repo, dest=None, **opts): |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1739 |
"""benchmark time needed to analyse phases of the remote server""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1740 |
from mercurial.node import bin |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1741 |
from mercurial import ( |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1742 |
exchange, |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1743 |
hg, |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1744 |
phases, |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1745 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1746 |
|
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1747 |
opts = _byteskwargs(opts) |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1748 |
timer, fm = gettimer(ui, opts) |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1749 |
|
46720
66fb04552122
ui: pass a `ui` object to `paths.getpath`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46388
diff
changeset
|
1750 |
path = ui.getpath(dest, default=(b'default-push', b'default')) |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1751 |
if not path: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1752 |
raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1753 |
b'default repository not configured!', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1754 |
hint=b"see 'hg help config.paths'", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1755 |
) |
49705
ec8140c44b14
path: update logic in `perf` to use the push variant when available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49562
diff
changeset
|
1756 |
if util.safehasattr(path, 'main_path'): |
ec8140c44b14
path: update logic in `perf` to use the push variant when available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49562
diff
changeset
|
1757 |
path = path.get_push_variant() |
ec8140c44b14
path: update logic in `perf` to use the push variant when available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49562
diff
changeset
|
1758 |
dest = path.loc |
ec8140c44b14
path: update logic in `perf` to use the push variant when available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49562
diff
changeset
|
1759 |
else: |
ec8140c44b14
path: update logic in `perf` to use the push variant when available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49562
diff
changeset
|
1760 |
dest = path.pushloc or path.loc |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1761 |
ui.statusnoi18n(b'analysing phase of %s\n' % util.hidepassword(dest)) |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1762 |
other = hg.peer(repo, opts, dest) |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1763 |
|
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1764 |
# easier to perform discovery through the operation |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1765 |
op = exchange.pushoperation(repo, other) |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1766 |
exchange._pushdiscoverychangeset(op) |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1767 |
|
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1768 |
remotesubset = op.fallbackheads |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1769 |
|
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1770 |
with other.commandexecutor() as e: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1771 |
remotephases = e.callcommand( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1772 |
b'listkeys', {b'namespace': b'phases'} |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1773 |
).result() |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1774 |
del other |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1775 |
publishing = remotephases.get(b'publishing', False) |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1776 |
if publishing: |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1777 |
ui.statusnoi18n(b'publishing: yes\n') |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1778 |
else: |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1779 |
ui.statusnoi18n(b'publishing: no\n') |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1780 |
|
43551
3350d7aefe67
perf: make `perfphasesremote` use the new `index.has_node` api
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43527
diff
changeset
|
1781 |
has_node = getattr(repo.changelog.index, 'has_node', None) |
3350d7aefe67
perf: make `perfphasesremote` use the new `index.has_node` api
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43527
diff
changeset
|
1782 |
if has_node is None: |
3350d7aefe67
perf: make `perfphasesremote` use the new `index.has_node` api
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43527
diff
changeset
|
1783 |
has_node = repo.changelog.nodemap.__contains__ |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1784 |
nonpublishroots = 0 |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1785 |
for nhex, phase in remotephases.iteritems(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1786 |
if nhex == b'publishing': # ignore data related to publish option |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1787 |
continue |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1788 |
node = bin(nhex) |
43551
3350d7aefe67
perf: make `perfphasesremote` use the new `index.has_node` api
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43527
diff
changeset
|
1789 |
if has_node(node) and int(phase): |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1790 |
nonpublishroots += 1 |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1791 |
ui.statusnoi18n(b'number of roots: %d\n' % len(remotephases)) |
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1792 |
ui.statusnoi18n(b'number of known non public roots: %d\n' % nonpublishroots) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1793 |
|
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1794 |
def d(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1795 |
phases.remotephasessummary(repo, remotesubset, remotephases) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1796 |
|
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1797 |
timer(d) |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1798 |
fm.end() |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1799 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1800 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1801 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1802 |
b'perf::manifest|perfmanifest', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1803 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1804 |
(b'm', b'manifest-rev', False, b'Look up a manifest node revision'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1805 |
(b'', b'clear-disk', False, b'clear on-disk caches too'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1806 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1807 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1808 |
b'REV|NODE', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1809 |
) |
38780
ddb15a83ae0b
debug: allow specifying a manifest node rather than a revision
Martijn Pieters <mj@zopatista.com>
parents:
38778
diff
changeset
|
1810 |
def perfmanifest(ui, repo, rev, manifest_rev=False, clear_disk=False, **opts): |
38693
9b6a708f2263
perf: document the perfmanifest command
Boris Feld <boris.feld@octobus.net>
parents:
38273
diff
changeset
|
1811 |
"""benchmark the time to read a manifest from disk and return a usable |
9b6a708f2263
perf: document the perfmanifest command
Boris Feld <boris.feld@octobus.net>
parents:
38273
diff
changeset
|
1812 |
dict-like object |
9b6a708f2263
perf: document the perfmanifest command
Boris Feld <boris.feld@octobus.net>
parents:
38273
diff
changeset
|
1813 |
|
9b6a708f2263
perf: document the perfmanifest command
Boris Feld <boris.feld@octobus.net>
parents:
38273
diff
changeset
|
1814 |
Manifest caches are cleared before retrieval.""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1815 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1816 |
timer, fm = gettimer(ui, opts) |
38780
ddb15a83ae0b
debug: allow specifying a manifest node rather than a revision
Martijn Pieters <mj@zopatista.com>
parents:
38778
diff
changeset
|
1817 |
if not manifest_rev: |
ddb15a83ae0b
debug: allow specifying a manifest node rather than a revision
Martijn Pieters <mj@zopatista.com>
parents:
38778
diff
changeset
|
1818 |
ctx = scmutil.revsingle(repo, rev, rev) |
ddb15a83ae0b
debug: allow specifying a manifest node rather than a revision
Martijn Pieters <mj@zopatista.com>
parents:
38778
diff
changeset
|
1819 |
t = ctx.manifestnode() |
ddb15a83ae0b
debug: allow specifying a manifest node rather than a revision
Martijn Pieters <mj@zopatista.com>
parents:
38778
diff
changeset
|
1820 |
else: |
39318
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1821 |
from mercurial.node import bin |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1822 |
|
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1823 |
if len(rev) == 40: |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1824 |
t = bin(rev) |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1825 |
else: |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1826 |
try: |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1827 |
rev = int(rev) |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1828 |
|
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1829 |
if util.safehasattr(repo.manifestlog, b'getstorage'): |
39318
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1830 |
t = repo.manifestlog.getstorage(b'').node(rev) |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1831 |
else: |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1832 |
t = repo.manifestlog._revlog.lookup(rev) |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1833 |
except ValueError: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1834 |
raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43080
diff
changeset
|
1835 |
b'manifest revision must be integer or full node' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1836 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1837 |
|
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1838 |
def d(): |
38781
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38780
diff
changeset
|
1839 |
repo.manifestlog.clearcaches(clear_persisted_data=clear_disk) |
30369
d79c141fdf41
manifest: remove usages of manifest.read
Durham Goode <durham@fb.com>
parents:
30337
diff
changeset
|
1840 |
repo.manifestlog[t].read() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1841 |
|
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1842 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1843 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1844 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1845 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1846 |
@command(b'perf::changeset|perfchangeset', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1847 |
def perfchangeset(ui, repo, rev, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1848 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1849 |
timer, fm = gettimer(ui, opts) |
37355
5bcd5859b505
perf: make perfmanifest and perfnodelookup work with revsets
Martin von Zweigbergk <martinvonz@google.com>
parents:
37269
diff
changeset
|
1850 |
n = scmutil.revsingle(repo, rev).node() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1851 |
|
16262
bf7a6c3b2a4a
perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents:
16260
diff
changeset
|
1852 |
def d(): |
19378
9de689d20230
cleanup: drop unused variables and an unused import
Simon Heimberg <simohe@besonet.ch>
parents:
19322
diff
changeset
|
1853 |
repo.changelog.read(n) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1854 |
# repo.changelog._cache = None |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1855 |
|
16262
bf7a6c3b2a4a
perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents:
16260
diff
changeset
|
1856 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1857 |
fm.end() |
16262
bf7a6c3b2a4a
perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents:
16260
diff
changeset
|
1858 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1859 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1860 |
@command(b'perf::ignore|perfignore', formatteropts) |
40750
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1861 |
def perfignore(ui, repo, **opts): |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1862 |
"""benchmark operation related to computing ignore""" |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1863 |
opts = _byteskwargs(opts) |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1864 |
timer, fm = gettimer(ui, opts) |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1865 |
dirstate = repo.dirstate |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1866 |
|
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1867 |
def setupone(): |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1868 |
dirstate.invalidate() |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1869 |
clearfilecache(dirstate, b'_ignore') |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1870 |
|
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1871 |
def runone(): |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1872 |
dirstate._ignore |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1873 |
|
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1874 |
timer(runone, setup=setupone, title=b"load") |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1875 |
fm.end() |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1876 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1877 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1878 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1879 |
b'perf::index|perfindex', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1880 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1881 |
(b'', b'rev', [], b'revision to be looked up (default tip)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1882 |
(b'', b'no-lookup', None, b'do not revision lookup post creation'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1883 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1884 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1885 |
) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1886 |
def perfindex(ui, repo, **opts): |
41437
d65ba1ff4559
perf: add some documentation to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41436
diff
changeset
|
1887 |
"""benchmark index creation time followed by a lookup |
d65ba1ff4559
perf: add some documentation to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41436
diff
changeset
|
1888 |
|
d65ba1ff4559
perf: add some documentation to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41436
diff
changeset
|
1889 |
The default is to look `tip` up. Depending on the index implementation, |
d65ba1ff4559
perf: add some documentation to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41436
diff
changeset
|
1890 |
the revision looked up can matters. For example, an implementation |
d65ba1ff4559
perf: add some documentation to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41436
diff
changeset
|
1891 |
scanning the index will have a faster lookup time for `--rev tip` than for |
41439
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1892 |
`--rev 0`. The number of looked up revisions and their order can also |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1893 |
matters. |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1894 |
|
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1895 |
Example of useful set to test: |
44260
216fc4633800
perf: fix list formatting in perfindex documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43976
diff
changeset
|
1896 |
|
41439
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1897 |
* tip |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1898 |
* 0 |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1899 |
* -10: |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1900 |
* :10 |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1901 |
* -10: + :10 |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1902 |
* :10: + -10: |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1903 |
* -10000: |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1904 |
* -10000: + 0 |
41437
d65ba1ff4559
perf: add some documentation to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41436
diff
changeset
|
1905 |
|
41469
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1906 |
It is not currently possible to check for lookup of a missing node. For |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1907 |
deeper lookup benchmarking, checkout the `perfnodemap` command.""" |
13255
2696730ca233
perf: make perfindex results useful on hg with lazyparser
Matt Mackall <mpm@selenic.com>
parents:
13254
diff
changeset
|
1908 |
import mercurial.revlog |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1909 |
|
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1910 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1911 |
timer, fm = gettimer(ui, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1912 |
mercurial.revlog._prereadsize = 2 ** 24 # disable lazy parser in old hg |
41438
e9891c734bf8
perf: add a no-lookup variant to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41437
diff
changeset
|
1913 |
if opts[b'no_lookup']: |
41439
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1914 |
if opts['rev']: |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1915 |
raise error.Abort('--no-lookup and --rev are mutually exclusive') |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1916 |
nodes = [] |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1917 |
elif not opts[b'rev']: |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1918 |
nodes = [repo[b"tip"].node()] |
40784
a0f2641ddd61
perf: add a --rev attribute to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
40783
diff
changeset
|
1919 |
else: |
41439
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1920 |
revs = scmutil.revrange(repo, opts[b'rev']) |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1921 |
cl = repo.changelog |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1922 |
nodes = [cl.node(r) for r in revs] |
40783
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40772
diff
changeset
|
1923 |
|
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40772
diff
changeset
|
1924 |
unfi = repo.unfiltered() |
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40772
diff
changeset
|
1925 |
# find the filecache func directly |
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40772
diff
changeset
|
1926 |
# This avoid polluting the benchmark with the filecache logic |
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40772
diff
changeset
|
1927 |
makecl = unfi.__class__.changelog.func |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1928 |
|
40783
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40772
diff
changeset
|
1929 |
def setup(): |
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40772
diff
changeset
|
1930 |
# probably not necessary, but for good measure |
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40772
diff
changeset
|
1931 |
clearchangelog(unfi) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1932 |
|
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1933 |
def d(): |
40783
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40772
diff
changeset
|
1934 |
cl = makecl(unfi) |
41439
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1935 |
for n in nodes: |
41438
e9891c734bf8
perf: add a no-lookup variant to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41437
diff
changeset
|
1936 |
cl.rev(n) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1937 |
|
40783
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40772
diff
changeset
|
1938 |
timer(d, setup=setup) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1939 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1940 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1941 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1942 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
1943 |
b'perf::nodemap|perfnodemap', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1944 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1945 |
(b'', b'rev', [], b'revision to be looked up (default tip)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1946 |
(b'', b'clear-caches', True, b'clear revlog cache between calls'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1947 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1948 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1949 |
) |
41469
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1950 |
def perfnodemap(ui, repo, **opts): |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1951 |
"""benchmark the time necessary to look up revision from a cold nodemap |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1952 |
|
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1953 |
Depending on the implementation, the amount and order of revision we look |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1954 |
up can varies. Example of useful set to test: |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1955 |
* tip |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1956 |
* 0 |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1957 |
* -10: |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1958 |
* :10 |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1959 |
* -10: + :10 |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1960 |
* :10: + -10: |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1961 |
* -10000: |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1962 |
* -10000: + 0 |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1963 |
|
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1964 |
The command currently focus on valid binary lookup. Benchmarking for |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1965 |
hexlookup, prefix lookup and missing lookup would also be valuable. |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1966 |
""" |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1967 |
import mercurial.revlog |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1968 |
|
41469
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1969 |
opts = _byteskwargs(opts) |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1970 |
timer, fm = gettimer(ui, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1971 |
mercurial.revlog._prereadsize = 2 ** 24 # disable lazy parser in old hg |
41469
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1972 |
|
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1973 |
unfi = repo.unfiltered() |
46196
96b73671753a
contrib: py3 compat for perfnodemap
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1974 |
clearcaches = opts[b'clear_caches'] |
41469
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1975 |
# find the filecache func directly |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1976 |
# This avoid polluting the benchmark with the filecache logic |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1977 |
makecl = unfi.__class__.changelog.func |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1978 |
if not opts[b'rev']: |
46196
96b73671753a
contrib: py3 compat for perfnodemap
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1979 |
raise error.Abort(b'use --rev to specify revisions to look up') |
41469
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1980 |
revs = scmutil.revrange(repo, opts[b'rev']) |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1981 |
cl = repo.changelog |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1982 |
nodes = [cl.node(r) for r in revs] |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1983 |
|
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1984 |
# use a list to pass reference to a nodemap from one closure to the next |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1985 |
nodeget = [None] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
1986 |
|
41469
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1987 |
def setnodeget(): |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1988 |
# probably not necessary, but for good measure |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1989 |
clearchangelog(unfi) |
43571
22cd0064370d
perf: make `perfnodemap` use the new `index.get_rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43551
diff
changeset
|
1990 |
cl = makecl(unfi) |
22cd0064370d
perf: make `perfnodemap` use the new `index.get_rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43551
diff
changeset
|
1991 |
if util.safehasattr(cl.index, 'get_rev'): |
22cd0064370d
perf: make `perfnodemap` use the new `index.get_rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43551
diff
changeset
|
1992 |
nodeget[0] = cl.index.get_rev |
22cd0064370d
perf: make `perfnodemap` use the new `index.get_rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43551
diff
changeset
|
1993 |
else: |
22cd0064370d
perf: make `perfnodemap` use the new `index.get_rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43551
diff
changeset
|
1994 |
nodeget[0] = cl.nodemap.get |
41469
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1995 |
|
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1996 |
def d(): |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1997 |
get = nodeget[0] |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1998 |
for n in nodes: |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1999 |
get(n) |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
2000 |
|
41470
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41469
diff
changeset
|
2001 |
setup = None |
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41469
diff
changeset
|
2002 |
if clearcaches: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2003 |
|
41470
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41469
diff
changeset
|
2004 |
def setup(): |
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41469
diff
changeset
|
2005 |
setnodeget() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2006 |
|
41470
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41469
diff
changeset
|
2007 |
else: |
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41469
diff
changeset
|
2008 |
setnodeget() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2009 |
d() # prewarm the data structure |
41469
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
2010 |
timer(d, setup=setup) |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
2011 |
fm.end() |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
2012 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2013 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
2014 |
@command(b'perf::startup|perfstartup', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2015 |
def perfstartup(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2016 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2017 |
timer, fm = gettimer(ui, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2018 |
|
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2019 |
def d(): |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
2020 |
if os.name != 'nt': |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2021 |
os.system( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2022 |
b"HGRCPATH= %s version -q > /dev/null" % fsencode(sys.argv[0]) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2023 |
) |
27382
de7bcbc68042
perf: adjust perfstartup() for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
27345
diff
changeset
|
2024 |
else: |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
2025 |
os.environ['HGRCPATH'] = r' ' |
43503
313e3a279828
cleanup: remove pointless r-prefixes on double-quoted strings
Augie Fackler <augie@google.com>
parents:
43495
diff
changeset
|
2026 |
os.system("%s version -q > NUL" % sys.argv[0]) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2027 |
|
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2028 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
2029 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2030 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2031 |
|
50674
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2032 |
def _find_stream_generator(version): |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2033 |
"""find the proper generator function for this stream version""" |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2034 |
import mercurial.streamclone |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2035 |
|
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2036 |
available = {} |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2037 |
|
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2038 |
# try to fetch a v1 generator |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2039 |
generatev1 = getattr(mercurial.streamclone, "generatev1", None) |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2040 |
if generatev1 is not None: |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2041 |
|
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2042 |
def generate(repo): |
51544
06671781b04d
perf-stream-locked-section: actually use v1 generation when requested
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51519
diff
changeset
|
2043 |
entries, bytes, data = generatev1(repo, None, None, True) |
50674
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2044 |
return data |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2045 |
|
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2046 |
available[b'v1'] = generatev1 |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2047 |
# try to fetch a v2 generator |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2048 |
generatev2 = getattr(mercurial.streamclone, "generatev2", None) |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2049 |
if generatev2 is not None: |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2050 |
|
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2051 |
def generate(repo): |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2052 |
entries, bytes, data = generatev2(repo, None, None, True) |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2053 |
return data |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2054 |
|
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2055 |
available[b'v2'] = generate |
50675
3ce370a00225
perf: add support for stream-v3 during benchmark
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50674
diff
changeset
|
2056 |
# try to fetch a v3 generator |
3ce370a00225
perf: add support for stream-v3 during benchmark
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50674
diff
changeset
|
2057 |
generatev3 = getattr(mercurial.streamclone, "generatev3", None) |
3ce370a00225
perf: add support for stream-v3 during benchmark
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50674
diff
changeset
|
2058 |
if generatev3 is not None: |
3ce370a00225
perf: add support for stream-v3 during benchmark
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50674
diff
changeset
|
2059 |
|
3ce370a00225
perf: add support for stream-v3 during benchmark
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50674
diff
changeset
|
2060 |
def generate(repo): |
51545
700783ed3415
perf-stream-locked-section: fix the call to the v3 generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51544
diff
changeset
|
2061 |
return generatev3(repo, None, None, True) |
50675
3ce370a00225
perf: add support for stream-v3 during benchmark
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50674
diff
changeset
|
2062 |
|
3ce370a00225
perf: add support for stream-v3 during benchmark
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50674
diff
changeset
|
2063 |
available[b'v3-exp'] = generate |
3ce370a00225
perf: add support for stream-v3 during benchmark
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50674
diff
changeset
|
2064 |
|
50674
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2065 |
# resolve the request |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2066 |
if version == b"latest": |
50675
3ce370a00225
perf: add support for stream-v3 during benchmark
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50674
diff
changeset
|
2067 |
# latest is the highest non experimental version |
3ce370a00225
perf: add support for stream-v3 during benchmark
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50674
diff
changeset
|
2068 |
latest_key = max(v for v in available if b'-exp' not in v) |
50674
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2069 |
return available[latest_key] |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2070 |
elif version in available: |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2071 |
return available[version] |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2072 |
else: |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2073 |
msg = b"unkown or unavailable version: %s" |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2074 |
msg %= version |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2075 |
hint = b"available versions: %s" |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2076 |
hint %= b', '.join(sorted(available)) |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2077 |
raise error.Abort(msg, hint=hint) |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2078 |
|
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2079 |
|
50458
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2080 |
@command( |
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2081 |
b'perf::stream-locked-section', |
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2082 |
[ |
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2083 |
( |
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2084 |
b'', |
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2085 |
b'stream-version', |
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2086 |
b'latest', |
51546
f376c4d5c4b6
perf-stream-locked-section: advertise the right version key in the help
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51545
diff
changeset
|
2087 |
b'stream version to use ("v1", "v2", "v3-exp" ' |
f376c4d5c4b6
perf-stream-locked-section: advertise the right version key in the help
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51545
diff
changeset
|
2088 |
b'or "latest", (the default))', |
50458
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2089 |
), |
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2090 |
] |
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2091 |
+ formatteropts, |
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2092 |
) |
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2093 |
def perf_stream_clone_scan(ui, repo, stream_version, **opts): |
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2094 |
"""benchmark the initial, repo-locked, section of a stream-clone""" |
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2095 |
|
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2096 |
opts = _byteskwargs(opts) |
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2097 |
timer, fm = gettimer(ui, opts) |
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2098 |
|
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2099 |
# deletion of the generator may trigger some cleanup that we do not want to |
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2100 |
# measure |
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2101 |
result_holder = [None] |
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2102 |
|
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2103 |
def setupone(): |
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2104 |
result_holder[0] = None |
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2105 |
|
50674
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2106 |
generate = _find_stream_generator(stream_version) |
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2107 |
|
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2108 |
def runone(): |
50458
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2109 |
# the lock is held for the duration the initialisation |
50674
b10c786b0145
perf: add a function to find a stream version generator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50458
diff
changeset
|
2110 |
result_holder[0] = generate(repo) |
50458
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2111 |
|
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2112 |
timer(runone, setup=setupone, title=b"load") |
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2113 |
fm.end() |
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2114 |
|
714b63a707b7
perf: introduce a `perf::stream-locked-section` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50143
diff
changeset
|
2115 |
|
50677
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2116 |
@command( |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2117 |
b'perf::stream-generate', |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2118 |
[ |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2119 |
( |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2120 |
b'', |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2121 |
b'stream-version', |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2122 |
b'latest', |
51546
f376c4d5c4b6
perf-stream-locked-section: advertise the right version key in the help
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51545
diff
changeset
|
2123 |
b'stream version to us ("v1", "v2", "v3-exp" ' |
f376c4d5c4b6
perf-stream-locked-section: advertise the right version key in the help
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51545
diff
changeset
|
2124 |
b'or "latest", (the default))', |
50677
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2125 |
), |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2126 |
] |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2127 |
+ formatteropts, |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2128 |
) |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2129 |
def perf_stream_clone_generate(ui, repo, stream_version, **opts): |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2130 |
"""benchmark the full generation of a stream clone""" |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2131 |
|
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2132 |
opts = _byteskwargs(opts) |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2133 |
timer, fm = gettimer(ui, opts) |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2134 |
|
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2135 |
# deletion of the generator may trigger some cleanup that we do not want to |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2136 |
# measure |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2137 |
|
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2138 |
generate = _find_stream_generator(stream_version) |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2139 |
|
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2140 |
def runone(): |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2141 |
# the lock is held for the duration the initialisation |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2142 |
for chunk in generate(repo): |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2143 |
pass |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2144 |
|
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2145 |
timer(runone, title=b"generate") |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2146 |
fm.end() |
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2147 |
|
b8de54ac5a21
perf: add a perf::stream-generate command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50676
diff
changeset
|
2148 |
|
50678
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2149 |
@command( |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2150 |
b'perf::stream-consume', |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2151 |
formatteropts, |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2152 |
) |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2153 |
def perf_stream_clone_consume(ui, repo, filename, **opts): |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2154 |
"""benchmark the full application of a stream clone |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2155 |
|
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2156 |
This include the creation of the repository |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2157 |
""" |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2158 |
# try except to appease check code |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2159 |
msg = b"mercurial too old, missing necessary module: %s" |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2160 |
try: |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2161 |
from mercurial import bundle2 |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2162 |
except ImportError as exc: |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2163 |
msg %= _bytestr(exc) |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2164 |
raise error.Abort(msg) |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2165 |
try: |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2166 |
from mercurial import exchange |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2167 |
except ImportError as exc: |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2168 |
msg %= _bytestr(exc) |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2169 |
raise error.Abort(msg) |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2170 |
try: |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2171 |
from mercurial import hg |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2172 |
except ImportError as exc: |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2173 |
msg %= _bytestr(exc) |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2174 |
raise error.Abort(msg) |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2175 |
try: |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2176 |
from mercurial import localrepo |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2177 |
except ImportError as exc: |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2178 |
msg %= _bytestr(exc) |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2179 |
raise error.Abort(msg) |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2180 |
|
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2181 |
opts = _byteskwargs(opts) |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2182 |
timer, fm = gettimer(ui, opts) |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2183 |
|
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2184 |
# deletion of the generator may trigger some cleanup that we do not want to |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2185 |
# measure |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2186 |
if not (os.path.isfile(filename) and os.access(filename, os.R_OK)): |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2187 |
raise error.Abort("not a readable file: %s" % filename) |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2188 |
|
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2189 |
run_variables = [None, None] |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2190 |
|
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2191 |
@contextlib.contextmanager |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2192 |
def context(): |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2193 |
with open(filename, mode='rb') as bundle: |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2194 |
with tempfile.TemporaryDirectory() as tmp_dir: |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2195 |
tmp_dir = fsencode(tmp_dir) |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2196 |
run_variables[0] = bundle |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2197 |
run_variables[1] = tmp_dir |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2198 |
yield |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2199 |
run_variables[0] = None |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2200 |
run_variables[1] = None |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2201 |
|
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2202 |
def runone(): |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2203 |
bundle = run_variables[0] |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2204 |
tmp_dir = run_variables[1] |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2205 |
# only pass ui when no srcrepo |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2206 |
localrepo.createrepository( |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2207 |
repo.ui, tmp_dir, requirements=repo.requirements |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2208 |
) |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2209 |
target = hg.repository(repo.ui, tmp_dir) |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2210 |
gen = exchange.readbundle(target.ui, bundle, bundle.name) |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2211 |
# stream v1 |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2212 |
if util.safehasattr(gen, 'apply'): |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2213 |
gen.apply(target) |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2214 |
else: |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2215 |
with target.transaction(b"perf::stream-consume") as tr: |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2216 |
bundle2.applybundle( |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2217 |
target, |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2218 |
gen, |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2219 |
tr, |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2220 |
source=b'unbundle', |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2221 |
url=filename, |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2222 |
) |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2223 |
|
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2224 |
timer(runone, context=context, title=b"consume") |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2225 |
fm.end() |
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2226 |
|
459681233b1f
perf: add a perf::stream-consume
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50677
diff
changeset
|
2227 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
2228 |
@command(b'perf::parents|perfparents', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2229 |
def perfparents(ui, repo, **opts): |
42016
b900b392c1cc
perf: document perfparents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42015
diff
changeset
|
2230 |
"""benchmark the time necessary to fetch one changeset's parents. |
b900b392c1cc
perf: document perfparents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42015
diff
changeset
|
2231 |
|
42021
4c700c847aa2
perf: copyedit a few documentation strings
Augie Fackler <augie@google.com>
parents:
42019
diff
changeset
|
2232 |
The fetch is done using the `node identifier`, traversing all object layers |
4c700c847aa2
perf: copyedit a few documentation strings
Augie Fackler <augie@google.com>
parents:
42019
diff
changeset
|
2233 |
from the repository object. The first N revisions will be used for this |
42016
b900b392c1cc
perf: document perfparents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42015
diff
changeset
|
2234 |
benchmark. N is controlled by the ``perf.parentscount`` config option |
b900b392c1cc
perf: document perfparents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42015
diff
changeset
|
2235 |
(default: 1000). |
b900b392c1cc
perf: document perfparents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42015
diff
changeset
|
2236 |
""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2237 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2238 |
timer, fm = gettimer(ui, opts) |
27305
5831cfbf0e33
perf: perfparents honor config perf.parentscount
timeless <timeless@mozdev.org>
parents:
27304
diff
changeset
|
2239 |
# control the number of commits perfparents iterates over |
5831cfbf0e33
perf: perfparents honor config perf.parentscount
timeless <timeless@mozdev.org>
parents:
27304
diff
changeset
|
2240 |
# experimental config: perf.parentscount |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2241 |
count = getint(ui, b"perf", b"parentscount", 1000) |
27305
5831cfbf0e33
perf: perfparents honor config perf.parentscount
timeless <timeless@mozdev.org>
parents:
27304
diff
changeset
|
2242 |
if len(repo.changelog) < count: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2243 |
raise error.Abort(b"repo needs %d commits for this test" % count) |
27100
8d5dba93aa4f
contrib/perf: perfparents handle filtered repos
timeless <timeless@mozdev.org>
parents:
27099
diff
changeset
|
2244 |
repo = repo.unfiltered() |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
2245 |
nl = [repo.changelog.node(i) for i in _xrange(count)] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2246 |
|
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2247 |
def d(): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2248 |
for n in nl: |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2249 |
repo.changelog.parents(n) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2250 |
|
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2251 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
2252 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2253 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2254 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
2255 |
@command(b'perf::ctxfiles|perfctxfiles', formatteropts) |
27095
aaf4e2d77148
contrib/perf: name functions to match decorators
timeless <timeless@mozdev.org>
parents:
27072
diff
changeset
|
2256 |
def perfctxfiles(ui, repo, x, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2257 |
opts = _byteskwargs(opts) |
24349
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
2258 |
x = int(x) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2259 |
timer, fm = gettimer(ui, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2260 |
|
24349
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
2261 |
def d(): |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
2262 |
len(repo[x].files()) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2263 |
|
24349
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
2264 |
timer(d) |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
2265 |
fm.end() |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
2266 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2267 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
2268 |
@command(b'perf::rawfiles|perfrawfiles', formatteropts) |
27095
aaf4e2d77148
contrib/perf: name functions to match decorators
timeless <timeless@mozdev.org>
parents:
27072
diff
changeset
|
2269 |
def perfrawfiles(ui, repo, x, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2270 |
opts = _byteskwargs(opts) |
24349
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
2271 |
x = int(x) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2272 |
timer, fm = gettimer(ui, opts) |
24349
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
2273 |
cl = repo.changelog |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2274 |
|
24349
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
2275 |
def d(): |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
2276 |
len(cl.read(x)[3]) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2277 |
|
24349
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
2278 |
timer(d) |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
2279 |
fm.end() |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
2280 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2281 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
2282 |
@command(b'perf::lookup|perflookup', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2283 |
def perflookup(ui, repo, rev, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2284 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2285 |
timer, fm = gettimer(ui, opts) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2286 |
timer(lambda: len(repo.lookup(rev))) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
2287 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2288 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2289 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2290 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
2291 |
b'perf::linelogedits|perflinelogedits', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2292 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2293 |
(b'n', b'edits', 10000, b'number of edits'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2294 |
(b'', b'max-hunk-lines', 10, b'max lines in a hunk'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2295 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2296 |
norepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2297 |
) |
38969
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2298 |
def perflinelogedits(ui, **opts): |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2299 |
from mercurial import linelog |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2300 |
|
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2301 |
opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2302 |
|
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2303 |
edits = opts[b'edits'] |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2304 |
maxhunklines = opts[b'max_hunk_lines'] |
38969
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2305 |
|
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2306 |
maxb1 = 100000 |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2307 |
random.seed(0) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2308 |
randint = random.randint |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2309 |
currentlines = 0 |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2310 |
arglist = [] |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
2311 |
for rev in _xrange(edits): |
38969
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2312 |
a1 = randint(0, currentlines) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2313 |
a2 = randint(a1, min(currentlines, a1 + maxhunklines)) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2314 |
b1 = randint(0, maxb1) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2315 |
b2 = randint(b1, b1 + maxhunklines) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2316 |
currentlines += (b2 - b1) - (a2 - a1) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2317 |
arglist.append((rev, a1, a2, b1, b2)) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2318 |
|
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2319 |
def d(): |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2320 |
ll = linelog.linelog() |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2321 |
for args in arglist: |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2322 |
ll.replacelines(*args) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2323 |
|
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2324 |
timer, fm = gettimer(ui, opts) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2325 |
timer(d) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2326 |
fm.end() |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
2327 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2328 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
2329 |
@command(b'perf::revrange|perfrevrange', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2330 |
def perfrevrange(ui, repo, *specs, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2331 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2332 |
timer, fm = gettimer(ui, opts) |
16858
fdf99e0f60f3
perf: add a benchmark for revrange
Bryan O'Sullivan <bryano@fb.com>
parents:
16802
diff
changeset
|
2333 |
revrange = scmutil.revrange |
fdf99e0f60f3
perf: add a benchmark for revrange
Bryan O'Sullivan <bryano@fb.com>
parents:
16802
diff
changeset
|
2334 |
timer(lambda: len(revrange(repo, specs))) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
2335 |
fm.end() |
16858
fdf99e0f60f3
perf: add a benchmark for revrange
Bryan O'Sullivan <bryano@fb.com>
parents:
16802
diff
changeset
|
2336 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2337 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
2338 |
@command(b'perf::nodelookup|perfnodelookup', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2339 |
def perfnodelookup(ui, repo, rev, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2340 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2341 |
timer, fm = gettimer(ui, opts) |
16309 | 2342 |
import mercurial.revlog |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2343 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2344 |
mercurial.revlog._prereadsize = 2 ** 24 # disable lazy parser in old hg |
37355
5bcd5859b505
perf: make perfmanifest and perfnodelookup work with revsets
Martin von Zweigbergk <martinvonz@google.com>
parents:
37269
diff
changeset
|
2345 |
n = scmutil.revsingle(repo, rev).node() |
47072
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47036
diff
changeset
|
2346 |
|
47150
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47149
diff
changeset
|
2347 |
try: |
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47149
diff
changeset
|
2348 |
cl = revlog(getsvfs(repo), radix=b"00changelog") |
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47149
diff
changeset
|
2349 |
except TypeError: |
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47149
diff
changeset
|
2350 |
cl = revlog(getsvfs(repo), indexfile=b"00changelog.i") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2351 |
|
16414
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
2352 |
def d(): |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
2353 |
cl.rev(n) |
16785
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
2354 |
clearcaches(cl) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2355 |
|
16414
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
2356 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
2357 |
fm.end() |
16414
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
2358 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2359 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2360 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
2361 |
b'perf::log|perflog', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2362 |
[(b'', b'rename', False, b'ask log to follow renames')] + formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2363 |
) |
27306
bafb1235f505
perf: add optional rev for perflog and perftemplating
timeless <timeless@mozdev.org>
parents:
27305
diff
changeset
|
2364 |
def perflog(ui, repo, rev=None, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2365 |
opts = _byteskwargs(opts) |
27306
bafb1235f505
perf: add optional rev for perflog and perftemplating
timeless <timeless@mozdev.org>
parents:
27305
diff
changeset
|
2366 |
if rev is None: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2367 |
rev = [] |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2368 |
timer, fm = gettimer(ui, opts) |
7872
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
2369 |
ui.pushbuffer() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2370 |
timer( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2371 |
lambda: commands.log( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2372 |
ui, repo, rev=rev, date=b'', user=b'', copies=opts.get(b'rename') |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2373 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2374 |
) |
7872
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
2375 |
ui.popbuffer() |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
2376 |
fm.end() |
7872
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
2377 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2378 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
2379 |
@command(b'perf::moonwalk|perfmoonwalk', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2380 |
def perfmoonwalk(ui, repo, **opts): |
20178
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
2381 |
"""benchmark walking the changelog backwards |
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
2382 |
|
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
2383 |
This also loads the changelog data for each revision in the changelog. |
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
2384 |
""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2385 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2386 |
timer, fm = gettimer(ui, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2387 |
|
20178
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
2388 |
def moonwalk(): |
38778
a4d847cea6f8
perfmoonwalk: make work with filtered repo
Martin von Zweigbergk <martinvonz@google.com>
parents:
38695
diff
changeset
|
2389 |
for i in repo.changelog.revs(start=(len(repo) - 1), stop=-1): |
20178
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
2390 |
ctx = repo[i] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2391 |
ctx.branch() # read changelog data (in addition to the index) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2392 |
|
20178
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
2393 |
timer(moonwalk) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
2394 |
fm.end() |
20178
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
2395 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2396 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2397 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
2398 |
b'perf::templating|perftemplating', |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2399 |
[ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2400 |
(b'r', b'rev', [], b'revisions to run the template on'), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2401 |
] |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2402 |
+ formatteropts, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2403 |
) |
38258
ae6e02fcee24
perftemplating: allow to specify the template to test
Boris Feld <boris.feld@octobus.net>
parents:
38257
diff
changeset
|
2404 |
def perftemplating(ui, repo, testedtemplate=None, **opts): |
ae6e02fcee24
perftemplating: allow to specify the template to test
Boris Feld <boris.feld@octobus.net>
parents:
38257
diff
changeset
|
2405 |
"""test the rendering time of a given template""" |
38257
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
2406 |
if makelogtemplater is None: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2407 |
raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2408 |
b"perftemplating not available with this Mercurial", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2409 |
hint=b"use 4.3 or later", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2410 |
) |
38257
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
2411 |
|
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2412 |
opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2413 |
|
38255
71d59b487d0c
perftemplating: drop usage of buffer
Boris Feld <boris.feld@octobus.net>
parents:
38254
diff
changeset
|
2414 |
nullui = ui.copy() |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
2415 |
nullui.fout = open(os.devnull, 'wb') |
38255
71d59b487d0c
perftemplating: drop usage of buffer
Boris Feld <boris.feld@octobus.net>
parents:
38254
diff
changeset
|
2416 |
nullui.disablepager() |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2417 |
revs = opts.get(b'rev') |
38257
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
2418 |
if not revs: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2419 |
revs = [b'all()'] |
38257
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
2420 |
revs = list(scmutil.revrange(repo, revs)) |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
2421 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2422 |
defaulttemplate = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2423 |
b'{date|shortdate} [{rev}:{node|short}]' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2424 |
b' {author|person}: {desc|firstline}\n' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2425 |
) |
38258
ae6e02fcee24
perftemplating: allow to specify the template to test
Boris Feld <boris.feld@octobus.net>
parents:
38257
diff
changeset
|
2426 |
if testedtemplate is None: |
ae6e02fcee24
perftemplating: allow to specify the template to test
Boris Feld <boris.feld@octobus.net>
parents:
38257
diff
changeset
|
2427 |
testedtemplate = defaulttemplate |
ae6e02fcee24
perftemplating: allow to specify the template to test
Boris Feld <boris.feld@octobus.net>
parents:
38257
diff
changeset
|
2428 |
displayer = makelogtemplater(nullui, repo, testedtemplate) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2429 |
|
38254
6b91815fcdce
perftemplating: move template formating into its own function
Boris Feld <boris.feld@octobus.net>
parents:
38253
diff
changeset
|
2430 |
def format(): |
38257
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
2431 |
for r in revs: |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
2432 |
ctx = repo[r] |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
2433 |
displayer.show(ctx) |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
2434 |
displayer.flush(ctx) |
38254
6b91815fcdce
perftemplating: move template formating into its own function
Boris Feld <boris.feld@octobus.net>
parents:
38253
diff
changeset
|
2435 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2436 |
timer, fm = gettimer(ui, opts) |
38254
6b91815fcdce
perftemplating: move template formating into its own function
Boris Feld <boris.feld@octobus.net>
parents:
38253
diff
changeset
|
2437 |
timer(format) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
2438 |
fm.end() |
7872
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
2439 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2440 |
|
42941
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2441 |
def _displaystats(ui, opts, entries, data): |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2442 |
# use a second formatter because the data are quite different, not sure |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2443 |
# how it flies with the templater. |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2444 |
fm = ui.formatter(b'perf-stats', opts) |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2445 |
for key, title in entries: |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2446 |
values = data[key] |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2447 |
nbvalues = len(data) |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2448 |
values.sort() |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2449 |
stats = { |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2450 |
'key': key, |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2451 |
'title': title, |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2452 |
'nbitems': len(values), |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2453 |
'min': values[0][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2454 |
'10%': values[(nbvalues * 10) // 100][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2455 |
'25%': values[(nbvalues * 25) // 100][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2456 |
'50%': values[(nbvalues * 50) // 100][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2457 |
'75%': values[(nbvalues * 75) // 100][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2458 |
'80%': values[(nbvalues * 80) // 100][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2459 |
'85%': values[(nbvalues * 85) // 100][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2460 |
'90%': values[(nbvalues * 90) // 100][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2461 |
'95%': values[(nbvalues * 95) // 100][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2462 |
'99%': values[(nbvalues * 99) // 100][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2463 |
'max': values[-1][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2464 |
} |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2465 |
fm.startitem() |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2466 |
fm.data(**stats) |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2467 |
# make node pretty for the human output |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2468 |
fm.plain('### %s (%d items)\n' % (title, len(values))) |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2469 |
lines = [ |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2470 |
'min', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2471 |
'10%', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2472 |
'25%', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2473 |
'50%', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2474 |
'75%', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2475 |
'80%', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2476 |
'85%', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2477 |
'90%', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2478 |
'95%', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2479 |
'99%', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2480 |
'max', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2481 |
] |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2482 |
for l in lines: |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2483 |
fm.plain('%s: %s\n' % (l, stats[l])) |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2484 |
fm.end() |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2485 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2486 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2487 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
2488 |
b'perf::helper-mergecopies|perfhelper-mergecopies', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2489 |
formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2490 |
+ [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2491 |
(b'r', b'revs', [], b'restrict search to these revisions'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2492 |
(b'', b'timing', False, b'provides extra data (costly)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2493 |
(b'', b'stats', False, b'provides statistic about the measured data'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2494 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2495 |
) |
42385
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2496 |
def perfhelpermergecopies(ui, repo, revs=[], **opts): |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2497 |
"""find statistics about potential parameters for `perfmergecopies` |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2498 |
|
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2499 |
This command find (base, p1, p2) triplet relevant for copytracing |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2500 |
benchmarking in the context of a merge. It reports values for some of the |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2501 |
parameters that impact merge copy tracing time during merge. |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2502 |
|
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2503 |
If `--timing` is set, rename detection is run and the associated timing |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2504 |
will be reported. The extra details come at the cost of slower command |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2505 |
execution. |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2506 |
|
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2507 |
Since rename detection is only run once, other factors might easily |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2508 |
affect the precision of the timing. However it should give a good |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2509 |
approximation of which revision triplets are very costly. |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2510 |
""" |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2511 |
opts = _byteskwargs(opts) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2512 |
fm = ui.formatter(b'perf', opts) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2513 |
dotiming = opts[b'timing'] |
42941
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2514 |
dostats = opts[b'stats'] |
42385
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2515 |
|
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2516 |
output_template = [ |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2517 |
("base", "%(base)12s"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2518 |
("p1", "%(p1.node)12s"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2519 |
("p2", "%(p2.node)12s"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2520 |
("p1.nb-revs", "%(p1.nbrevs)12d"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2521 |
("p1.nb-files", "%(p1.nbmissingfiles)12d"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2522 |
("p1.renames", "%(p1.renamedfiles)12d"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2523 |
("p1.time", "%(p1.time)12.3f"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2524 |
("p2.nb-revs", "%(p2.nbrevs)12d"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2525 |
("p2.nb-files", "%(p2.nbmissingfiles)12d"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2526 |
("p2.renames", "%(p2.renamedfiles)12d"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2527 |
("p2.time", "%(p2.time)12.3f"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2528 |
("renames", "%(nbrenamedfiles)12d"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2529 |
("total.time", "%(time)12.3f"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2530 |
] |
42385
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2531 |
if not dotiming: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2532 |
output_template = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2533 |
i |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2534 |
for i in output_template |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2535 |
if not ('time' in i[0] or 'renames' in i[0]) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2536 |
] |
42385
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2537 |
header_names = [h for (h, v) in output_template] |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2538 |
output = ' '.join([v for (h, v) in output_template]) + '\n' |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2539 |
header = ' '.join(['%12s'] * len(header_names)) + '\n' |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2540 |
fm.plain(header % tuple(header_names)) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2541 |
|
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2542 |
if not revs: |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2543 |
revs = ['all()'] |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2544 |
revs = scmutil.revrange(repo, revs) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2545 |
|
42941
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2546 |
if dostats: |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2547 |
alldata = { |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2548 |
'nbrevs': [], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2549 |
'nbmissingfiles': [], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2550 |
} |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2551 |
if dotiming: |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2552 |
alldata['parentnbrenames'] = [] |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2553 |
alldata['totalnbrenames'] = [] |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2554 |
alldata['parenttime'] = [] |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2555 |
alldata['totaltime'] = [] |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2556 |
|
42385
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2557 |
roi = repo.revs('merge() and %ld', revs) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2558 |
for r in roi: |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2559 |
ctx = repo[r] |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2560 |
p1 = ctx.p1() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2561 |
p2 = ctx.p2() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2562 |
bases = repo.changelog._commonancestorsheads(p1.rev(), p2.rev()) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2563 |
for b in bases: |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2564 |
b = repo[b] |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2565 |
p1missing = copies._computeforwardmissing(b, p1) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2566 |
p2missing = copies._computeforwardmissing(b, p2) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2567 |
data = { |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2568 |
b'base': b.hex(), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2569 |
b'p1.node': p1.hex(), |
43161
9d57c2df7b5f
perf: fix `perfhelper-mergecopies` report of #changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43160
diff
changeset
|
2570 |
b'p1.nbrevs': len(repo.revs('only(%d, %d)', p1.rev(), b.rev())), |
42385
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2571 |
b'p1.nbmissingfiles': len(p1missing), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2572 |
b'p2.node': p2.hex(), |
43161
9d57c2df7b5f
perf: fix `perfhelper-mergecopies` report of #changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43160
diff
changeset
|
2573 |
b'p2.nbrevs': len(repo.revs('only(%d, %d)', p2.rev(), b.rev())), |
42385
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2574 |
b'p2.nbmissingfiles': len(p2missing), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2575 |
} |
42941
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2576 |
if dostats: |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2577 |
if p1missing: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2578 |
alldata['nbrevs'].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2579 |
(data['p1.nbrevs'], b.hex(), p1.hex()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2580 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2581 |
alldata['nbmissingfiles'].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2582 |
(data['p1.nbmissingfiles'], b.hex(), p1.hex()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2583 |
) |
42941
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2584 |
if p2missing: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2585 |
alldata['nbrevs'].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2586 |
(data['p2.nbrevs'], b.hex(), p2.hex()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2587 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2588 |
alldata['nbmissingfiles'].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2589 |
(data['p2.nbmissingfiles'], b.hex(), p2.hex()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2590 |
) |
42385
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2591 |
if dotiming: |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2592 |
begin = util.timer() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2593 |
mergedata = copies.mergecopies(repo, p1, p2, b) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2594 |
end = util.timer() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2595 |
# not very stable timing since we did only one run |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2596 |
data['time'] = end - begin |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2597 |
# mergedata contains five dicts: "copy", "movewithdir", |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2598 |
# "diverge", "renamedelete" and "dirmove". |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2599 |
# The first 4 are about renamed file so lets count that. |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2600 |
renames = len(mergedata[0]) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2601 |
renames += len(mergedata[1]) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2602 |
renames += len(mergedata[2]) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2603 |
renames += len(mergedata[3]) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2604 |
data['nbrenamedfiles'] = renames |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2605 |
begin = util.timer() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2606 |
p1renames = copies.pathcopies(b, p1) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2607 |
end = util.timer() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2608 |
data['p1.time'] = end - begin |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2609 |
begin = util.timer() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2610 |
p2renames = copies.pathcopies(b, p2) |
43974
a2ad5aeedfdf
perf: fix the time measurement for pathcopies relative to p2
Matt Harbison <matt_harbison@yahoo.com>
parents:
43653
diff
changeset
|
2611 |
end = util.timer() |
42385
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2612 |
data['p2.time'] = end - begin |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2613 |
data['p1.renamedfiles'] = len(p1renames) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2614 |
data['p2.renamedfiles'] = len(p2renames) |
42941
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2615 |
|
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2616 |
if dostats: |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2617 |
if p1missing: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2618 |
alldata['parentnbrenames'].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2619 |
(data['p1.renamedfiles'], b.hex(), p1.hex()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2620 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2621 |
alldata['parenttime'].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2622 |
(data['p1.time'], b.hex(), p1.hex()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2623 |
) |
42941
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2624 |
if p2missing: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2625 |
alldata['parentnbrenames'].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2626 |
(data['p2.renamedfiles'], b.hex(), p2.hex()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2627 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2628 |
alldata['parenttime'].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2629 |
(data['p2.time'], b.hex(), p2.hex()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2630 |
) |
42941
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2631 |
if p1missing or p2missing: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2632 |
alldata['totalnbrenames'].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2633 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2634 |
data['nbrenamedfiles'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2635 |
b.hex(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2636 |
p1.hex(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2637 |
p2.hex(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2638 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2639 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2640 |
alldata['totaltime'].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2641 |
(data['time'], b.hex(), p1.hex(), p2.hex()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2642 |
) |
42385
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2643 |
fm.startitem() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2644 |
fm.data(**data) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2645 |
# make node pretty for the human output |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2646 |
out = data.copy() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2647 |
out['base'] = fm.hexfunc(b.node()) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2648 |
out['p1.node'] = fm.hexfunc(p1.node()) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2649 |
out['p2.node'] = fm.hexfunc(p2.node()) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2650 |
fm.plain(output % out) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2651 |
|
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2652 |
fm.end() |
42941
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2653 |
if dostats: |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2654 |
# use a second formatter because the data are quite different, not sure |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2655 |
# how it flies with the templater. |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2656 |
entries = [ |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2657 |
('nbrevs', 'number of revision covered'), |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2658 |
('nbmissingfiles', 'number of missing files at head'), |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2659 |
] |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2660 |
if dotiming: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2661 |
entries.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2662 |
('parentnbrenames', 'rename from one parent to base') |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2663 |
) |
42941
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2664 |
entries.append(('totalnbrenames', 'total number of renames')) |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2665 |
entries.append(('parenttime', 'time for one parent')) |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2666 |
entries.append(('totaltime', 'time for both parents')) |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2667 |
_displaystats(ui, opts, entries, alldata) |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42785
diff
changeset
|
2668 |
|
42385
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
2669 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2670 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
2671 |
b'perf::helper-pathcopies|perfhelper-pathcopies', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2672 |
formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2673 |
+ [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2674 |
(b'r', b'revs', [], b'restrict search to these revisions'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2675 |
(b'', b'timing', False, b'provides extra data (costly)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2676 |
(b'', b'stats', False, b'provides statistic about the measured data'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2677 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2678 |
) |
40740
30d878cb102d
perf: rename `perfhelper-tracecopies` to `perfhelper-pathcopies`
Boris Feld <boris.feld@octobus.net>
parents:
40739
diff
changeset
|
2679 |
def perfhelperpathcopies(ui, repo, revs=[], **opts): |
40691
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2680 |
"""find statistic about potential parameters for the `perftracecopies` |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2681 |
|
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2682 |
This command find source-destination pair relevant for copytracing testing. |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2683 |
It report value for some of the parameters that impact copy tracing time. |
40731
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2684 |
|
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2685 |
If `--timing` is set, rename detection is run and the associated timing |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2686 |
will be reported. The extra details comes at the cost of a slower command |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2687 |
execution. |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2688 |
|
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2689 |
Since the rename detection is only run once, other factors might easily |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2690 |
affect the precision of the timing. However it should give a good |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2691 |
approximation of which revision pairs are very costly. |
40691
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2692 |
""" |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2693 |
opts = _byteskwargs(opts) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2694 |
fm = ui.formatter(b'perf', opts) |
40731
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2695 |
dotiming = opts[b'timing'] |
42942
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42941
diff
changeset
|
2696 |
dostats = opts[b'stats'] |
40731
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2697 |
|
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2698 |
if dotiming: |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2699 |
header = '%12s %12s %12s %12s %12s %12s\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2700 |
output = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2701 |
"%(source)12s %(destination)12s " |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2702 |
"%(nbrevs)12d %(nbmissingfiles)12d " |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2703 |
"%(nbrenamedfiles)12d %(time)18.5f\n" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2704 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2705 |
header_names = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2706 |
"source", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2707 |
"destination", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2708 |
"nb-revs", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2709 |
"nb-files", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2710 |
"nb-renames", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2711 |
"time", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2712 |
) |
40731
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2713 |
fm.plain(header % header_names) |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2714 |
else: |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2715 |
header = '%12s %12s %12s %12s\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2716 |
output = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2717 |
"%(source)12s %(destination)12s " |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2718 |
"%(nbrevs)12d %(nbmissingfiles)12d\n" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2719 |
) |
40731
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2720 |
fm.plain(header % ("source", "destination", "nb-revs", "nb-files")) |
40691
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2721 |
|
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2722 |
if not revs: |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2723 |
revs = ['all()'] |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2724 |
revs = scmutil.revrange(repo, revs) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2725 |
|
42942
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42941
diff
changeset
|
2726 |
if dostats: |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42941
diff
changeset
|
2727 |
alldata = { |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42941
diff
changeset
|
2728 |
'nbrevs': [], |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42941
diff
changeset
|
2729 |
'nbmissingfiles': [], |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42941
diff
changeset
|
2730 |
} |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42941
diff
changeset
|
2731 |
if dotiming: |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42941
diff
changeset
|
2732 |
alldata['nbrenames'] = [] |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42941
diff
changeset
|
2733 |
alldata['time'] = [] |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42941
diff
changeset
|
2734 |
|
40691
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2735 |
roi = repo.revs('merge() and %ld', revs) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2736 |
for r in roi: |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2737 |
ctx = repo[r] |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2738 |
p1 = ctx.p1().rev() |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2739 |
p2 = ctx.p2().rev() |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2740 |
bases = repo.changelog._commonancestorsheads(p1, p2) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2741 |
for p in (p1, p2): |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2742 |
for b in bases: |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2743 |
base = repo[b] |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2744 |
parent = repo[p] |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2745 |
missing = copies._computeforwardmissing(base, parent) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2746 |
if not missing: |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2747 |
continue |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2748 |
data = { |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2749 |
b'source': base.hex(), |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2750 |
b'destination': parent.hex(), |
43160
84a950007619
perf: fix `perfhelper-pathcopies` report of #changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43130
diff
changeset
|
2751 |
b'nbrevs': len(repo.revs('only(%d, %d)', p, b)), |
40691
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2752 |
b'nbmissingfiles': len(missing), |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2753 |
} |
43003
bbf77341a956
perf: fix perfhelper-pathcopies without --stats
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42979
diff
changeset
|
2754 |
if dostats: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2755 |
alldata['nbrevs'].append( |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2756 |
( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2757 |
data['nbrevs'], |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2758 |
base.hex(), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2759 |
parent.hex(), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2760 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2761 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2762 |
alldata['nbmissingfiles'].append( |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2763 |
( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2764 |
data['nbmissingfiles'], |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2765 |
base.hex(), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2766 |
parent.hex(), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2767 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2768 |
) |
40731
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2769 |
if dotiming: |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2770 |
begin = util.timer() |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2771 |
renames = copies.pathcopies(base, parent) |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2772 |
end = util.timer() |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2773 |
# not very stable timing since we did only one run |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2774 |
data['time'] = end - begin |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2775 |
data['nbrenamedfiles'] = len(renames) |
43003
bbf77341a956
perf: fix perfhelper-pathcopies without --stats
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42979
diff
changeset
|
2776 |
if dostats: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2777 |
alldata['time'].append( |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2778 |
( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2779 |
data['time'], |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2780 |
base.hex(), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2781 |
parent.hex(), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2782 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2783 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2784 |
alldata['nbrenames'].append( |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2785 |
( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2786 |
data['nbrenamedfiles'], |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2787 |
base.hex(), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2788 |
parent.hex(), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
2789 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2790 |
) |
40731
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2791 |
fm.startitem() |
40691
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2792 |
fm.data(**data) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2793 |
out = data.copy() |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2794 |
out['source'] = fm.hexfunc(base.node()) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2795 |
out['destination'] = fm.hexfunc(parent.node()) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2796 |
fm.plain(output % out) |
40731
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
2797 |
|
40691
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2798 |
fm.end() |
42942
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42941
diff
changeset
|
2799 |
if dostats: |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42941
diff
changeset
|
2800 |
entries = [ |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42941
diff
changeset
|
2801 |
('nbrevs', 'number of revision covered'), |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42941
diff
changeset
|
2802 |
('nbmissingfiles', 'number of missing files at head'), |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42941
diff
changeset
|
2803 |
] |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42941
diff
changeset
|
2804 |
if dotiming: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2805 |
entries.append(('nbrenames', 'renamed files')) |
42942
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42941
diff
changeset
|
2806 |
entries.append(('time', 'time')) |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42941
diff
changeset
|
2807 |
_displaystats(ui, opts, entries, alldata) |
40691
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
2808 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2809 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
2810 |
@command(b'perf::cca|perfcca', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2811 |
def perfcca(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2812 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2813 |
timer, fm = gettimer(ui, opts) |
17216
01c1ee4bd1dd
perf: fix perfcca to work with new casecollisionauditor interface
Joshua Redstone <joshua.redstone@fb.com>
parents:
16866
diff
changeset
|
2814 |
timer(lambda: scmutil.casecollisionauditor(ui, False, repo.dirstate)) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
2815 |
fm.end() |
16386
ccc173d0914e
perf: add case collision auditor perf
Matt Mackall <mpm@selenic.com>
parents:
16309
diff
changeset
|
2816 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2817 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
2818 |
@command(b'perf::fncacheload|perffncacheload', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2819 |
def perffncacheload(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2820 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2821 |
timer, fm = gettimer(ui, opts) |
17780
769f66861eb8
perf: simply use repo.store for perffncache* commands
Adrian Buehlmann <adrian@cadifra.com>
parents:
17553
diff
changeset
|
2822 |
s = repo.store |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2823 |
|
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
2824 |
def d(): |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
2825 |
s.fncache._load() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2826 |
|
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
2827 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
2828 |
fm.end() |
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
2829 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2830 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
2831 |
@command(b'perf::fncachewrite|perffncachewrite', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2832 |
def perffncachewrite(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2833 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2834 |
timer, fm = gettimer(ui, opts) |
17780
769f66861eb8
perf: simply use repo.store for perffncache* commands
Adrian Buehlmann <adrian@cadifra.com>
parents:
17553
diff
changeset
|
2835 |
s = repo.store |
38695
2cdb82e8fb44
perffncachewrite: load fncache after lock is acquired
Boris Feld <boris.feld@octobus.net>
parents:
38694
diff
changeset
|
2836 |
lock = repo.lock() |
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
2837 |
s.fncache._load() |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2838 |
tr = repo.transaction(b'perffncachewrite') |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2839 |
tr.addbackup(b'fncache') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2840 |
|
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
2841 |
def d(): |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
2842 |
s.fncache._dirty = True |
27097
b3e24a9c5f9b
contrib/perf: fix perffncachewrite
timeless <timeless@mozdev.org>
parents:
27096
diff
changeset
|
2843 |
s.fncache.write(tr) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2844 |
|
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
2845 |
timer(d) |
30069
98b9846a131e
perf: release lock after transaction in perffncachewrite
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30018
diff
changeset
|
2846 |
tr.close() |
27097
b3e24a9c5f9b
contrib/perf: fix perffncachewrite
timeless <timeless@mozdev.org>
parents:
27096
diff
changeset
|
2847 |
lock.release() |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
2848 |
fm.end() |
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
2849 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2850 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
2851 |
@command(b'perf::fncacheencode|perffncacheencode', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2852 |
def perffncacheencode(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2853 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2854 |
timer, fm = gettimer(ui, opts) |
17780
769f66861eb8
perf: simply use repo.store for perffncache* commands
Adrian Buehlmann <adrian@cadifra.com>
parents:
17553
diff
changeset
|
2855 |
s = repo.store |
17553
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
2856 |
s.fncache._load() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2857 |
|
17553
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
2858 |
def d(): |
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
2859 |
for p in s.fncache.entries: |
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
2860 |
s.encode(p) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2861 |
|
17553
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
2862 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
2863 |
fm.end() |
17553
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
2864 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2865 |
|
36766
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
2866 |
def _bdiffworker(q, blocks, xdiff, ready, done): |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2867 |
while not done.is_set(): |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2868 |
pair = q.get() |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2869 |
while pair is not None: |
36766
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
2870 |
if xdiff: |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
2871 |
mdiff.bdiff.xdiffblocks(*pair) |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
2872 |
elif blocks: |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
2873 |
mdiff.bdiff.blocks(*pair) |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
2874 |
else: |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
2875 |
mdiff.textdiff(*pair) |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2876 |
q.task_done() |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2877 |
pair = q.get() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2878 |
q.task_done() # for the None one |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2879 |
with ready: |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2880 |
ready.wait() |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2881 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2882 |
|
39319
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
2883 |
def _manifestrevision(repo, mnode): |
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
2884 |
ml = repo.manifestlog |
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
2885 |
|
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2886 |
if util.safehasattr(ml, b'getstorage'): |
39319
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
2887 |
store = ml.getstorage(b'') |
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
2888 |
else: |
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
2889 |
store = ml._revlog |
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
2890 |
|
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
2891 |
return store.revision(mnode) |
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
2892 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2893 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2894 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
2895 |
b'perf::bdiff|perfbdiff', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2896 |
revlogopts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2897 |
+ formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2898 |
+ [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2899 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2900 |
b'', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2901 |
b'count', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2902 |
1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2903 |
b'number of revisions to test (when using --startrev)', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2904 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2905 |
(b'', b'alldata', False, b'test bdiffs for all associated revisions'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2906 |
(b'', b'threads', 0, b'number of thread to use (disable with 0)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2907 |
(b'', b'blocks', False, b'test computing diffs into blocks'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2908 |
(b'', b'xdiff', False, b'use xdiff algorithm'), |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2909 |
], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2910 |
b'-c|-m|FILE REV', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2911 |
) |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2912 |
def perfbdiff(ui, repo, file_, rev=None, count=None, threads=0, **opts): |
30336
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
2913 |
"""benchmark a bdiff between revisions |
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
2914 |
|
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
2915 |
By default, benchmark a bdiff between its delta parent and itself. |
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
2916 |
|
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
2917 |
With ``--count``, benchmark bdiffs between delta parents and self for N |
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
2918 |
revisions starting at the specified revision. |
30337
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
2919 |
|
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
2920 |
With ``--alldata``, assume the requested revision is a changeset and |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
2921 |
measure bdiffs for all changes related to that changeset (manifest |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
2922 |
and filelogs). |
30336
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
2923 |
""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2924 |
opts = _byteskwargs(opts) |
36766
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
2925 |
|
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2926 |
if opts[b'xdiff'] and not opts[b'blocks']: |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2927 |
raise error.CommandError(b'perfbdiff', b'--xdiff requires --blocks') |
36766
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
2928 |
|
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2929 |
if opts[b'alldata']: |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2930 |
opts[b'changelog'] = True |
30337
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
2931 |
|
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2932 |
if opts.get(b'changelog') or opts.get(b'manifest'): |
30307
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
2933 |
file_, rev = None, file_ |
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
2934 |
elif rev is None: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2935 |
raise error.CommandError(b'perfbdiff', b'invalid arguments') |
30307
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
2936 |
|
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2937 |
blocks = opts[b'blocks'] |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2938 |
xdiff = opts[b'xdiff'] |
30335
7d91a085ebe6
perf: prepare to handle multiple pairs in perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30307
diff
changeset
|
2939 |
textpairs = [] |
7d91a085ebe6
perf: prepare to handle multiple pairs in perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30307
diff
changeset
|
2940 |
|
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2941 |
r = cmdutil.openrevlog(repo, b'perfbdiff', file_, opts) |
30307
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
2942 |
|
30336
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
2943 |
startrev = r.rev(r.lookup(rev)) |
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
2944 |
for rev in range(startrev, min(startrev + count, len(r) - 1)): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2945 |
if opts[b'alldata']: |
30337
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
2946 |
# Load revisions associated with changeset. |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
2947 |
ctx = repo[rev] |
39319
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
2948 |
mtext = _manifestrevision(repo, ctx.manifestnode()) |
30337
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
2949 |
for pctx in ctx.parents(): |
39319
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
2950 |
pman = _manifestrevision(repo, pctx.manifestnode()) |
30337
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
2951 |
textpairs.append((pman, mtext)) |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
2952 |
|
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
2953 |
# Load filelog revisions by iterating manifest delta. |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
2954 |
man = ctx.manifest() |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
2955 |
pman = ctx.p1().manifest() |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
2956 |
for filename, change in pman.diff(man).items(): |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
2957 |
fctx = repo.file(filename) |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
2958 |
f1 = fctx.revision(change[0][0] or -1) |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
2959 |
f2 = fctx.revision(change[1][0] or -1) |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
2960 |
textpairs.append((f1, f2)) |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
2961 |
else: |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
2962 |
dp = r.deltaparent(rev) |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
2963 |
textpairs.append((r.revision(dp), r.revision(rev))) |
30307
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
2964 |
|
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2965 |
withthreads = threads > 0 |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2966 |
if not withthreads: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2967 |
|
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2968 |
def d(): |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2969 |
for pair in textpairs: |
36766
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
2970 |
if xdiff: |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
2971 |
mdiff.bdiff.xdiffblocks(*pair) |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
2972 |
elif blocks: |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
2973 |
mdiff.bdiff.blocks(*pair) |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
2974 |
else: |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
2975 |
mdiff.textdiff(*pair) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2976 |
|
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2977 |
else: |
37844
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
2978 |
q = queue() |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
2979 |
for i in _xrange(threads): |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2980 |
q.put(None) |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2981 |
ready = threading.Condition() |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2982 |
done = threading.Event() |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
2983 |
for i in _xrange(threads): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2984 |
threading.Thread( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2985 |
target=_bdiffworker, args=(q, blocks, xdiff, ready, done) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2986 |
).start() |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2987 |
q.join() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2988 |
|
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2989 |
def d(): |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2990 |
for pair in textpairs: |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2991 |
q.put(pair) |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
2992 |
for i in _xrange(threads): |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2993 |
q.put(None) |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2994 |
with ready: |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2995 |
ready.notify_all() |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
2996 |
q.join() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
2997 |
|
30307
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
2998 |
timer, fm = gettimer(ui, opts) |
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
2999 |
timer(d) |
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
3000 |
fm.end() |
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
3001 |
|
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
3002 |
if withthreads: |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
3003 |
done.set() |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
3004 |
for i in _xrange(threads): |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
3005 |
q.put(None) |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
3006 |
with ready: |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
3007 |
ready.notify_all() |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
3008 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3009 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3010 |
@command( |
49414
3c5d0f879404
perf-unbundle: add a perf command to time the unbundle operation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49413
diff
changeset
|
3011 |
b'perf::unbundle', |
51436
827b89714a8d
perf: add a --as-push option to perf::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51413
diff
changeset
|
3012 |
[ |
827b89714a8d
perf: add a --as-push option to perf::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51413
diff
changeset
|
3013 |
(b'', b'as-push', None, b'pretend the bundle comes from a push'), |
827b89714a8d
perf: add a --as-push option to perf::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51413
diff
changeset
|
3014 |
] |
827b89714a8d
perf: add a --as-push option to perf::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51413
diff
changeset
|
3015 |
+ formatteropts, |
49414
3c5d0f879404
perf-unbundle: add a perf command to time the unbundle operation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49413
diff
changeset
|
3016 |
b'BUNDLE_FILE', |
3c5d0f879404
perf-unbundle: add a perf command to time the unbundle operation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49413
diff
changeset
|
3017 |
) |
3c5d0f879404
perf-unbundle: add a perf command to time the unbundle operation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49413
diff
changeset
|
3018 |
def perf_unbundle(ui, repo, fname, **opts): |
3c5d0f879404
perf-unbundle: add a perf command to time the unbundle operation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49413
diff
changeset
|
3019 |
"""benchmark application of a bundle in a repository. |
3c5d0f879404
perf-unbundle: add a perf command to time the unbundle operation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49413
diff
changeset
|
3020 |
|
51436
827b89714a8d
perf: add a --as-push option to perf::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51413
diff
changeset
|
3021 |
This does not include the final transaction processing |
827b89714a8d
perf: add a --as-push option to perf::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51413
diff
changeset
|
3022 |
|
827b89714a8d
perf: add a --as-push option to perf::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51413
diff
changeset
|
3023 |
The --as-push option make the unbundle operation appears like it comes from |
827b89714a8d
perf: add a --as-push option to perf::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51413
diff
changeset
|
3024 |
a client push. It change some aspect of the processing and associated |
827b89714a8d
perf: add a --as-push option to perf::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51413
diff
changeset
|
3025 |
performance profile. |
827b89714a8d
perf: add a --as-push option to perf::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51413
diff
changeset
|
3026 |
""" |
49562
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3027 |
|
49414
3c5d0f879404
perf-unbundle: add a perf command to time the unbundle operation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49413
diff
changeset
|
3028 |
from mercurial import exchange |
3c5d0f879404
perf-unbundle: add a perf command to time the unbundle operation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49413
diff
changeset
|
3029 |
from mercurial import bundle2 |
49562
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3030 |
from mercurial import transaction |
49414
3c5d0f879404
perf-unbundle: add a perf command to time the unbundle operation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49413
diff
changeset
|
3031 |
|
49445
cd21f2b4226f
perf: properly process formatter option in perf::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49444
diff
changeset
|
3032 |
opts = _byteskwargs(opts) |
cd21f2b4226f
perf: properly process formatter option in perf::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49444
diff
changeset
|
3033 |
|
49562
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3034 |
### some compatibility hotfix |
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3035 |
# |
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3036 |
# the data attribute is dropped in 63edc384d3b7 a changeset introducing a |
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3037 |
# critical regression that break transaction rollback for files that are |
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3038 |
# de-inlined. |
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3039 |
method = transaction.transaction._addentry |
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3040 |
pre_63edc384d3b7 = "data" in getargspec(method).args |
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3041 |
# the `detailed_exit_code` attribute is introduced in 33c0c25d0b0f |
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3042 |
# a changeset that is a close descendant of 18415fc918a1, the changeset |
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3043 |
# that conclude the fix run for the bug introduced in 63edc384d3b7. |
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3044 |
args = getargspec(error.Abort.__init__).args |
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3045 |
post_18415fc918a1 = "detailed_exit_code" in args |
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3046 |
|
51436
827b89714a8d
perf: add a --as-push option to perf::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51413
diff
changeset
|
3047 |
unbundle_source = b'perf::unbundle' |
827b89714a8d
perf: add a --as-push option to perf::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51413
diff
changeset
|
3048 |
if opts[b'as_push']: |
827b89714a8d
perf: add a --as-push option to perf::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51413
diff
changeset
|
3049 |
unbundle_source = b'push' |
827b89714a8d
perf: add a --as-push option to perf::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51413
diff
changeset
|
3050 |
|
49562
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3051 |
old_max_inline = None |
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3052 |
try: |
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3053 |
if not (pre_63edc384d3b7 or post_18415fc918a1): |
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3054 |
# disable inlining |
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3055 |
old_max_inline = mercurial.revlog._maxinline |
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3056 |
# large enough to never happen |
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3057 |
mercurial.revlog._maxinline = 2 ** 50 |
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3058 |
|
49561
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3059 |
with repo.lock(): |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3060 |
bundle = [None, None] |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3061 |
orig_quiet = repo.ui.quiet |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3062 |
try: |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3063 |
repo.ui.quiet = True |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3064 |
with open(fname, mode="rb") as f: |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3065 |
|
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3066 |
def noop_report(*args, **kwargs): |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3067 |
pass |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3068 |
|
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3069 |
def setup(): |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3070 |
gen, tr = bundle |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3071 |
if tr is not None: |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3072 |
tr.abort() |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3073 |
bundle[:] = [None, None] |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3074 |
f.seek(0) |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3075 |
bundle[0] = exchange.readbundle(ui, f, fname) |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3076 |
bundle[1] = repo.transaction(b'perf::unbundle') |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3077 |
# silence the transaction |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3078 |
bundle[1]._report = noop_report |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3079 |
|
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3080 |
def apply(): |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3081 |
gen, tr = bundle |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3082 |
bundle2.applybundle( |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3083 |
repo, |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3084 |
gen, |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3085 |
tr, |
51436
827b89714a8d
perf: add a --as-push option to perf::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51413
diff
changeset
|
3086 |
source=unbundle_source, |
49561
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3087 |
url=fname, |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3088 |
) |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3089 |
|
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3090 |
timer, fm = gettimer(ui, opts) |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3091 |
timer(apply, setup=setup) |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3092 |
fm.end() |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3093 |
finally: |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3094 |
repo.ui.quiet == orig_quiet |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3095 |
gen, tr = bundle |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3096 |
if tr is not None: |
220738a53d05
perf-unbundle: pre-indent the main block in per::unbundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49475
diff
changeset
|
3097 |
tr.abort() |
49562
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3098 |
finally: |
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3099 |
if old_max_inline is not None: |
27bff60887fe
perf-unbundle: do a quick and dirty fix to make it run on more commit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49561
diff
changeset
|
3100 |
mercurial.revlog._maxinline = old_max_inline |
49414
3c5d0f879404
perf-unbundle: add a perf command to time the unbundle operation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49413
diff
changeset
|
3101 |
|
3c5d0f879404
perf-unbundle: add a perf command to time the unbundle operation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49413
diff
changeset
|
3102 |
|
3c5d0f879404
perf-unbundle: add a perf command to time the unbundle operation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49413
diff
changeset
|
3103 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
3104 |
b'perf::unidiff|perfunidiff', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3105 |
revlogopts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3106 |
+ formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3107 |
+ [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3108 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3109 |
b'', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3110 |
b'count', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3111 |
1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3112 |
b'number of revisions to test (when using --startrev)', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3113 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3114 |
(b'', b'alldata', False, b'test unidiffs for all associated revisions'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3115 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3116 |
b'-c|-m|FILE REV', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3117 |
) |
35861
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3118 |
def perfunidiff(ui, repo, file_, rev=None, count=None, **opts): |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3119 |
"""benchmark a unified diff between revisions |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3120 |
|
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3121 |
This doesn't include any copy tracing - it's just a unified diff |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3122 |
of the texts. |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3123 |
|
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3124 |
By default, benchmark a diff between its delta parent and itself. |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3125 |
|
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3126 |
With ``--count``, benchmark diffs between delta parents and self for N |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3127 |
revisions starting at the specified revision. |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3128 |
|
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3129 |
With ``--alldata``, assume the requested revision is a changeset and |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3130 |
measure diffs for all changes related to that changeset (manifest |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3131 |
and filelogs). |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3132 |
""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
3133 |
opts = _byteskwargs(opts) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3134 |
if opts[b'alldata']: |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3135 |
opts[b'changelog'] = True |
35861
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3136 |
|
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3137 |
if opts.get(b'changelog') or opts.get(b'manifest'): |
35861
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3138 |
file_, rev = None, file_ |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3139 |
elif rev is None: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3140 |
raise error.CommandError(b'perfunidiff', b'invalid arguments') |
35861
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3141 |
|
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3142 |
textpairs = [] |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3143 |
|
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3144 |
r = cmdutil.openrevlog(repo, b'perfunidiff', file_, opts) |
35861
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3145 |
|
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3146 |
startrev = r.rev(r.lookup(rev)) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3147 |
for rev in range(startrev, min(startrev + count, len(r) - 1)): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3148 |
if opts[b'alldata']: |
35861
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3149 |
# Load revisions associated with changeset. |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3150 |
ctx = repo[rev] |
39319
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
3151 |
mtext = _manifestrevision(repo, ctx.manifestnode()) |
35861
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3152 |
for pctx in ctx.parents(): |
39319
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
3153 |
pman = _manifestrevision(repo, pctx.manifestnode()) |
35861
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3154 |
textpairs.append((pman, mtext)) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3155 |
|
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3156 |
# Load filelog revisions by iterating manifest delta. |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3157 |
man = ctx.manifest() |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3158 |
pman = ctx.p1().manifest() |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3159 |
for filename, change in pman.diff(man).items(): |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3160 |
fctx = repo.file(filename) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3161 |
f1 = fctx.revision(change[0][0] or -1) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3162 |
f2 = fctx.revision(change[1][0] or -1) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3163 |
textpairs.append((f1, f2)) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3164 |
else: |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3165 |
dp = r.deltaparent(rev) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3166 |
textpairs.append((r.revision(dp), r.revision(rev))) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3167 |
|
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3168 |
def d(): |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3169 |
for left, right in textpairs: |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3170 |
# The date strings don't matter, so we pass empty strings. |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3171 |
headerlines, hunks = mdiff.unidiff( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3172 |
left, b'', right, b'', b'left', b'right', binary=False |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3173 |
) |
35861
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3174 |
# consume iterators in roughly the way patch.py does |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3175 |
b'\n'.join(headerlines) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3176 |
b''.join(sum((list(hlines) for hrange, hlines in hunks), [])) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3177 |
|
35861
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3178 |
timer, fm = gettimer(ui, opts) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3179 |
timer(d) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3180 |
fm.end() |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
3181 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3182 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
3183 |
@command(b'perf::diffwd|perfdiffwd', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
3184 |
def perfdiffwd(ui, repo, **opts): |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
3185 |
"""Profile diff of working directory changes""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
3186 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
3187 |
timer, fm = gettimer(ui, opts) |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
3188 |
options = { |
40214
b456b2e0ad9f
py3: make test-contrib-perf.t work on python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40145
diff
changeset
|
3189 |
'w': 'ignore_all_space', |
b456b2e0ad9f
py3: make test-contrib-perf.t work on python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40145
diff
changeset
|
3190 |
'b': 'ignore_space_change', |
b456b2e0ad9f
py3: make test-contrib-perf.t work on python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40145
diff
changeset
|
3191 |
'B': 'ignore_blank_lines', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3192 |
} |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
3193 |
|
40214
b456b2e0ad9f
py3: make test-contrib-perf.t work on python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40145
diff
changeset
|
3194 |
for diffopt in ('', 'w', 'b', 'B', 'wB'): |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44260
diff
changeset
|
3195 |
opts = {options[c]: b'1' for c in diffopt} |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3196 |
|
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
3197 |
def d(): |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
3198 |
ui.pushbuffer() |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
3199 |
commands.diff(ui, repo, **opts) |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
3200 |
ui.popbuffer() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3201 |
|
40214
b456b2e0ad9f
py3: make test-contrib-perf.t work on python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40145
diff
changeset
|
3202 |
diffopt = diffopt.encode('ascii') |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3203 |
title = b'diffopts: %s' % (diffopt and (b'-' + diffopt) or b'none') |
40679
20d2fd6036ed
perf: explicitly pass title as a keyword argument in `perfdiffwd`
Boris Feld <boris.feld@octobus.net>
parents:
40558
diff
changeset
|
3204 |
timer(d, title=title) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
3205 |
fm.end() |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
3206 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3207 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
3208 |
@command( |
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
3209 |
b'perf::revlogindex|perfrevlogindex', |
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
3210 |
revlogopts + formatteropts, |
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
3211 |
b'-c|-m|FILE', |
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
3212 |
) |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3213 |
def perfrevlogindex(ui, repo, file_=None, **opts): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3214 |
"""Benchmark operations against a revlog index. |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3215 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3216 |
This tests constructing a revlog instance, reading index data, |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3217 |
parsing index data, and performing various operations related to |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3218 |
index data. |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3219 |
""" |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3220 |
|
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
3221 |
opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
3222 |
|
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3223 |
rl = cmdutil.openrevlog(repo, b'perfrevlogindex', file_, opts) |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3224 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3225 |
opener = getattr(rl, 'opener') # trick linter |
47148
a07d5cb03a85
revlog: rename `indexfile` to `_indexfile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47072
diff
changeset
|
3226 |
# compat with hg <= 5.8 |
47150
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47149
diff
changeset
|
3227 |
radix = getattr(rl, 'radix', None) |
47148
a07d5cb03a85
revlog: rename `indexfile` to `_indexfile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47072
diff
changeset
|
3228 |
indexfile = getattr(rl, '_indexfile', None) |
a07d5cb03a85
revlog: rename `indexfile` to `_indexfile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47072
diff
changeset
|
3229 |
if indexfile is None: |
a07d5cb03a85
revlog: rename `indexfile` to `_indexfile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47072
diff
changeset
|
3230 |
# compatibility with <= hg-5.8 |
a07d5cb03a85
revlog: rename `indexfile` to `_indexfile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47072
diff
changeset
|
3231 |
indexfile = getattr(rl, 'indexfile') |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3232 |
data = opener.read(indexfile) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3233 |
|
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3234 |
header = struct.unpack(b'>I', data[0:4])[0] |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3235 |
version = header & 0xFFFF |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3236 |
if version == 1: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3237 |
inline = header & (1 << 16) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3238 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3239 |
raise error.Abort(b'unsupported revlog version: %d' % version) |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3240 |
|
47072
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47036
diff
changeset
|
3241 |
parse_index_v1 = getattr(mercurial.revlog, 'parse_index_v1', None) |
47036
5e64c93d5f94
revlog: remove the revlogio class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46974
diff
changeset
|
3242 |
if parse_index_v1 is None: |
47072
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47036
diff
changeset
|
3243 |
parse_index_v1 = mercurial.revlog.revlogio().parseindex |
47036
5e64c93d5f94
revlog: remove the revlogio class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46974
diff
changeset
|
3244 |
|
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3245 |
rllen = len(rl) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3246 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3247 |
node0 = rl.node(0) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3248 |
node25 = rl.node(rllen // 4) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3249 |
node50 = rl.node(rllen // 2) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3250 |
node75 = rl.node(rllen // 4 * 3) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3251 |
node100 = rl.node(rllen - 1) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3252 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3253 |
allrevs = range(rllen) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3254 |
allrevsrev = list(reversed(allrevs)) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3255 |
allnodes = [rl.node(rev) for rev in range(rllen)] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3256 |
allnodesrev = list(reversed(allnodes)) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3257 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3258 |
def constructor(): |
47150
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47149
diff
changeset
|
3259 |
if radix is not None: |
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47149
diff
changeset
|
3260 |
revlog(opener, radix=radix) |
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47149
diff
changeset
|
3261 |
else: |
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47149
diff
changeset
|
3262 |
# hg <= 5.8 |
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47149
diff
changeset
|
3263 |
revlog(opener, indexfile=indexfile) |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3264 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3265 |
def read(): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3266 |
with opener(indexfile) as fh: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3267 |
fh.read() |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3268 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3269 |
def parseindex(): |
47036
5e64c93d5f94
revlog: remove the revlogio class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46974
diff
changeset
|
3270 |
parse_index_v1(data, inline) |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3271 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3272 |
def getentry(revornode): |
47036
5e64c93d5f94
revlog: remove the revlogio class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46974
diff
changeset
|
3273 |
index = parse_index_v1(data, inline)[0] |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3274 |
index[revornode] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3275 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3276 |
def getentries(revs, count=1): |
47036
5e64c93d5f94
revlog: remove the revlogio class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46974
diff
changeset
|
3277 |
index = parse_index_v1(data, inline)[0] |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3278 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3279 |
for i in range(count): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3280 |
for rev in revs: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3281 |
index[rev] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3282 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3283 |
def resolvenode(node): |
47036
5e64c93d5f94
revlog: remove the revlogio class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46974
diff
changeset
|
3284 |
index = parse_index_v1(data, inline)[0] |
43572
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43571
diff
changeset
|
3285 |
rev = getattr(index, 'rev', None) |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43571
diff
changeset
|
3286 |
if rev is None: |
47036
5e64c93d5f94
revlog: remove the revlogio class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46974
diff
changeset
|
3287 |
nodemap = getattr(parse_index_v1(data, inline)[0], 'nodemap', None) |
43572
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43571
diff
changeset
|
3288 |
# This only works for the C code. |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43571
diff
changeset
|
3289 |
if nodemap is None: |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43571
diff
changeset
|
3290 |
return |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43571
diff
changeset
|
3291 |
rev = nodemap.__getitem__ |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3292 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3293 |
try: |
43572
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43571
diff
changeset
|
3294 |
rev(node) |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3295 |
except error.RevlogError: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3296 |
pass |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3297 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3298 |
def resolvenodes(nodes, count=1): |
47036
5e64c93d5f94
revlog: remove the revlogio class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46974
diff
changeset
|
3299 |
index = parse_index_v1(data, inline)[0] |
43572
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43571
diff
changeset
|
3300 |
rev = getattr(index, 'rev', None) |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43571
diff
changeset
|
3301 |
if rev is None: |
47036
5e64c93d5f94
revlog: remove the revlogio class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46974
diff
changeset
|
3302 |
nodemap = getattr(parse_index_v1(data, inline)[0], 'nodemap', None) |
43572
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43571
diff
changeset
|
3303 |
# This only works for the C code. |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43571
diff
changeset
|
3304 |
if nodemap is None: |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43571
diff
changeset
|
3305 |
return |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43571
diff
changeset
|
3306 |
rev = nodemap.__getitem__ |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3307 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3308 |
for i in range(count): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3309 |
for node in nodes: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3310 |
try: |
43572
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43571
diff
changeset
|
3311 |
rev(node) |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3312 |
except error.RevlogError: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3313 |
pass |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3314 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3315 |
benches = [ |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3316 |
(constructor, b'revlog constructor'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3317 |
(read, b'read'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3318 |
(parseindex, b'create index object'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3319 |
(lambda: getentry(0), b'retrieve index entry for rev 0'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3320 |
(lambda: resolvenode(b'a' * 20), b'look up missing node'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3321 |
(lambda: resolvenode(node0), b'look up node at rev 0'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3322 |
(lambda: resolvenode(node25), b'look up node at 1/4 len'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3323 |
(lambda: resolvenode(node50), b'look up node at 1/2 len'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3324 |
(lambda: resolvenode(node75), b'look up node at 3/4 len'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3325 |
(lambda: resolvenode(node100), b'look up node at tip'), |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3326 |
# 2x variation is to measure caching impact. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3327 |
(lambda: resolvenodes(allnodes), b'look up all nodes (forward)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3328 |
(lambda: resolvenodes(allnodes, 2), b'look up all nodes 2x (forward)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3329 |
(lambda: resolvenodes(allnodesrev), b'look up all nodes (reverse)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3330 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3331 |
lambda: resolvenodes(allnodesrev, 2), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3332 |
b'look up all nodes 2x (reverse)', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3333 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3334 |
(lambda: getentries(allrevs), b'retrieve all index entries (forward)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3335 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3336 |
lambda: getentries(allrevs, 2), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3337 |
b'retrieve all index entries 2x (forward)', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3338 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3339 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3340 |
lambda: getentries(allrevsrev), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3341 |
b'retrieve all index entries (reverse)', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3342 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3343 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3344 |
lambda: getentries(allrevsrev, 2), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3345 |
b'retrieve all index entries 2x (reverse)', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3346 |
), |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3347 |
] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3348 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3349 |
for fn, title in benches: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3350 |
timer, fm = gettimer(ui, opts) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3351 |
timer(fn, title=title) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3352 |
fm.end() |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
3353 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3354 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3355 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
3356 |
b'perf::revlogrevisions|perfrevlogrevisions', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3357 |
revlogopts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3358 |
+ formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3359 |
+ [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3360 |
(b'd', b'dist', 100, b'distance between the revisions'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3361 |
(b's', b'startrev', 0, b'revision to start reading at'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3362 |
(b'', b'reverse', False, b'read in reverse'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3363 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3364 |
b'-c|-m|FILE', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3365 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3366 |
def perfrevlogrevisions( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3367 |
ui, repo, file_=None, startrev=0, reverse=False, **opts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3368 |
): |
27492
ac549d7fbc2b
perf: use standard arguments for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27472
diff
changeset
|
3369 |
"""Benchmark reading a series of revisions from a revlog. |
ac549d7fbc2b
perf: use standard arguments for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27472
diff
changeset
|
3370 |
|
ac549d7fbc2b
perf: use standard arguments for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27472
diff
changeset
|
3371 |
By default, we read every ``-d/--dist`` revision from 0 to tip of |
ac549d7fbc2b
perf: use standard arguments for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27472
diff
changeset
|
3372 |
the specified revlog. |
27493
14b0930105da
perf: make start revision configurable for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27492
diff
changeset
|
3373 |
|
14b0930105da
perf: make start revision configurable for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27492
diff
changeset
|
3374 |
The start revision can be defined via ``-s/--startrev``. |
27492
ac549d7fbc2b
perf: use standard arguments for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27472
diff
changeset
|
3375 |
""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
3376 |
opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
3377 |
|
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3378 |
rl = cmdutil.openrevlog(repo, b'perfrevlogrevisions', file_, opts) |
32232
4c6b2076d292
perf: move revlog construction and length calculation out of benchmark
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32231
diff
changeset
|
3379 |
rllen = getlen(ui)(rl) |
30017
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
3380 |
|
40143
d5d28d360a19
pref: support negative indexing in perfrevlogrevisions
Boris Feld <boris.feld@octobus.net>
parents:
40142
diff
changeset
|
3381 |
if startrev < 0: |
d5d28d360a19
pref: support negative indexing in perfrevlogrevisions
Boris Feld <boris.feld@octobus.net>
parents:
40142
diff
changeset
|
3382 |
startrev = rllen + startrev |
d5d28d360a19
pref: support negative indexing in perfrevlogrevisions
Boris Feld <boris.feld@octobus.net>
parents:
40142
diff
changeset
|
3383 |
|
11694
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
3384 |
def d(): |
32232
4c6b2076d292
perf: move revlog construction and length calculation out of benchmark
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32231
diff
changeset
|
3385 |
rl.clearcaches() |
30017
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
3386 |
|
32224
6b582f9b6e5e
perf: don't clobber startrev variable
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32202
diff
changeset
|
3387 |
beginrev = startrev |
32232
4c6b2076d292
perf: move revlog construction and length calculation out of benchmark
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32231
diff
changeset
|
3388 |
endrev = rllen |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3389 |
dist = opts[b'dist'] |
30017
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
3390 |
|
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
3391 |
if reverse: |
40537
cbd251d479bb
perf: fix perfrevlogrevisions --reverse
Boris Feld <boris.feld@octobus.net>
parents:
40531
diff
changeset
|
3392 |
beginrev, endrev = endrev - 1, beginrev - 1 |
30017
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
3393 |
dist = -1 * dist |
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
3394 |
|
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
3395 |
for x in _xrange(beginrev, endrev, dist): |
32297
d7efaf6275a7
perf: always pass node to revlog.revision()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32232
diff
changeset
|
3396 |
# Old revisions don't support passing int. |
d7efaf6275a7
perf: always pass node to revlog.revision()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32232
diff
changeset
|
3397 |
n = rl.node(x) |
d7efaf6275a7
perf: always pass node to revlog.revision()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32232
diff
changeset
|
3398 |
rl.revision(n) |
11694
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
3399 |
|
32225
c68c400d0a2d
perf: move gettimer() call
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32224
diff
changeset
|
3400 |
timer, fm = gettimer(ui, opts) |
11694
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
3401 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
3402 |
fm.end() |
11694
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
3403 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3404 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3405 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
3406 |
b'perf::revlogwrite|perfrevlogwrite', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3407 |
revlogopts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3408 |
+ formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3409 |
+ [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3410 |
(b's', b'startrev', 1000, b'revision to start writing at'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3411 |
(b'', b'stoprev', -1, b'last revision to write'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3412 |
(b'', b'count', 3, b'number of passes to perform'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3413 |
(b'', b'details', False, b'print timing for every revisions tested'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3414 |
(b'', b'source', b'full', b'the kind of data feed in the revlog'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3415 |
(b'', b'lazydeltabase', True, b'try the provided delta first'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3416 |
(b'', b'clear-caches', True, b'clear revlog cache between calls'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3417 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3418 |
b'-c|-m|FILE', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3419 |
) |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3420 |
def perfrevlogwrite(ui, repo, file_=None, startrev=1000, stoprev=-1, **opts): |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3421 |
"""Benchmark writing a series of revisions to a revlog. |
40553
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
3422 |
|
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
3423 |
Possible source values are: |
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
3424 |
* `full`: add from a full text (default). |
40554
6c2357029364
perf: add `parent-1` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40553
diff
changeset
|
3425 |
* `parent-1`: add from a delta to the first parent |
40555
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40554
diff
changeset
|
3426 |
* `parent-2`: add from a delta to the second parent if it exists |
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40554
diff
changeset
|
3427 |
(use a delta from the first parent otherwise) |
40556
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
3428 |
* `parent-smallest`: add from the smallest delta (either p1 or p2) |
40557
355ae096faef
perf: add `storage` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40556
diff
changeset
|
3429 |
* `storage`: add from the existing precomputed deltas |
42461
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42460
diff
changeset
|
3430 |
|
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42460
diff
changeset
|
3431 |
Note: This performance command measures performance in a custom way. As a |
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42460
diff
changeset
|
3432 |
result some of the global configuration of the 'perf' command does not |
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42460
diff
changeset
|
3433 |
apply to it: |
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42460
diff
changeset
|
3434 |
|
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42460
diff
changeset
|
3435 |
* ``pre-run``: disabled |
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42460
diff
changeset
|
3436 |
|
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42460
diff
changeset
|
3437 |
* ``profile-benchmark``: disabled |
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42460
diff
changeset
|
3438 |
|
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42460
diff
changeset
|
3439 |
* ``run-limits``: disabled use --count instead |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3440 |
""" |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3441 |
opts = _byteskwargs(opts) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3442 |
|
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3443 |
rl = cmdutil.openrevlog(repo, b'perfrevlogwrite', file_, opts) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3444 |
rllen = getlen(ui)(rl) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3445 |
if startrev < 0: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3446 |
startrev = rllen + startrev |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3447 |
if stoprev < 0: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3448 |
stoprev = rllen + stoprev |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3449 |
|
40558
4756a33d0d31
perf: add a lazydeltabase option to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40557
diff
changeset
|
3450 |
lazydeltabase = opts['lazydeltabase'] |
40553
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
3451 |
source = opts['source'] |
41002
e88ced97151d
perfrevlogwrite: fix a typo in the option name
Boris Feld <boris.feld@octobus.net>
parents:
40977
diff
changeset
|
3452 |
clearcaches = opts['clear_caches'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3453 |
validsource = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3454 |
b'full', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3455 |
b'parent-1', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3456 |
b'parent-2', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3457 |
b'parent-smallest', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3458 |
b'storage', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3459 |
) |
40553
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
3460 |
if source not in validsource: |
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
3461 |
raise error.Abort('invalid source type: %s' % source) |
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
3462 |
|
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3463 |
### actually gather results |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3464 |
count = opts['count'] |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3465 |
if count <= 0: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3466 |
raise error.Abort('invalide run count: %d' % count) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3467 |
allresults = [] |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3468 |
for c in range(count): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3469 |
timing = _timeonewrite( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3470 |
ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3471 |
rl, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3472 |
source, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3473 |
startrev, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3474 |
stoprev, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3475 |
c + 1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3476 |
lazydeltabase=lazydeltabase, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3477 |
clearcaches=clearcaches, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3478 |
) |
40553
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
3479 |
allresults.append(timing) |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3480 |
|
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3481 |
### consolidate the results in a single list |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3482 |
results = [] |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3483 |
for idx, (rev, t) in enumerate(allresults[0]): |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3484 |
ts = [t] |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3485 |
for other in allresults[1:]: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3486 |
orev, ot = other[idx] |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3487 |
assert orev == rev |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3488 |
ts.append(ot) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3489 |
results.append((rev, ts)) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3490 |
resultcount = len(results) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3491 |
|
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3492 |
### Compute and display relevant statistics |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3493 |
|
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3494 |
# get a formatter |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3495 |
fm = ui.formatter(b'perf', opts) |
50802
cf0502231d56
perf: display all timing by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50795
diff
changeset
|
3496 |
displayall = ui.configbool(b"perf", b"all-timing", True) |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3497 |
|
40551
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40550
diff
changeset
|
3498 |
# print individual details if requested |
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40550
diff
changeset
|
3499 |
if opts['details']: |
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40550
diff
changeset
|
3500 |
for idx, item in enumerate(results, 1): |
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40550
diff
changeset
|
3501 |
rev, data = item |
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40550
diff
changeset
|
3502 |
title = 'revisions #%d of %d, rev %d' % (idx, resultcount, rev) |
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40550
diff
changeset
|
3503 |
formatone(fm, data, title=title, displayall=displayall) |
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40550
diff
changeset
|
3504 |
|
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3505 |
# sorts results by median time |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3506 |
results.sort(key=lambda x: sorted(x[1])[len(x[1]) // 2]) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3507 |
# list of (name, index) to display) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3508 |
relevants = [ |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3509 |
("min", 0), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3510 |
("10%", resultcount * 10 // 100), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3511 |
("25%", resultcount * 25 // 100), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3512 |
("50%", resultcount * 70 // 100), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3513 |
("75%", resultcount * 75 // 100), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3514 |
("90%", resultcount * 90 // 100), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3515 |
("95%", resultcount * 95 // 100), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3516 |
("99%", resultcount * 99 // 100), |
40956
74ee5ff1e81c
perf: report more of the higher range in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40948
diff
changeset
|
3517 |
("99.9%", resultcount * 999 // 1000), |
74ee5ff1e81c
perf: report more of the higher range in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40948
diff
changeset
|
3518 |
("99.99%", resultcount * 9999 // 10000), |
74ee5ff1e81c
perf: report more of the higher range in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40948
diff
changeset
|
3519 |
("99.999%", resultcount * 99999 // 100000), |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3520 |
("max", -1), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3521 |
] |
40552
c63081cd3902
perf: only display the total time for perfrevlogwrite if quiet
Boris Feld <boris.feld@octobus.net>
parents:
40551
diff
changeset
|
3522 |
if not ui.quiet: |
c63081cd3902
perf: only display the total time for perfrevlogwrite if quiet
Boris Feld <boris.feld@octobus.net>
parents:
40551
diff
changeset
|
3523 |
for name, idx in relevants: |
c63081cd3902
perf: only display the total time for perfrevlogwrite if quiet
Boris Feld <boris.feld@octobus.net>
parents:
40551
diff
changeset
|
3524 |
data = results[idx] |
c63081cd3902
perf: only display the total time for perfrevlogwrite if quiet
Boris Feld <boris.feld@octobus.net>
parents:
40551
diff
changeset
|
3525 |
title = '%s of %d, rev %d' % (name, resultcount, data[0]) |
c63081cd3902
perf: only display the total time for perfrevlogwrite if quiet
Boris Feld <boris.feld@octobus.net>
parents:
40551
diff
changeset
|
3526 |
formatone(fm, data[1], title=title, displayall=displayall) |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3527 |
|
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3528 |
# XXX summing that many float will not be very precise, we ignore this fact |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3529 |
# for now |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3530 |
totaltime = [] |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3531 |
for item in allresults: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3532 |
totaltime.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3533 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3534 |
sum(x[1][0] for x in item), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3535 |
sum(x[1][1] for x in item), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3536 |
sum(x[1][2] for x in item), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3537 |
) |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3538 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3539 |
formatone( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3540 |
fm, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3541 |
totaltime, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3542 |
title="total time (%d revs)" % resultcount, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3543 |
displayall=displayall, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3544 |
) |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3545 |
fm.end() |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3546 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3547 |
|
48946
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
3548 |
class _faketr: |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3549 |
def add(s, x, y, z=None): |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3550 |
return None |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3551 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3552 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3553 |
def _timeonewrite( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3554 |
ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3555 |
orig, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3556 |
source, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3557 |
startrev, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3558 |
stoprev, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3559 |
runidx=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3560 |
lazydeltabase=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3561 |
clearcaches=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3562 |
): |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3563 |
timings = [] |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3564 |
tr = _faketr() |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3565 |
with _temprevlog(ui, orig, startrev) as dest: |
51067
26dcdbe15024
revlog: remove legacy usage of `_lazydeltabase`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51059
diff
changeset
|
3566 |
if hasattr(dest, "delta_config"): |
26dcdbe15024
revlog: remove legacy usage of `_lazydeltabase`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51059
diff
changeset
|
3567 |
dest.delta_config.lazy_delta_base = lazydeltabase |
26dcdbe15024
revlog: remove legacy usage of `_lazydeltabase`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51059
diff
changeset
|
3568 |
else: |
26dcdbe15024
revlog: remove legacy usage of `_lazydeltabase`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51059
diff
changeset
|
3569 |
dest._lazydeltabase = lazydeltabase |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3570 |
revs = list(orig.revs(startrev, stoprev)) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3571 |
total = len(revs) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3572 |
topic = 'adding' |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3573 |
if runidx is not None: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3574 |
topic += ' (run #%d)' % runidx |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3575 |
# Support both old and new progress API |
41156
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
3576 |
if util.safehasattr(ui, 'makeprogress'): |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
3577 |
progress = ui.makeprogress(topic, unit='revs', total=total) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3578 |
|
41156
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
3579 |
def updateprogress(pos): |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
3580 |
progress.update(pos) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3581 |
|
41156
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
3582 |
def completeprogress(): |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
3583 |
progress.complete() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3584 |
|
41156
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
3585 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3586 |
|
41156
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
3587 |
def updateprogress(pos): |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
3588 |
ui.progress(topic, pos, unit='revs', total=total) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3589 |
|
41156
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
3590 |
def completeprogress(): |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
3591 |
ui.progress(topic, None, unit='revs', total=total) |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
3592 |
|
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3593 |
for idx, rev in enumerate(revs): |
41156
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
3594 |
updateprogress(idx) |
40553
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
3595 |
addargs, addkwargs = _getrevisionseed(orig, rev, tr, source) |
40977
21a9cace4bbf
perfrevflogwrite: clear revlog cache between each write
Boris Feld <boris.feld@octobus.net>
parents:
40956
diff
changeset
|
3596 |
if clearcaches: |
21a9cace4bbf
perfrevflogwrite: clear revlog cache between each write
Boris Feld <boris.feld@octobus.net>
parents:
40956
diff
changeset
|
3597 |
dest.index.clearcaches() |
21a9cace4bbf
perfrevflogwrite: clear revlog cache between each write
Boris Feld <boris.feld@octobus.net>
parents:
40956
diff
changeset
|
3598 |
dest.clearcaches() |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3599 |
with timeone() as r: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3600 |
dest.addrawrevision(*addargs, **addkwargs) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3601 |
timings.append((rev, r[0])) |
41156
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
3602 |
updateprogress(total) |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
3603 |
completeprogress() |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3604 |
return timings |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3605 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3606 |
|
40553
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
3607 |
def _getrevisionseed(orig, rev, tr, source): |
40555
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40554
diff
changeset
|
3608 |
from mercurial.node import nullid |
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40554
diff
changeset
|
3609 |
|
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3610 |
linkrev = orig.linkrev(rev) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3611 |
node = orig.node(rev) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3612 |
p1, p2 = orig.parents(node) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3613 |
flags = orig.flags(rev) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3614 |
cachedelta = None |
40553
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
3615 |
text = None |
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
3616 |
|
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
3617 |
if source == b'full': |
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
3618 |
text = orig.revision(rev) |
40554
6c2357029364
perf: add `parent-1` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40553
diff
changeset
|
3619 |
elif source == b'parent-1': |
6c2357029364
perf: add `parent-1` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40553
diff
changeset
|
3620 |
baserev = orig.rev(p1) |
6c2357029364
perf: add `parent-1` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40553
diff
changeset
|
3621 |
cachedelta = (baserev, orig.revdiff(p1, rev)) |
40555
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40554
diff
changeset
|
3622 |
elif source == b'parent-2': |
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40554
diff
changeset
|
3623 |
parent = p2 |
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40554
diff
changeset
|
3624 |
if p2 == nullid: |
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40554
diff
changeset
|
3625 |
parent = p1 |
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40554
diff
changeset
|
3626 |
baserev = orig.rev(parent) |
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40554
diff
changeset
|
3627 |
cachedelta = (baserev, orig.revdiff(parent, rev)) |
40556
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
3628 |
elif source == b'parent-smallest': |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
3629 |
p1diff = orig.revdiff(p1, rev) |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
3630 |
parent = p1 |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
3631 |
diff = p1diff |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
3632 |
if p2 != nullid: |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
3633 |
p2diff = orig.revdiff(p2, rev) |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
3634 |
if len(p1diff) > len(p2diff): |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
3635 |
parent = p2 |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
3636 |
diff = p2diff |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
3637 |
baserev = orig.rev(parent) |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
3638 |
cachedelta = (baserev, diff) |
40557
355ae096faef
perf: add `storage` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40556
diff
changeset
|
3639 |
elif source == b'storage': |
355ae096faef
perf: add `storage` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40556
diff
changeset
|
3640 |
baserev = orig.deltaparent(rev) |
355ae096faef
perf: add `storage` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40556
diff
changeset
|
3641 |
cachedelta = (baserev, orig.revdiff(orig.node(baserev), rev)) |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3642 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3643 |
return ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3644 |
(text, tr, linkrev, p1, p2), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3645 |
{'node': node, 'flags': flags, 'cachedelta': cachedelta}, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3646 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3647 |
|
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3648 |
|
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3649 |
@contextlib.contextmanager |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3650 |
def _temprevlog(ui, orig, truncaterev): |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3651 |
from mercurial import vfs as vfsmod |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3652 |
|
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3653 |
if orig._inline: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3654 |
raise error.Abort('not supporting inline revlog (yet)') |
42462
bc4373babd04
revlog: add the option to track the expected compression upper bound
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42461
diff
changeset
|
3655 |
revlogkwargs = {} |
bc4373babd04
revlog: add the option to track the expected compression upper bound
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42461
diff
changeset
|
3656 |
k = 'upperboundcomp' |
bc4373babd04
revlog: add the option to track the expected compression upper bound
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42461
diff
changeset
|
3657 |
if util.safehasattr(orig, k): |
bc4373babd04
revlog: add the option to track the expected compression upper bound
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42461
diff
changeset
|
3658 |
revlogkwargs[k] = getattr(orig, k) |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3659 |
|
47148
a07d5cb03a85
revlog: rename `indexfile` to `_indexfile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47072
diff
changeset
|
3660 |
indexfile = getattr(orig, '_indexfile', None) |
a07d5cb03a85
revlog: rename `indexfile` to `_indexfile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47072
diff
changeset
|
3661 |
if indexfile is None: |
a07d5cb03a85
revlog: rename `indexfile` to `_indexfile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47072
diff
changeset
|
3662 |
# compatibility with <= hg-5.8 |
a07d5cb03a85
revlog: rename `indexfile` to `_indexfile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47072
diff
changeset
|
3663 |
indexfile = getattr(orig, 'indexfile') |
a07d5cb03a85
revlog: rename `indexfile` to `_indexfile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47072
diff
changeset
|
3664 |
origindexpath = orig.opener.join(indexfile) |
47149
396442cd7e6a
revlog: rename `datafile` to `datafile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47148
diff
changeset
|
3665 |
|
396442cd7e6a
revlog: rename `datafile` to `datafile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47148
diff
changeset
|
3666 |
datafile = getattr(orig, '_datafile', getattr(orig, 'datafile')) |
396442cd7e6a
revlog: rename `datafile` to `datafile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47148
diff
changeset
|
3667 |
origdatapath = orig.opener.join(datafile) |
47150
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47149
diff
changeset
|
3668 |
radix = b'revlog' |
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47149
diff
changeset
|
3669 |
indexname = b'revlog.i' |
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47149
diff
changeset
|
3670 |
dataname = b'revlog.d' |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3671 |
|
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3672 |
tmpdir = tempfile.mkdtemp(prefix='tmp-hgperf-') |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3673 |
try: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3674 |
# copy the data file in a temporary directory |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3675 |
ui.debug('copying data in %s\n' % tmpdir) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3676 |
destindexpath = os.path.join(tmpdir, 'revlog.i') |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3677 |
destdatapath = os.path.join(tmpdir, 'revlog.d') |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3678 |
shutil.copyfile(origindexpath, destindexpath) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3679 |
shutil.copyfile(origdatapath, destdatapath) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3680 |
|
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3681 |
# remove the data we want to add again |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3682 |
ui.debug('truncating data to be rewritten\n') |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3683 |
with open(destindexpath, 'ab') as index: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3684 |
index.seek(0) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3685 |
index.truncate(truncaterev * orig._io.size) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3686 |
with open(destdatapath, 'ab') as data: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3687 |
data.seek(0) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3688 |
data.truncate(orig.start(truncaterev)) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3689 |
|
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3690 |
# instantiate a new revlog from the temporary copy |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3691 |
ui.debug('truncating adding to be rewritten\n') |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3692 |
vfs = vfsmod.vfs(tmpdir) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3693 |
vfs.options = getattr(orig.opener, 'options', None) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3694 |
|
47150
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47149
diff
changeset
|
3695 |
try: |
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47149
diff
changeset
|
3696 |
dest = revlog(vfs, radix=radix, **revlogkwargs) |
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47149
diff
changeset
|
3697 |
except TypeError: |
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47149
diff
changeset
|
3698 |
dest = revlog( |
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47149
diff
changeset
|
3699 |
vfs, indexfile=indexname, datafile=dataname, **revlogkwargs |
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47149
diff
changeset
|
3700 |
) |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3701 |
if dest._inline: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3702 |
raise error.Abort('not supporting inline revlog (yet)') |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3703 |
# make sure internals are initialized |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3704 |
dest.revision(len(dest) - 1) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3705 |
yield dest |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3706 |
del dest, vfs |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3707 |
finally: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3708 |
shutil.rmtree(tmpdir, True) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
3709 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3710 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3711 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
3712 |
b'perf::revlogchunks|perfrevlogchunks', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3713 |
revlogopts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3714 |
+ formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3715 |
+ [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3716 |
(b'e', b'engines', b'', b'compression engines to use'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3717 |
(b's', b'startrev', 0, b'revision to start at'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3718 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3719 |
b'-c|-m|FILE', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3720 |
) |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3721 |
def perfrevlogchunks(ui, repo, file_=None, engines=None, startrev=0, **opts): |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3722 |
"""Benchmark operations on revlog chunks. |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3723 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3724 |
Logically, each revlog is a collection of fulltext revisions. However, |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3725 |
stored within each revlog are "chunks" of possibly compressed data. This |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3726 |
data needs to be read and decompressed or compressed and written. |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3727 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3728 |
This command measures the time it takes to read+decompress and recompress |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3729 |
chunks in a revlog. It effectively isolates I/O and compression performance. |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3730 |
For measurements of higher-level operations like resolving revisions, |
32531
7236facefd4f
perf: rename perfrevlog to perfrevlogrevisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32467
diff
changeset
|
3731 |
see ``perfrevlogrevisions`` and ``perfrevlogrevision``. |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3732 |
""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
3733 |
opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
3734 |
|
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3735 |
rl = cmdutil.openrevlog(repo, b'perfrevlogchunks', file_, opts) |
32229
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
3736 |
|
51087
df50a1592e0c
revlog: move _getsegmentforrevs on the internal object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51067
diff
changeset
|
3737 |
# - _chunkraw was renamed to _getsegmentforrevs |
df50a1592e0c
revlog: move _getsegmentforrevs on the internal object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51067
diff
changeset
|
3738 |
# - _getsegmentforrevs was moved on the inner object |
32229
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
3739 |
try: |
51087
df50a1592e0c
revlog: move _getsegmentforrevs on the internal object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51067
diff
changeset
|
3740 |
segmentforrevs = rl._inner.get_segment_for_revs |
32229
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
3741 |
except AttributeError: |
51087
df50a1592e0c
revlog: move _getsegmentforrevs on the internal object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51067
diff
changeset
|
3742 |
try: |
df50a1592e0c
revlog: move _getsegmentforrevs on the internal object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51067
diff
changeset
|
3743 |
segmentforrevs = rl._getsegmentforrevs |
df50a1592e0c
revlog: move _getsegmentforrevs on the internal object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51067
diff
changeset
|
3744 |
except AttributeError: |
df50a1592e0c
revlog: move _getsegmentforrevs on the internal object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51067
diff
changeset
|
3745 |
segmentforrevs = rl._chunkraw |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3746 |
|
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3747 |
# Verify engines argument. |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3748 |
if engines: |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44260
diff
changeset
|
3749 |
engines = {e.strip() for e in engines.split(b',')} |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3750 |
for engine in engines: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3751 |
try: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3752 |
util.compressionengines[engine] |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3753 |
except KeyError: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3754 |
raise error.Abort(b'unknown compression engine: %s' % engine) |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3755 |
else: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3756 |
engines = [] |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3757 |
for e in util.compengines: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3758 |
engine = util.compengines[e] |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3759 |
try: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3760 |
if engine.available(): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3761 |
engine.revlogcompressor().compress(b'dummy') |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3762 |
engines.append(e) |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3763 |
except NotImplementedError: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3764 |
pass |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3765 |
|
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3766 |
revs = list(rl.revs(startrev, len(rl) - 1)) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3767 |
|
51008
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3768 |
@contextlib.contextmanager |
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3769 |
def reading(rl): |
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3770 |
if getattr(rl, 'reading', None) is not None: |
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3771 |
with rl.reading(): |
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3772 |
yield None |
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3773 |
elif rl._inline: |
47148
a07d5cb03a85
revlog: rename `indexfile` to `_indexfile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47072
diff
changeset
|
3774 |
indexfile = getattr(rl, '_indexfile', None) |
a07d5cb03a85
revlog: rename `indexfile` to `_indexfile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47072
diff
changeset
|
3775 |
if indexfile is None: |
a07d5cb03a85
revlog: rename `indexfile` to `_indexfile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47072
diff
changeset
|
3776 |
# compatibility with <= hg-5.8 |
a07d5cb03a85
revlog: rename `indexfile` to `_indexfile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47072
diff
changeset
|
3777 |
indexfile = getattr(rl, 'indexfile') |
51008
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3778 |
yield getsvfs(repo)(indexfile) |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3779 |
else: |
47149
396442cd7e6a
revlog: rename `datafile` to `datafile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47148
diff
changeset
|
3780 |
datafile = getattr(rl, 'datafile', getattr(rl, 'datafile')) |
51008
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3781 |
yield getsvfs(repo)(datafile) |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3782 |
|
51009
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3783 |
if getattr(rl, 'reading', None) is not None: |
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3784 |
|
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3785 |
@contextlib.contextmanager |
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3786 |
def lazy_reading(rl): |
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3787 |
with rl.reading(): |
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3788 |
yield |
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3789 |
|
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3790 |
else: |
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3791 |
|
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3792 |
@contextlib.contextmanager |
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3793 |
def lazy_reading(rl): |
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3794 |
yield |
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3795 |
|
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3796 |
def doread(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3797 |
rl.clearcaches() |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3798 |
for rev in revs: |
51009
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3799 |
with lazy_reading(rl): |
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3800 |
segmentforrevs(rev, rev) |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3801 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3802 |
def doreadcachedfh(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3803 |
rl.clearcaches() |
51008
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3804 |
with reading(rl) as fh: |
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3805 |
if fh is not None: |
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3806 |
for rev in revs: |
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3807 |
segmentforrevs(rev, rev, df=fh) |
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3808 |
else: |
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3809 |
for rev in revs: |
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3810 |
segmentforrevs(rev, rev) |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3811 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3812 |
def doreadbatch(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3813 |
rl.clearcaches() |
51009
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3814 |
with lazy_reading(rl): |
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3815 |
segmentforrevs(revs[0], revs[-1]) |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3816 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3817 |
def doreadbatchcachedfh(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3818 |
rl.clearcaches() |
51008
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3819 |
with reading(rl) as fh: |
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3820 |
if fh is not None: |
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3821 |
segmentforrevs(revs[0], revs[-1], df=fh) |
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3822 |
else: |
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3823 |
segmentforrevs(revs[0], revs[-1]) |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3824 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3825 |
def dochunk(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3826 |
rl.clearcaches() |
51092
9c8df10ea6e0
revlog: move the `_chunk` method on the inner object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51091
diff
changeset
|
3827 |
# chunk used to be available directly on the revlog |
9c8df10ea6e0
revlog: move the `_chunk` method on the inner object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51091
diff
changeset
|
3828 |
_chunk = getattr(rl, '_inner', rl)._chunk |
51008
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3829 |
with reading(rl) as fh: |
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3830 |
if fh is not None: |
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3831 |
for rev in revs: |
51092
9c8df10ea6e0
revlog: move the `_chunk` method on the inner object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51091
diff
changeset
|
3832 |
_chunk(rev, df=fh) |
51008
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3833 |
else: |
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3834 |
for rev in revs: |
51092
9c8df10ea6e0
revlog: move the `_chunk` method on the inner object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51091
diff
changeset
|
3835 |
_chunk(rev) |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3836 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3837 |
chunks = [None] |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3838 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3839 |
def dochunkbatch(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3840 |
rl.clearcaches() |
51094
e8ad6d8de8b8
revlog: move the `_chunks` method on the inner object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51092
diff
changeset
|
3841 |
_chunks = getattr(rl, '_inner', rl)._chunks |
51008
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3842 |
with reading(rl) as fh: |
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3843 |
if fh is not None: |
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3844 |
# Save chunks as a side-effect. |
51094
e8ad6d8de8b8
revlog: move the `_chunks` method on the inner object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51092
diff
changeset
|
3845 |
chunks[0] = _chunks(revs, df=fh) |
51008
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3846 |
else: |
2f1967ffefb1
perf: change the way we approach revlog reading
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50993
diff
changeset
|
3847 |
# Save chunks as a side-effect. |
51094
e8ad6d8de8b8
revlog: move the `_chunks` method on the inner object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51092
diff
changeset
|
3848 |
chunks[0] = _chunks(revs) |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3849 |
|
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3850 |
def docompress(compressor): |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3851 |
rl.clearcaches() |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3852 |
|
51091
a82704902db8
revlog: move the compression/decompression logic on the inner object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51087
diff
changeset
|
3853 |
compressor_holder = getattr(rl, '_inner', rl) |
a82704902db8
revlog: move the compression/decompression logic on the inner object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51087
diff
changeset
|
3854 |
|
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3855 |
try: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3856 |
# Swap in the requested compression engine. |
51091
a82704902db8
revlog: move the compression/decompression logic on the inner object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51087
diff
changeset
|
3857 |
oldcompressor = compressor_holder._compressor |
a82704902db8
revlog: move the compression/decompression logic on the inner object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51087
diff
changeset
|
3858 |
compressor_holder._compressor = compressor |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3859 |
for chunk in chunks[0]: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3860 |
rl.compress(chunk) |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3861 |
finally: |
51091
a82704902db8
revlog: move the compression/decompression logic on the inner object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51087
diff
changeset
|
3862 |
compressor_holder._compressor = oldcompressor |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3863 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3864 |
benches = [ |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3865 |
(lambda: doread(), b'read'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3866 |
(lambda: doreadcachedfh(), b'read w/ reused fd'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3867 |
(lambda: doreadbatch(), b'read batch'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3868 |
(lambda: doreadbatchcachedfh(), b'read batch w/ reused fd'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3869 |
(lambda: dochunk(), b'chunk'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3870 |
(lambda: dochunkbatch(), b'chunk batch'), |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3871 |
] |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3872 |
|
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3873 |
for engine in sorted(engines): |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3874 |
compressor = util.compengines[engine].revlogcompressor() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3875 |
benches.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3876 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3877 |
functools.partial(docompress, compressor), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3878 |
b'compress w/ %s' % engine, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3879 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3880 |
) |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3881 |
|
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3882 |
for fn, title in benches: |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3883 |
timer, fm = gettimer(ui, opts) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3884 |
timer(fn, title=title) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3885 |
fm.end() |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
3886 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3887 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3888 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
3889 |
b'perf::revlogrevision|perfrevlogrevision', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3890 |
revlogopts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3891 |
+ formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3892 |
+ [(b'', b'cache', False, b'use caches instead of clearing')], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3893 |
b'-c|-m|FILE REV', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
3894 |
) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3895 |
def perfrevlogrevision(ui, repo, file_, rev=None, cache=None, **opts): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3896 |
"""Benchmark obtaining a revlog revision. |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3897 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3898 |
Obtaining a revlog revision consists of roughly the following steps: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3899 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3900 |
1. Compute the delta chain |
40531
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
3901 |
2. Slice the delta chain if applicable |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
3902 |
3. Obtain the raw chunks for that delta chain |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
3903 |
4. Decompress each raw chunk |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
3904 |
5. Apply binary patches to obtain fulltext |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
3905 |
6. Verify hash of fulltext |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3906 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3907 |
This command measures the time spent in each of these phases. |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3908 |
""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
3909 |
opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
3910 |
|
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3911 |
if opts.get(b'changelog') or opts.get(b'manifest'): |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3912 |
file_, rev = None, file_ |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3913 |
elif rev is None: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3914 |
raise error.CommandError(b'perfrevlogrevision', b'invalid arguments') |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3915 |
|
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3916 |
r = cmdutil.openrevlog(repo, b'perfrevlogrevision', file_, opts) |
32229
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
3917 |
|
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
3918 |
# _chunkraw was renamed to _getsegmentforrevs. |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
3919 |
try: |
51087
df50a1592e0c
revlog: move _getsegmentforrevs on the internal object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51067
diff
changeset
|
3920 |
segmentforrevs = r._inner.get_segment_for_revs |
32229
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
3921 |
except AttributeError: |
51087
df50a1592e0c
revlog: move _getsegmentforrevs on the internal object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51067
diff
changeset
|
3922 |
try: |
df50a1592e0c
revlog: move _getsegmentforrevs on the internal object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51067
diff
changeset
|
3923 |
segmentforrevs = r._getsegmentforrevs |
df50a1592e0c
revlog: move _getsegmentforrevs on the internal object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51067
diff
changeset
|
3924 |
except AttributeError: |
df50a1592e0c
revlog: move _getsegmentforrevs on the internal object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51067
diff
changeset
|
3925 |
segmentforrevs = r._chunkraw |
32229
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
3926 |
|
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3927 |
node = r.lookup(rev) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3928 |
rev = r.rev(node) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3929 |
|
51009
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3930 |
if getattr(r, 'reading', None) is not None: |
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3931 |
|
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3932 |
@contextlib.contextmanager |
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3933 |
def lazy_reading(r): |
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3934 |
with r.reading(): |
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3935 |
yield |
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3936 |
|
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3937 |
else: |
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3938 |
|
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3939 |
@contextlib.contextmanager |
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3940 |
def lazy_reading(r): |
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3941 |
yield |
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3942 |
|
30882
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3943 |
def getrawchunks(data, chain): |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3944 |
start = r.start |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3945 |
length = r.length |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3946 |
inline = r._inline |
46974
3c9208702db3
revlog: replace revlog._io.size with a new revlog.index.entry_size
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46973
diff
changeset
|
3947 |
try: |
3c9208702db3
revlog: replace revlog._io.size with a new revlog.index.entry_size
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46973
diff
changeset
|
3948 |
iosize = r.index.entry_size |
3c9208702db3
revlog: replace revlog._io.size with a new revlog.index.entry_size
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46973
diff
changeset
|
3949 |
except AttributeError: |
3c9208702db3
revlog: replace revlog._io.size with a new revlog.index.entry_size
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46973
diff
changeset
|
3950 |
iosize = r._io.size |
30882
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3951 |
buffer = util.buffer |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3952 |
|
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3953 |
chunks = [] |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3954 |
ladd = chunks.append |
40530
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
3955 |
for idx, item in enumerate(chain): |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
3956 |
offset = start(item[0]) |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
3957 |
bits = data[idx] |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
3958 |
for rev in item: |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
3959 |
chunkstart = start(rev) |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
3960 |
if inline: |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
3961 |
chunkstart += (rev + 1) * iosize |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
3962 |
chunklength = length(rev) |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
3963 |
ladd(buffer(bits, chunkstart - offset, chunklength)) |
30882
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3964 |
|
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3965 |
return chunks |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3966 |
|
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3967 |
def dodeltachain(rev): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3968 |
if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3969 |
r.clearcaches() |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3970 |
r._deltachain(rev) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3971 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3972 |
def doread(chain): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3973 |
if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3974 |
r.clearcaches() |
40530
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
3975 |
for item in slicedchain: |
51009
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3976 |
with lazy_reading(r): |
ffb393dd5999
perf: ensure all readlog's reading is done within a `reading` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51008
diff
changeset
|
3977 |
segmentforrevs(item[0], item[-1]) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3978 |
|
40531
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
3979 |
def doslice(r, chain, size): |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
3980 |
for s in slicechunk(r, chain, targetsize=size): |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
3981 |
pass |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
3982 |
|
30882
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3983 |
def dorawchunks(data, chain): |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3984 |
if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3985 |
r.clearcaches() |
30882
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3986 |
getrawchunks(data, chain) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3987 |
|
30882
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3988 |
def dodecompress(chunks): |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3989 |
decomp = r.decompress |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3990 |
for chunk in chunks: |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3991 |
decomp(chunk) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3992 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3993 |
def dopatch(text, bins): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3994 |
if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3995 |
r.clearcaches() |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3996 |
mdiff.patches(text, bins) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3997 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3998 |
def dohash(text): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3999 |
if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
4000 |
r.clearcaches() |
30584
be5b2098a817
revlog: merge hash checking subfunctions
Remi Chaintron <remi@fb.com>
parents:
30451
diff
changeset
|
4001 |
r.checkhash(text, node, rev=rev) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
4002 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
4003 |
def dorevision(): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
4004 |
if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
4005 |
r.clearcaches() |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
4006 |
r.revision(node) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
4007 |
|
40530
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
4008 |
try: |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
4009 |
from mercurial.revlogutils.deltas import slicechunk |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
4010 |
except ImportError: |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
4011 |
slicechunk = getattr(revlog, '_slicechunk', None) |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
4012 |
|
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
4013 |
size = r.length(rev) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
4014 |
chain = r._deltachain(rev)[0] |
51059
47d43efda8b7
revlog: remove legacy usage of `_withsparseread`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51009
diff
changeset
|
4015 |
|
47d43efda8b7
revlog: remove legacy usage of `_withsparseread`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51009
diff
changeset
|
4016 |
with_sparse_read = False |
47d43efda8b7
revlog: remove legacy usage of `_withsparseread`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51009
diff
changeset
|
4017 |
if hasattr(r, 'data_config'): |
47d43efda8b7
revlog: remove legacy usage of `_withsparseread`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51009
diff
changeset
|
4018 |
with_sparse_read = r.data_config.with_sparse_read |
47d43efda8b7
revlog: remove legacy usage of `_withsparseread`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51009
diff
changeset
|
4019 |
elif hasattr(r, '_withsparseread'): |
47d43efda8b7
revlog: remove legacy usage of `_withsparseread`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51009
diff
changeset
|
4020 |
with_sparse_read = r._withsparseread |
47d43efda8b7
revlog: remove legacy usage of `_withsparseread`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51009
diff
changeset
|
4021 |
if with_sparse_read: |
40530
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
4022 |
slicedchain = (chain,) |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
4023 |
else: |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
4024 |
slicedchain = tuple(slicechunk(r, chain, targetsize=size)) |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
4025 |
data = [segmentforrevs(seg[0], seg[-1])[1] for seg in slicedchain] |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
4026 |
rawchunks = getrawchunks(data, slicedchain) |
51094
e8ad6d8de8b8
revlog: move the `_chunks` method on the inner object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51092
diff
changeset
|
4027 |
bins = r._inner._chunks(chain) |
40214
b456b2e0ad9f
py3: make test-contrib-perf.t work on python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40145
diff
changeset
|
4028 |
text = bytes(bins[0]) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
4029 |
bins = bins[1:] |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
4030 |
text = mdiff.patches(text, bins) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
4031 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
4032 |
benches = [ |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
4033 |
(lambda: dorevision(), b'full'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
4034 |
(lambda: dodeltachain(rev), b'deltachain'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
4035 |
(lambda: doread(chain), b'read'), |
40531
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
4036 |
] |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
4037 |
|
51059
47d43efda8b7
revlog: remove legacy usage of `_withsparseread`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51009
diff
changeset
|
4038 |
if with_sparse_read: |
40531
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
4039 |
slicing = (lambda: doslice(r, chain, size), b'slice-sparse-chain') |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
4040 |
benches.append(slicing) |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
4041 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4042 |
benches.extend( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4043 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4044 |
(lambda: dorawchunks(data, slicedchain), b'rawchunks'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4045 |
(lambda: dodecompress(rawchunks), b'decompress'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4046 |
(lambda: dopatch(text, bins), b'patch'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4047 |
(lambda: dohash(text), b'hash'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4048 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4049 |
) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
4050 |
|
40529
cf3bef7f162b
perf: use the same timer for all section of perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40349
diff
changeset
|
4051 |
timer, fm = gettimer(ui, opts) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
4052 |
for fn, title in benches: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
4053 |
timer(fn, title=title) |
40529
cf3bef7f162b
perf: use the same timer for all section of perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40349
diff
changeset
|
4054 |
fm.end() |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
4055 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4056 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4057 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
4058 |
b'perf::revset|perfrevset', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4059 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4060 |
(b'C', b'clear', False, b'clear volatile cache between each call.'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4061 |
(b'', b'contexts', False, b'obtain changectx for each revision'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4062 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4063 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4064 |
b"REVSET", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4065 |
) |
27072
e18a9ceade3b
perf: support obtaining contexts from perfrevset
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27017
diff
changeset
|
4066 |
def perfrevset(ui, repo, expr, clear=False, contexts=False, **opts): |
18239
a95f1d619bb7
perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18238
diff
changeset
|
4067 |
"""benchmark the execution time of a revset |
a95f1d619bb7
perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18238
diff
changeset
|
4068 |
|
18644
3e92772d5383
spelling: fix some minor issues found by spell checker
Mads Kiilerich <mads@kiilerich.com>
parents:
18304
diff
changeset
|
4069 |
Use the --clean option if need to evaluate the impact of build volatile |
18239
a95f1d619bb7
perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18238
diff
changeset
|
4070 |
revisions set cache on the revset execution. Volatile cache hold filtered |
a95f1d619bb7
perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18238
diff
changeset
|
4071 |
and obsolete related cache.""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
4072 |
opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
4073 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
4074 |
timer, fm = gettimer(ui, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4075 |
|
18062
1471f5e83686
perf: add a command to measure revset performance
Siddharth Agarwal <sid0@fb.com>
parents:
18033
diff
changeset
|
4076 |
def d(): |
18239
a95f1d619bb7
perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18238
diff
changeset
|
4077 |
if clear: |
a95f1d619bb7
perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18238
diff
changeset
|
4078 |
repo.invalidatevolatilesets() |
27072
e18a9ceade3b
perf: support obtaining contexts from perfrevset
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27017
diff
changeset
|
4079 |
if contexts: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4080 |
for ctx in repo.set(expr): |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4081 |
pass |
27072
e18a9ceade3b
perf: support obtaining contexts from perfrevset
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27017
diff
changeset
|
4082 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4083 |
for r in repo.revs(expr): |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4084 |
pass |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4085 |
|
18062
1471f5e83686
perf: add a command to measure revset performance
Siddharth Agarwal <sid0@fb.com>
parents:
18033
diff
changeset
|
4086 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
4087 |
fm.end() |
18240
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
4088 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4089 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4090 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
4091 |
b'perf::volatilesets|perfvolatilesets', |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
4092 |
[ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
4093 |
(b'', b'clear-obsstore', False, b'drop obsstore between each call.'), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
4094 |
] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4095 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4096 |
) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
4097 |
def perfvolatilesets(ui, repo, *names, **opts): |
18240
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
4098 |
"""benchmark the computation of various volatile set |
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
4099 |
|
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
4100 |
Volatile set computes element related to filtering and obsolescence.""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
4101 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
4102 |
timer, fm = gettimer(ui, opts) |
18240
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
4103 |
repo = repo.unfiltered() |
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
4104 |
|
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
4105 |
def getobs(name): |
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
4106 |
def d(): |
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
4107 |
repo.invalidatevolatilesets() |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
4108 |
if opts[b'clear_obsstore']: |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
4109 |
clearfilecache(repo, b'obsstore') |
18240
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
4110 |
obsolete.getrevs(repo, name) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4111 |
|
18240
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
4112 |
return d |
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
4113 |
|
18241
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
4114 |
allobs = sorted(obsolete.cachefuncs) |
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
4115 |
if names: |
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
4116 |
allobs = [n for n in allobs if n in names] |
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
4117 |
|
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
4118 |
for name in allobs: |
18240
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
4119 |
timer(getobs(name), title=name) |
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
4120 |
|
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
4121 |
def getfiltered(name): |
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
4122 |
def d(): |
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
4123 |
repo.invalidatevolatilesets() |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
4124 |
if opts[b'clear_obsstore']: |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
4125 |
clearfilecache(repo, b'obsstore') |
20205
d67a7758da6d
perf: fix perfvolatilesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
20178
diff
changeset
|
4126 |
repoview.filterrevs(repo, name) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4127 |
|
18240
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
4128 |
return d |
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
4129 |
|
18241
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
4130 |
allfilter = sorted(repoview.filtertable) |
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
4131 |
if names: |
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
4132 |
allfilter = [n for n in allfilter if n in names] |
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
4133 |
|
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
4134 |
for name in allfilter: |
18240
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
4135 |
timer(getfiltered(name), title=name) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
4136 |
fm.end() |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4137 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4138 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4139 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
4140 |
b'perf::branchmap|perfbranchmap', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4141 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4142 |
(b'f', b'full', False, b'Includes build time of subset'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4143 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4144 |
b'', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4145 |
b'clear-revbranch', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4146 |
False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4147 |
b'purge the revbranch cache between computation', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4148 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4149 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4150 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4151 |
) |
36360
c25290b98190
perfbranchmap: allow to select the filter to benchmark
Boris Feld <boris.feld@octobus.net>
parents:
36359
diff
changeset
|
4152 |
def perfbranchmap(ui, repo, *filternames, **opts): |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4153 |
"""benchmark the update of a branchmap |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4154 |
|
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4155 |
This benchmarks the full repo.branchmap() call with read and write disabled |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4156 |
""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
4157 |
opts = _byteskwargs(opts) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
4158 |
full = opts.get(b"full", False) |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
4159 |
clear_revbranch = opts.get(b"clear_revbranch", False) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
4160 |
timer, fm = gettimer(ui, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4161 |
|
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4162 |
def getbranchmap(filtername): |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4163 |
"""generate a benchmark function for the filtername""" |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4164 |
if filtername is None: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4165 |
view = repo |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4166 |
else: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4167 |
view = repo.filtered(filtername) |
41615
328ca3b9e545
branchmap: encapsulate cache updating in the map itself
Martijn Pieters <mj@octobus.net>
parents:
41565
diff
changeset
|
4168 |
if util.safehasattr(view._branchcaches, '_per_filter'): |
328ca3b9e545
branchmap: encapsulate cache updating in the map itself
Martijn Pieters <mj@octobus.net>
parents:
41565
diff
changeset
|
4169 |
filtered = view._branchcaches._per_filter |
328ca3b9e545
branchmap: encapsulate cache updating in the map itself
Martijn Pieters <mj@octobus.net>
parents:
41565
diff
changeset
|
4170 |
else: |
328ca3b9e545
branchmap: encapsulate cache updating in the map itself
Martijn Pieters <mj@octobus.net>
parents:
41565
diff
changeset
|
4171 |
# older versions |
328ca3b9e545
branchmap: encapsulate cache updating in the map itself
Martijn Pieters <mj@octobus.net>
parents:
41565
diff
changeset
|
4172 |
filtered = view._branchcaches |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4173 |
|
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4174 |
def d(): |
32710
326c0e2c1a1d
perfbranchmap: add an option to purge the revbranch cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32532
diff
changeset
|
4175 |
if clear_revbranch: |
326c0e2c1a1d
perfbranchmap: add an option to purge the revbranch cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32532
diff
changeset
|
4176 |
repo.revbranchcache()._clear() |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4177 |
if full: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4178 |
view._branchcaches.clear() |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4179 |
else: |
41615
328ca3b9e545
branchmap: encapsulate cache updating in the map itself
Martijn Pieters <mj@octobus.net>
parents:
41565
diff
changeset
|
4180 |
filtered.pop(filtername, None) |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4181 |
view.branchmap() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4182 |
|
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4183 |
return d |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4184 |
|
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4185 |
# add filter in smaller subset to bigger subset |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4186 |
possiblefilters = set(repoview.filtertable) |
36360
c25290b98190
perfbranchmap: allow to select the filter to benchmark
Boris Feld <boris.feld@octobus.net>
parents:
36359
diff
changeset
|
4187 |
if filternames: |
c25290b98190
perfbranchmap: allow to select the filter to benchmark
Boris Feld <boris.feld@octobus.net>
parents:
36359
diff
changeset
|
4188 |
possiblefilters &= set(filternames) |
30144
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
4189 |
subsettable = getbranchmapsubsettable() |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4190 |
allfilters = [] |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4191 |
while possiblefilters: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4192 |
for name in possiblefilters: |
30144
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
4193 |
subset = subsettable.get(name) |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4194 |
if subset not in possiblefilters: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4195 |
break |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4196 |
else: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
4197 |
assert False, b'subset cycle %s!' % possiblefilters |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4198 |
allfilters.append(name) |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4199 |
possiblefilters.remove(name) |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4200 |
|
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4201 |
# warm the cache |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4202 |
if not full: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4203 |
for name in allfilters: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4204 |
repo.filtered(name).branchmap() |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
4205 |
if not filternames or b'unfiltered' in filternames: |
36360
c25290b98190
perfbranchmap: allow to select the filter to benchmark
Boris Feld <boris.feld@octobus.net>
parents:
36359
diff
changeset
|
4206 |
# add unfiltered |
c25290b98190
perfbranchmap: allow to select the filter to benchmark
Boris Feld <boris.feld@octobus.net>
parents:
36359
diff
changeset
|
4207 |
allfilters.append(None) |
30145
113aa6145020
perf: avoid actual writing branch cache out correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30144
diff
changeset
|
4208 |
|
51519
ec640dc9cebd
branchcache: use an explicit class for the v2 version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51493
diff
changeset
|
4209 |
old_branch_cache_from_file = None |
ec640dc9cebd
branchcache: use an explicit class for the v2 version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51493
diff
changeset
|
4210 |
branchcacheread = None |
ec640dc9cebd
branchcache: use an explicit class for the v2 version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51493
diff
changeset
|
4211 |
if util.safehasattr(branchmap, 'branch_cache_from_file'): |
ec640dc9cebd
branchcache: use an explicit class for the v2 version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51493
diff
changeset
|
4212 |
old_branch_cache_from_file = branchmap.branch_cache_from_file |
ec640dc9cebd
branchcache: use an explicit class for the v2 version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51493
diff
changeset
|
4213 |
branchmap.branch_cache_from_file = lambda *args: None |
ec640dc9cebd
branchcache: use an explicit class for the v2 version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51493
diff
changeset
|
4214 |
elif util.safehasattr(branchmap.branchcache, 'fromfile'): |
41565
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
4215 |
branchcacheread = safeattrsetter(branchmap.branchcache, b'fromfile') |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
4216 |
branchcacheread.set(classmethod(lambda *args: None)) |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
4217 |
else: |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
4218 |
# older versions |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
4219 |
branchcacheread = safeattrsetter(branchmap, b'read') |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
4220 |
branchcacheread.set(lambda *args: None) |
51519
ec640dc9cebd
branchcache: use an explicit class for the v2 version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51493
diff
changeset
|
4221 |
if util.safehasattr(branchmap, '_LocalBranchCache'): |
ec640dc9cebd
branchcache: use an explicit class for the v2 version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51493
diff
changeset
|
4222 |
branchcachewrite = safeattrsetter(branchmap._LocalBranchCache, b'write') |
ec640dc9cebd
branchcache: use an explicit class for the v2 version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51493
diff
changeset
|
4223 |
branchcachewrite.set(lambda *args: None) |
ec640dc9cebd
branchcache: use an explicit class for the v2 version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51493
diff
changeset
|
4224 |
else: |
ec640dc9cebd
branchcache: use an explicit class for the v2 version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51493
diff
changeset
|
4225 |
branchcachewrite = safeattrsetter(branchmap.branchcache, b'write') |
ec640dc9cebd
branchcache: use an explicit class for the v2 version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51493
diff
changeset
|
4226 |
branchcachewrite.set(lambda *args: None) |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4227 |
try: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4228 |
for name in allfilters: |
36359
df3f7f00a3fc
perfbranchmap: display 'unfiltered' for unfiltered performance
Boris Feld <boris.feld@octobus.net>
parents:
36178
diff
changeset
|
4229 |
printname = name |
df3f7f00a3fc
perfbranchmap: display 'unfiltered' for unfiltered performance
Boris Feld <boris.feld@octobus.net>
parents:
36178
diff
changeset
|
4230 |
if name is None: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
4231 |
printname = b'unfiltered' |
46255
cce05a6c271f
perf: don't turn byte to string when formatting perfbranchmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46196
diff
changeset
|
4232 |
timer(getbranchmap(name), title=printname) |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
4233 |
finally: |
51519
ec640dc9cebd
branchcache: use an explicit class for the v2 version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51493
diff
changeset
|
4234 |
if old_branch_cache_from_file is not None: |
ec640dc9cebd
branchcache: use an explicit class for the v2 version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51493
diff
changeset
|
4235 |
branchmap.branch_cache_from_file = old_branch_cache_from_file |
ec640dc9cebd
branchcache: use an explicit class for the v2 version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51493
diff
changeset
|
4236 |
if branchcacheread is not None: |
ec640dc9cebd
branchcache: use an explicit class for the v2 version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51493
diff
changeset
|
4237 |
branchcacheread.restore() |
30145
113aa6145020
perf: avoid actual writing branch cache out correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30144
diff
changeset
|
4238 |
branchcachewrite.restore() |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
4239 |
fm.end() |
23485
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
4240 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4241 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4242 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
4243 |
b'perf::branchmapupdate|perfbranchmapupdate', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4244 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4245 |
(b'', b'base', [], b'subset of revision to start from'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4246 |
(b'', b'target', [], b'subset of revision to end with'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4247 |
(b'', b'clear-caches', False, b'clear cache between each runs'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4248 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4249 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4250 |
) |
40768
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4251 |
def perfbranchmapupdate(ui, repo, base=(), target=(), **opts): |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4252 |
"""benchmark branchmap update from for <base> revs to <target> revs |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4253 |
|
40772
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40771
diff
changeset
|
4254 |
If `--clear-caches` is passed, the following items will be reset before |
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40771
diff
changeset
|
4255 |
each update: |
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40771
diff
changeset
|
4256 |
* the changelog instance and associated indexes |
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40771
diff
changeset
|
4257 |
* the rev-branch-cache instance |
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40771
diff
changeset
|
4258 |
|
40768
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4259 |
Examples: |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4260 |
|
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4261 |
# update for the one last revision |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4262 |
$ hg perfbranchmapupdate --base 'not tip' --target 'tip' |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4263 |
|
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4264 |
$ update for change coming with a new branch |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4265 |
$ hg perfbranchmapupdate --base 'stable' --target 'default' |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4266 |
""" |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4267 |
from mercurial import branchmap |
40770
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4268 |
from mercurial import repoview |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4269 |
|
40768
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4270 |
opts = _byteskwargs(opts) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4271 |
timer, fm = gettimer(ui, opts) |
40772
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40771
diff
changeset
|
4272 |
clearcaches = opts[b'clear_caches'] |
40770
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4273 |
unfi = repo.unfiltered() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4274 |
x = [None] # used to pass data between closure |
40768
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4275 |
|
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4276 |
# we use a `list` here to avoid possible side effect from smartset |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4277 |
baserevs = list(scmutil.revrange(repo, base)) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4278 |
targetrevs = list(scmutil.revrange(repo, target)) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4279 |
if not baserevs: |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4280 |
raise error.Abort(b'no revisions selected for --base') |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4281 |
if not targetrevs: |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4282 |
raise error.Abort(b'no revisions selected for --target') |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4283 |
|
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4284 |
# make sure the target branchmap also contains the one in the base |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4285 |
targetrevs = list(set(baserevs) | set(targetrevs)) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4286 |
targetrevs.sort() |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4287 |
|
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4288 |
cl = repo.changelog |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4289 |
allbaserevs = list(cl.ancestors(baserevs, inclusive=True)) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4290 |
allbaserevs.sort() |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4291 |
alltargetrevs = frozenset(cl.ancestors(targetrevs, inclusive=True)) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4292 |
|
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4293 |
newrevs = list(alltargetrevs.difference(allbaserevs)) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4294 |
newrevs.sort() |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4295 |
|
40770
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4296 |
allrevs = frozenset(unfi.changelog.revs()) |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4297 |
basefilterrevs = frozenset(allrevs.difference(allbaserevs)) |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4298 |
targetfilterrevs = frozenset(allrevs.difference(alltargetrevs)) |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4299 |
|
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4300 |
def basefilter(repo, visibilityexceptions=None): |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4301 |
return basefilterrevs |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4302 |
|
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4303 |
def targetfilter(repo, visibilityexceptions=None): |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4304 |
return targetfilterrevs |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4305 |
|
40768
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4306 |
msg = b'benchmark of branchmap with %d revisions with %d new ones\n' |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4307 |
ui.status(msg % (len(allbaserevs), len(newrevs))) |
40770
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4308 |
if targetfilterrevs: |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4309 |
msg = b'(%d revisions still filtered)\n' |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4310 |
ui.status(msg % len(targetfilterrevs)) |
40768
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4311 |
|
40770
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4312 |
try: |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4313 |
repoview.filtertable[b'__perf_branchmap_update_base'] = basefilter |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4314 |
repoview.filtertable[b'__perf_branchmap_update_target'] = targetfilter |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4315 |
|
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4316 |
baserepo = repo.filtered(b'__perf_branchmap_update_base') |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4317 |
targetrepo = repo.filtered(b'__perf_branchmap_update_target') |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4318 |
|
51493
82c1a388e86a
branchcache: explicitly track inheritence "state"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51450
diff
changeset
|
4319 |
bcache = repo.branchmap() |
82c1a388e86a
branchcache: explicitly track inheritence "state"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51450
diff
changeset
|
4320 |
copy_method = 'copy' |
82c1a388e86a
branchcache: explicitly track inheritence "state"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51450
diff
changeset
|
4321 |
|
51450
3aba79ce52a9
branchcache: pass the target repository when copying
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51437
diff
changeset
|
4322 |
copy_base_kwargs = copy_base_kwargs = {} |
51493
82c1a388e86a
branchcache: explicitly track inheritence "state"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51450
diff
changeset
|
4323 |
if hasattr(bcache, 'copy'): |
82c1a388e86a
branchcache: explicitly track inheritence "state"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51450
diff
changeset
|
4324 |
if 'repo' in getargspec(bcache.copy).args: |
82c1a388e86a
branchcache: explicitly track inheritence "state"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51450
diff
changeset
|
4325 |
copy_base_kwargs = {"repo": baserepo} |
82c1a388e86a
branchcache: explicitly track inheritence "state"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51450
diff
changeset
|
4326 |
copy_target_kwargs = {"repo": targetrepo} |
82c1a388e86a
branchcache: explicitly track inheritence "state"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51450
diff
changeset
|
4327 |
else: |
82c1a388e86a
branchcache: explicitly track inheritence "state"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51450
diff
changeset
|
4328 |
copy_method = 'inherit_for' |
51450
3aba79ce52a9
branchcache: pass the target repository when copying
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51437
diff
changeset
|
4329 |
copy_base_kwargs = {"repo": baserepo} |
3aba79ce52a9
branchcache: pass the target repository when copying
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51437
diff
changeset
|
4330 |
copy_target_kwargs = {"repo": targetrepo} |
3aba79ce52a9
branchcache: pass the target repository when copying
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51437
diff
changeset
|
4331 |
|
40771
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
4332 |
# try to find an existing branchmap to reuse |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
4333 |
subsettable = getbranchmapsubsettable() |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
4334 |
candidatefilter = subsettable.get(None) |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
4335 |
while candidatefilter is not None: |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
4336 |
candidatebm = repo.filtered(candidatefilter).branchmap() |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
4337 |
if candidatebm.validfor(baserepo): |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
4338 |
filtered = repoview.filterrevs(repo, candidatefilter) |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
4339 |
missing = [r for r in allbaserevs if r in filtered] |
51493
82c1a388e86a
branchcache: explicitly track inheritence "state"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51450
diff
changeset
|
4340 |
base = getattr(candidatebm, copy_method)(**copy_base_kwargs) |
40771
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
4341 |
base.update(baserepo, missing) |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
4342 |
break |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
4343 |
candidatefilter = subsettable.get(candidatefilter) |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
4344 |
else: |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
4345 |
# no suitable subset where found |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
4346 |
base = branchmap.branchcache() |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
4347 |
base.update(baserepo, allbaserevs) |
40768
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4348 |
|
40769
95f35c873463
perf: pre-indent some code in `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40768
diff
changeset
|
4349 |
def setup(): |
51493
82c1a388e86a
branchcache: explicitly track inheritence "state"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51450
diff
changeset
|
4350 |
x[0] = getattr(base, copy_method)(**copy_target_kwargs) |
40772
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40771
diff
changeset
|
4351 |
if clearcaches: |
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40771
diff
changeset
|
4352 |
unfi._revbranchcache = None |
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40771
diff
changeset
|
4353 |
clearchangelog(repo) |
40768
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4354 |
|
40769
95f35c873463
perf: pre-indent some code in `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40768
diff
changeset
|
4355 |
def bench(): |
40770
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4356 |
x[0].update(targetrepo, newrevs) |
40769
95f35c873463
perf: pre-indent some code in `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40768
diff
changeset
|
4357 |
|
95f35c873463
perf: pre-indent some code in `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40768
diff
changeset
|
4358 |
timer(bench, setup=setup) |
95f35c873463
perf: pre-indent some code in `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40768
diff
changeset
|
4359 |
fm.end() |
40770
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4360 |
finally: |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4361 |
repoview.filtertable.pop(b'__perf_branchmap_update_base', None) |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
4362 |
repoview.filtertable.pop(b'__perf_branchmap_update_target', None) |
40768
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
4363 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4364 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4365 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
4366 |
b'perf::branchmapload|perfbranchmapload', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4367 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4368 |
(b'f', b'filter', b'', b'Specify repoview filter'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4369 |
(b'', b'list', False, b'List brachmap filter caches'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4370 |
(b'', b'clear-revlogs', False, b'refresh changelog and manifest'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4371 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4372 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4373 |
) |
40699
94d76ddac40a
perf: update function name to match `perfbranchmapload` command
Boris Feld <boris.feld@octobus.net>
parents:
40698
diff
changeset
|
4374 |
def perfbranchmapload(ui, repo, filter=b'', list=False, **opts): |
39114
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
38977
diff
changeset
|
4375 |
"""benchmark reading the branchmap""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
4376 |
opts = _byteskwargs(opts) |
40702
4240a1da4188
perf: add --clear-revlog flag to branchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40701
diff
changeset
|
4377 |
clearrevlogs = opts[b'clear_revlogs'] |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
4378 |
|
39114
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
38977
diff
changeset
|
4379 |
if list: |
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
38977
diff
changeset
|
4380 |
for name, kind, st in repo.cachevfs.readdir(stat=True): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
4381 |
if name.startswith(b'branch2'): |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
4382 |
filtername = name.partition(b'-')[2] or b'unfiltered' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4383 |
ui.status( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4384 |
b'%s - %s\n' % (filtername, util.bytecount(st.st_size)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4385 |
) |
39114
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
38977
diff
changeset
|
4386 |
return |
40720
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
4387 |
if not filter: |
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
4388 |
filter = None |
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
4389 |
subsettable = getbranchmapsubsettable() |
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
4390 |
if filter is None: |
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
4391 |
repo = repo.unfiltered() |
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
4392 |
else: |
39114
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
38977
diff
changeset
|
4393 |
repo = repoview.repoview(repo, filter) |
40719
578646b1e2b6
perf: prewarm the branchmap in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40713
diff
changeset
|
4394 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4395 |
repo.branchmap() # make sure we have a relevant, up to date branchmap |
40719
578646b1e2b6
perf: prewarm the branchmap in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40713
diff
changeset
|
4396 |
|
51519
ec640dc9cebd
branchcache: use an explicit class for the v2 version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51493
diff
changeset
|
4397 |
fromfile = getattr(branchmap, 'branch_cache_from_file', None) |
ec640dc9cebd
branchcache: use an explicit class for the v2 version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51493
diff
changeset
|
4398 |
if fromfile is None: |
ec640dc9cebd
branchcache: use an explicit class for the v2 version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51493
diff
changeset
|
4399 |
fromfile = getattr(branchmap.branchcache, 'fromfile', None) |
ec640dc9cebd
branchcache: use an explicit class for the v2 version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51493
diff
changeset
|
4400 |
if fromfile is None: |
41565
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
4401 |
fromfile = branchmap.read |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
4402 |
|
40720
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
4403 |
currentfilter = filter |
39114
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
38977
diff
changeset
|
4404 |
# try once without timer, the filter may not be cached |
41565
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
4405 |
while fromfile(repo) is None: |
40720
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
4406 |
currentfilter = subsettable.get(currentfilter) |
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
4407 |
if currentfilter is None: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4408 |
raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4409 |
b'No branchmap cached for %s repo' % (filter or b'unfiltered') |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4410 |
) |
40720
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
4411 |
repo = repo.filtered(currentfilter) |
39114
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
38977
diff
changeset
|
4412 |
timer, fm = gettimer(ui, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4413 |
|
40702
4240a1da4188
perf: add --clear-revlog flag to branchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40701
diff
changeset
|
4414 |
def setup(): |
4240a1da4188
perf: add --clear-revlog flag to branchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40701
diff
changeset
|
4415 |
if clearrevlogs: |
4240a1da4188
perf: add --clear-revlog flag to branchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40701
diff
changeset
|
4416 |
clearchangelog(repo) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4417 |
|
40700
30f443d34a7d
perf: use an explicit function in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40699
diff
changeset
|
4418 |
def bench(): |
41565
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
4419 |
fromfile(repo) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4420 |
|
40702
4240a1da4188
perf: add --clear-revlog flag to branchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40701
diff
changeset
|
4421 |
timer(bench, setup=setup) |
39114
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
38977
diff
changeset
|
4422 |
fm.end() |
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
38977
diff
changeset
|
4423 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4424 |
|
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
4425 |
@command(b'perf::loadmarkers|perfloadmarkers') |
23485
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
4426 |
def perfloadmarkers(ui, repo): |
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
4427 |
"""benchmark the time to parse the on-disk markers for a repo |
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
4428 |
|
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
4429 |
Result is the number of markers in the repo.""" |
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
4430 |
timer, fm = gettimer(ui) |
30146
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
4431 |
svfs = getsvfs(repo) |
46780
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46720
diff
changeset
|
4432 |
timer(lambda: len(obsolete.obsstore(repo, svfs))) |
23485
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
4433 |
fm.end() |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4434 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4435 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4436 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
4437 |
b'perf::lrucachedict|perflrucachedict', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4438 |
formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4439 |
+ [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4440 |
(b'', b'costlimit', 0, b'maximum total cost of items in cache'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4441 |
(b'', b'mincost', 0, b'smallest cost of items in cache'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4442 |
(b'', b'maxcost', 100, b'maximum cost of items in cache'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4443 |
(b'', b'size', 4, b'size of cache'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4444 |
(b'', b'gets', 10000, b'number of key lookups'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4445 |
(b'', b'sets', 10000, b'number of key sets'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4446 |
(b'', b'mixed', 10000, b'number of mixed mode operations'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4447 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4448 |
b'', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4449 |
b'mixedgetfreq', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4450 |
50, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4451 |
b'frequency of get vs set ops in mixed mode', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4452 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4453 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4454 |
norepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4455 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4456 |
def perflrucache( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4457 |
ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4458 |
mincost=0, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4459 |
maxcost=100, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4460 |
costlimit=0, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4461 |
size=4, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4462 |
gets=10000, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4463 |
sets=10000, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4464 |
mixed=10000, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4465 |
mixedgetfreq=50, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4466 |
**opts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4467 |
): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
4468 |
opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
4469 |
|
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4470 |
def doinit(): |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
4471 |
for i in _xrange(10000): |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4472 |
util.lrucachedict(size) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4473 |
|
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4474 |
costrange = list(range(mincost, maxcost + 1)) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4475 |
|
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4476 |
values = [] |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
4477 |
for i in _xrange(size): |
39823
c4ab9fa81377
py3: work around the lack of sys.maxint in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39822
diff
changeset
|
4478 |
values.append(random.randint(0, _maxint)) |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4479 |
|
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4480 |
# Get mode fills the cache and tests raw lookup performance with no |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4481 |
# eviction. |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4482 |
getseq = [] |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
4483 |
for i in _xrange(gets): |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4484 |
getseq.append(random.choice(values)) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4485 |
|
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4486 |
def dogets(): |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4487 |
d = util.lrucachedict(size) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4488 |
for v in values: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4489 |
d[v] = v |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4490 |
for key in getseq: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4491 |
value = d[key] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4492 |
value # silence pyflakes warning |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4493 |
|
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4494 |
def dogetscost(): |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4495 |
d = util.lrucachedict(size, maxcost=costlimit) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4496 |
for i, v in enumerate(values): |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4497 |
d.insert(v, v, cost=costs[i]) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4498 |
for key in getseq: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4499 |
try: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4500 |
value = d[key] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4501 |
value # silence pyflakes warning |
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4502 |
except KeyError: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4503 |
pass |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4504 |
|
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4505 |
# Set mode tests insertion speed with cache eviction. |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4506 |
setseq = [] |
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4507 |
costs = [] |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
4508 |
for i in _xrange(sets): |
39823
c4ab9fa81377
py3: work around the lack of sys.maxint in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39822
diff
changeset
|
4509 |
setseq.append(random.randint(0, _maxint)) |
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4510 |
costs.append(random.choice(costrange)) |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4511 |
|
39567
ee087f0d7db5
util: allow lrucachedict to track cost of entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39362
diff
changeset
|
4512 |
def doinserts(): |
ee087f0d7db5
util: allow lrucachedict to track cost of entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39362
diff
changeset
|
4513 |
d = util.lrucachedict(size) |
ee087f0d7db5
util: allow lrucachedict to track cost of entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39362
diff
changeset
|
4514 |
for v in setseq: |
ee087f0d7db5
util: allow lrucachedict to track cost of entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39362
diff
changeset
|
4515 |
d.insert(v, v) |
ee087f0d7db5
util: allow lrucachedict to track cost of entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39362
diff
changeset
|
4516 |
|
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4517 |
def doinsertscost(): |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4518 |
d = util.lrucachedict(size, maxcost=costlimit) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4519 |
for i, v in enumerate(setseq): |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4520 |
d.insert(v, v, cost=costs[i]) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4521 |
|
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4522 |
def dosets(): |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4523 |
d = util.lrucachedict(size) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4524 |
for v in setseq: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4525 |
d[v] = v |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4526 |
|
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4527 |
# Mixed mode randomly performs gets and sets with eviction. |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4528 |
mixedops = [] |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
4529 |
for i in _xrange(mixed): |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4530 |
r = random.randint(0, 100) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4531 |
if r < mixedgetfreq: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4532 |
op = 0 |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4533 |
else: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4534 |
op = 1 |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4535 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4536 |
mixedops.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4537 |
(op, random.randint(0, size * 2), random.choice(costrange)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4538 |
) |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4539 |
|
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4540 |
def domixed(): |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4541 |
d = util.lrucachedict(size) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4542 |
|
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4543 |
for op, v, cost in mixedops: |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4544 |
if op == 0: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4545 |
try: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4546 |
d[v] |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4547 |
except KeyError: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4548 |
pass |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4549 |
else: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4550 |
d[v] = v |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4551 |
|
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4552 |
def domixedcost(): |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4553 |
d = util.lrucachedict(size, maxcost=costlimit) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4554 |
|
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4555 |
for op, v, cost in mixedops: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4556 |
if op == 0: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4557 |
try: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4558 |
d[v] |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4559 |
except KeyError: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4560 |
pass |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4561 |
else: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4562 |
d.insert(v, v, cost=cost) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4563 |
|
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4564 |
benches = [ |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
4565 |
(doinit, b'init'), |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4566 |
] |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4567 |
|
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4568 |
if costlimit: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4569 |
benches.extend( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4570 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4571 |
(dogetscost, b'gets w/ cost limit'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4572 |
(doinsertscost, b'inserts w/ cost limit'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4573 |
(domixedcost, b'mixed w/ cost limit'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4574 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4575 |
) |
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4576 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4577 |
benches.extend( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4578 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4579 |
(dogets, b'gets'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4580 |
(doinserts, b'inserts'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4581 |
(dosets, b'sets'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4582 |
(domixed, b'mixed'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4583 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4584 |
) |
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
4585 |
|
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4586 |
for fn, title in benches: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4587 |
timer, fm = gettimer(ui, opts) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4588 |
timer(fn, title=title) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
4589 |
fm.end() |
29495
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
4590 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4591 |
|
44996
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4592 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
4593 |
b'perf::write|perfwrite', |
44996
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4594 |
formatteropts |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4595 |
+ [ |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4596 |
(b'', b'write-method', b'write', b'ui write method'), |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4597 |
(b'', b'nlines', 100, b'number of lines'), |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4598 |
(b'', b'nitems', 100, b'number of items (per line)'), |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4599 |
(b'', b'item', b'x', b'item that is written'), |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4600 |
(b'', b'batch-line', None, b'pass whole line to write method at once'), |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4601 |
(b'', b'flush-line', None, b'flush after each line'), |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4602 |
], |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4603 |
) |
30977
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
4604 |
def perfwrite(ui, repo, **opts): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45632
diff
changeset
|
4605 |
"""microbenchmark ui.write (and others)""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
4606 |
opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
4607 |
|
44996
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4608 |
write = getattr(ui, _sysstr(opts[b'write_method'])) |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4609 |
nlines = int(opts[b'nlines']) |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4610 |
nitems = int(opts[b'nitems']) |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4611 |
item = opts[b'item'] |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4612 |
batch_line = opts.get(b'batch_line') |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4613 |
flush_line = opts.get(b'flush_line') |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4614 |
|
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4615 |
if batch_line: |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4616 |
line = item * nitems + b'\n' |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4617 |
|
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4618 |
def benchmark(): |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4619 |
for i in pycompat.xrange(nlines): |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4620 |
if batch_line: |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4621 |
write(line) |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4622 |
else: |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4623 |
for i in pycompat.xrange(nitems): |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4624 |
write(item) |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4625 |
write(b'\n') |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4626 |
if flush_line: |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4627 |
ui.flush() |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4628 |
ui.flush() |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4629 |
|
30977
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
4630 |
timer, fm = gettimer(ui, opts) |
44996
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44452
diff
changeset
|
4631 |
timer(benchmark) |
30977
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
4632 |
fm.end() |
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
4633 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4634 |
|
29495
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
4635 |
def uisetup(ui): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4636 |
if util.safehasattr(cmdutil, b'openrevlog') and not util.safehasattr( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4637 |
commands, b'debugrevlogopts' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4638 |
): |
29495
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
4639 |
# for "historical portability": |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
4640 |
# In this case, Mercurial should be 1.9 (or a79fea6b3e77) - |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
4641 |
# 3.7 (or 5606f7d0d063). Therefore, '--dir' option for |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
4642 |
# openrevlog() should cause failure, because it has been |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
4643 |
# available since 3.5 (or 49c583ca48c4). |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
4644 |
def openrevlog(orig, repo, cmd, file_, opts): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
4645 |
if opts.get(b'dir') and not util.safehasattr(repo, b'dirlog'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4646 |
raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4647 |
b"This version doesn't support --dir option", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4648 |
hint=b"use 3.5 or later", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4649 |
) |
29495
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
4650 |
return orig(repo, cmd, file_, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4651 |
|
50795
193a6e9a56f3
wrapfunction: use sysstr instead of bytes as argument in "perf"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50705
diff
changeset
|
4652 |
name = _sysstr(b'openrevlog') |
193a6e9a56f3
wrapfunction: use sysstr instead of bytes as argument in "perf"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50705
diff
changeset
|
4653 |
extensions.wrapfunction(cmdutil, name, openrevlog) |
40925
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
4654 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4655 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4656 |
@command( |
46388
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46354
diff
changeset
|
4657 |
b'perf::progress|perfprogress', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4658 |
formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4659 |
+ [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4660 |
(b'', b'topic', b'topic', b'topic for progress messages'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4661 |
(b'c', b'total', 1000000, b'total value we are progressing to'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4662 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4663 |
norepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43003
diff
changeset
|
4664 |
) |
40925
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
4665 |
def perfprogress(ui, topic=None, total=None, **opts): |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
4666 |
"""printing of progress bars""" |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
4667 |
opts = _byteskwargs(opts) |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
4668 |
|
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
4669 |
timer, fm = gettimer(ui, opts) |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
4670 |
|
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
4671 |
def doprogress(): |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
4672 |
with ui.makeprogress(topic, total=total) as progress: |
42785
c00005975c91
perf: don't depend on pycompat for older Mercurial versions
Martin von Zweigbergk <martinvonz@google.com>
parents:
42784
diff
changeset
|
4673 |
for i in _xrange(total): |
40925
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
4674 |
progress.increment() |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
4675 |
|
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
4676 |
timer(doprogress) |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
4677 |
fm.end() |