Mercurial > hg
annotate tests/test-contrib-dumprevlog.t @ 50400:95acba2c29f6
encoding: avoid quadratic time complexity when json-encoding non-UTF8 strings
Apparently the code uses "+=" with a bytes object, which is linear-time, so the
whole encoding is quadratic-time. This patch makes us use a bytearray object,
instead, which has a(n amortized-)constant-time append operation.
The encoding is still not particularly fast, but at least a 10MB file
takes tens of seconds, not many hours to encode.
author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
---|---|
date | Mon, 06 Mar 2023 11:27:57 +0000 |
parents | 2f2682f40ea0 |
children |
rev | line source |
---|---|
37407
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 #require reporevlogstore |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 $ CONTRIBDIR="$TESTDIR/../contrib" |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 $ hg init repo-a |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 $ cd repo-a |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 $ echo this is file a > a |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 $ hg add a |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
10 $ hg commit -m first |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
11 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
12 $ echo adding to file a >> a |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
13 $ hg commit -m second |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
14 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
15 $ echo adding more to file a >> a |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
16 $ hg commit -m third |
49825
2f2682f40ea0
tests: use the `--quiet` flag for verify when applicable
Raphaël Gomès <rgomes@octobus.net>
parents:
39707
diff
changeset
|
17 $ hg verify -q |
37407
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
18 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
19 Dumping revlog of file a to stdout: |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
39489
diff
changeset
|
20 $ "$PYTHON" "$CONTRIBDIR/dumprevlog" .hg/store/data/a.i |
37407
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
21 file: .hg/store/data/a.i |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
22 node: 183d2312b35066fb6b3b449b84efc370d50993d0 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
23 linkrev: 0 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
24 parents: 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
25 length: 15 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
26 -start- |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
27 this is file a |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
28 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
29 -end- |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
30 node: b1047953b6e6b633c0d8197eaa5116fbdfd3095b |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
31 linkrev: 1 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
32 parents: 183d2312b35066fb6b3b449b84efc370d50993d0 0000000000000000000000000000000000000000 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
33 length: 32 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
34 -start- |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
35 this is file a |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
36 adding to file a |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
37 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
38 -end- |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
39 node: 8c4fd1f7129b8cdec6c7f58bf48fb5237a4030c1 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
40 linkrev: 2 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
41 parents: b1047953b6e6b633c0d8197eaa5116fbdfd3095b 0000000000000000000000000000000000000000 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
42 length: 54 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
43 -start- |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
44 this is file a |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
45 adding to file a |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
46 adding more to file a |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
47 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
48 -end- |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
49 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
50 Dump all revlogs to file repo.dump: |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
51 |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
39489
diff
changeset
|
52 $ find .hg/store -name "*.i" | sort | xargs "$PYTHON" "$CONTRIBDIR/dumprevlog" > ../repo.dump |
37407
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
53 $ cd .. |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
54 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
55 Undumping into repo-b: |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
56 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
57 $ hg init repo-b |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
58 $ cd repo-b |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
39489
diff
changeset
|
59 $ "$PYTHON" "$CONTRIBDIR/undumprevlog" < ../repo.dump |
37407
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
60 .hg/store/00changelog.i |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
61 .hg/store/00manifest.i |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
62 .hg/store/data/a.i |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
63 $ cd .. |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
64 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
65 Rebuild fncache with clone --pull: |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
66 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
67 $ hg clone --pull -U repo-b repo-c |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
68 requesting all changes |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
69 adding changesets |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
70 adding manifests |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
71 adding file changes |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
72 added 3 changesets with 3 changes to 1 files |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
73 new changesets de1da620e7d8:46946d278c50 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
74 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
75 Verify: |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
76 |
49825
2f2682f40ea0
tests: use the `--quiet` flag for verify when applicable
Raphaël Gomès <rgomes@octobus.net>
parents:
39707
diff
changeset
|
77 $ hg -R repo-c verify -q |
37407
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
78 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
79 Compare repos: |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
80 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
81 $ hg -R repo-c incoming repo-a |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
82 comparing with repo-a |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
83 searching for changes |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
84 no changes found |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
85 [1] |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
86 |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
87 $ hg -R repo-a incoming repo-c |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
88 comparing with repo-c |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
89 searching for changes |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
90 no changes found |
567bddcb4271
tests: extract dumprevlog tests to own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
91 [1] |