Mercurial > hg
annotate tests/test-dispatch.py @ 38661:8ac0c9cd4c48
fncache: avoid loading the filename cache when not actually modifying it
With time, fncache can become very large. The mozilla-central repo for example,
has a 31M and growing fncache file. Loading this file takes time (280ms for the
mozilla-central repository).
In many scenarios, we don't need to load fncache at all. For example, when
committing changes to existing files, or pushing such commits to another clone.
This patch detects when a name is added via store.vfs(), and only loads the
cache if a) the data metadata file doesn't already exist, or b) when opening
for appending, the data or metadata file exists but has size (a transaction
rollback leaves behind such files).
Benchmarks (run on Macos 10.13 on a 2017-model Macbook Pro with Core i7 2.9GHz
and flash drive), each test without and with patch run 5 times:
* committing to an existing file, against the mozilla-central repository.
Baseline real time average 2.3736, with patch 1.9884.
* unbundling a large changeset consisting *only* of existing-file modifications
(159 revisions, 1050 modifications, mozilla-central
4a250a0e4f29:beea9ac7d823), into a clone limited to the ancestor revision of
that revset). Baseline real time average 1.5048, with patch 1.3108.
author | Martijn Pieters <mj@zopatista.com> |
---|---|
date | Wed, 11 Jul 2018 14:28:13 +0100 |
parents | 32106c474086 |
children | 2372284d9457 |
rev | line source |
---|---|
28405
1d9d29d4813a
tests: test-dispatch use print_function
timeless <timeless@mozdev.org>
parents:
28404
diff
changeset
|
1 from __future__ import absolute_import, print_function |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
2 import os |
37924
32106c474086
tests: port test-dispatch.py to Python 3
Augie Fackler <augie@google.com>
parents:
36374
diff
changeset
|
3 import sys |
28404
06245740b408
tests: test-dispatch use absolute_import
timeless <timeless@mozdev.org>
parents:
14438
diff
changeset
|
4 from mercurial import ( |
06245740b408
tests: test-dispatch use absolute_import
timeless <timeless@mozdev.org>
parents:
14438
diff
changeset
|
5 dispatch, |
06245740b408
tests: test-dispatch use absolute_import
timeless <timeless@mozdev.org>
parents:
14438
diff
changeset
|
6 ) |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
7 |
37924
32106c474086
tests: port test-dispatch.py to Python 3
Augie Fackler <augie@google.com>
parents:
36374
diff
changeset
|
8 def printb(data, end=b'\n'): |
32106c474086
tests: port test-dispatch.py to Python 3
Augie Fackler <augie@google.com>
parents:
36374
diff
changeset
|
9 out = getattr(sys.stdout, 'buffer', sys.stdout) |
32106c474086
tests: port test-dispatch.py to Python 3
Augie Fackler <augie@google.com>
parents:
36374
diff
changeset
|
10 out.write(data + end) |
32106c474086
tests: port test-dispatch.py to Python 3
Augie Fackler <augie@google.com>
parents:
36374
diff
changeset
|
11 out.flush() |
32106c474086
tests: port test-dispatch.py to Python 3
Augie Fackler <augie@google.com>
parents:
36374
diff
changeset
|
12 |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5095
diff
changeset
|
13 def testdispatch(cmd): |
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5095
diff
changeset
|
14 """Simple wrapper around dispatch.dispatch() |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
15 |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
16 Prints command and result value, but does not handle quoting. |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
17 """ |
37924
32106c474086
tests: port test-dispatch.py to Python 3
Augie Fackler <augie@google.com>
parents:
36374
diff
changeset
|
18 printb(b"running: %s" % (cmd,)) |
14438
08bfec2ef031
dispatch: wrap dispatch related information in a request class
Idan Kamara <idankk86@gmail.com>
parents:
9031
diff
changeset
|
19 req = dispatch.request(cmd.split()) |
08bfec2ef031
dispatch: wrap dispatch related information in a request class
Idan Kamara <idankk86@gmail.com>
parents:
9031
diff
changeset
|
20 result = dispatch.dispatch(req) |
37924
32106c474086
tests: port test-dispatch.py to Python 3
Augie Fackler <augie@google.com>
parents:
36374
diff
changeset
|
21 printb(b"result: %r" % (result,)) |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
22 |
36374
f0c94af0d70d
py3: add b'' prefixes in test-dispatch.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28405
diff
changeset
|
23 testdispatch(b"init test1") |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
24 os.chdir('test1') |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
25 |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
26 # create file 'foo', add and commit |
9031
3b76321aa0de
compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents:
5178
diff
changeset
|
27 f = open('foo', 'wb') |
36374
f0c94af0d70d
py3: add b'' prefixes in test-dispatch.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28405
diff
changeset
|
28 f.write(b'foo\n') |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
29 f.close() |
36374
f0c94af0d70d
py3: add b'' prefixes in test-dispatch.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28405
diff
changeset
|
30 testdispatch(b"add foo") |
f0c94af0d70d
py3: add b'' prefixes in test-dispatch.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28405
diff
changeset
|
31 testdispatch(b"commit -m commit1 -d 2000-01-01 foo") |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
32 |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
33 # append to file 'foo' and commit |
9031
3b76321aa0de
compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents:
5178
diff
changeset
|
34 f = open('foo', 'ab') |
36374
f0c94af0d70d
py3: add b'' prefixes in test-dispatch.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28405
diff
changeset
|
35 f.write(b'bar\n') |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
36 f.close() |
36374
f0c94af0d70d
py3: add b'' prefixes in test-dispatch.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28405
diff
changeset
|
37 testdispatch(b"commit -m commit2 -d 2000-01-02 foo") |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
38 |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
39 # check 88803a69b24 (fancyopts modified command table) |
36374
f0c94af0d70d
py3: add b'' prefixes in test-dispatch.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28405
diff
changeset
|
40 testdispatch(b"log -r 0") |
f0c94af0d70d
py3: add b'' prefixes in test-dispatch.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28405
diff
changeset
|
41 testdispatch(b"log -r tip") |