Mercurial > hg
view tests/test-journal.t @ 44363:f7459da77f23
nodemap: introduce an option to use mmap to read the nodemap mapping
The performance and memory benefit is much greater if we don't have to copy all
the data in memory for each information. So we introduce an option (on by
default) to read the data using mmap.
This changeset is the last one definition the API for index support nodemap
data. (they have to be able to use the mmaping).
Below are some benchmark comparing the best we currently have in 5.3 with the
final step of this series (using the persistent nodemap implementation in
Rust). The benchmark run `hg perfindex` with various revset and the following
variants:
Before:
* do not use the persistent nodemap
* use the CPython implementation of the index for nodemap
* use mmapping of the changelog index
After:
* use the MixedIndex Rust code, with the NodeTree object for nodemap access
(still in review)
* use the persistent nodemap data from disk
* access the persistent nodemap data through mmap
* use mmapping of the changelog index
The persistent nodemap greatly speed up most operation on very large
repositories. Some of the previously very fast lookup end up a bit slower because
the persistent nodemap has to be setup. However the absolute slowdown is very
small and won't matters in the big picture.
Here are some numbers (in seconds) for the reference copy of mozilla-try:
Revset Before After abs-change speedup
-10000: 0.004622 0.005532 0.000910 × 0.83
-10: 0.000050 0.000132 0.000082 × 0.37
tip 0.000052 0.000085 0.000033 × 0.61
0 + (-10000:) 0.028222 0.005337 -0.022885 × 5.29
0 0.023521 0.000084 -0.023437 × 280.01
(-10000:) + 0 0.235539 0.005308 -0.230231 × 44.37
(-10:) + :9 0.232883 0.000180 -0.232703 ×1293.79
(-10000:) + (:99) 0.238735 0.005358 -0.233377 × 44.55
:99 + (-10000:) 0.317942 0.005593 -0.312349 × 56.84
:9 + (-10:) 0.313372 0.000179 -0.313193 ×1750.68
:9 0.316450 0.000143 -0.316307 ×2212.93
On smaller repositories, the cost of nodemap related operation is not as big, so
the win is much more modest. Yet it helps shaving a handful of millisecond here
and there.
Here are some numbers (in seconds) for the reference copy of mercurial:
Revset Before After abs-change speedup
-10: 0.000065 0.000097 0.000032 × 0.67
tip 0.000063 0.000078 0.000015 × 0.80
0 0.000561 0.000079 -0.000482 × 7.10
-10000: 0.004609 0.003648 -0.000961 × 1.26
0 + (-10000:) 0.005023 0.003715 -0.001307 × 1.35
(-10:) + :9 0.002187 0.000108 -0.002079 ×20.25
(-10000:) + 0 0.006252 0.003716 -0.002536 × 1.68
(-10000:) + (:99) 0.006367 0.003707 -0.002660 × 1.71
:9 + (-10:) 0.003846 0.000110 -0.003736 ×34.96
:9 0.003854 0.000099 -0.003755 ×38.92
:99 + (-10000:) 0.007644 0.003778 -0.003866 × 2.02
Differential Revision: https://phab.mercurial-scm.org/D7894
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 11 Feb 2020 11:18:52 +0100 |
parents | ef6cab7930b3 |
children | 8ef9cdffad6a |
line wrap: on
line source
Tests for the journal extension; records bookmark locations. $ cat >> testmocks.py << EOF > # mock out procutil.getuser() and util.makedate() to supply testable values > import os > from mercurial import pycompat, util > from mercurial.utils import dateutil, procutil > def mockgetuser(): > return b'foobar' > > def mockmakedate(): > filename = os.path.join(os.environ['TESTTMP'], 'testtime') > try: > with open(filename, 'rb') as timef: > time = float(timef.read()) + 1 > except IOError: > time = 0.0 > with open(filename, 'wb') as timef: > timef.write(pycompat.bytestr(time)) > return (time, 0) > > procutil.getuser = mockgetuser > dateutil.makedate = mockmakedate > EOF $ cat >> $HGRCPATH << EOF > [extensions] > journal= > testmocks=`pwd`/testmocks.py > EOF Setup repo $ hg init repo $ cd repo Test empty journal $ hg journal previous locations of '.': no recorded locations $ hg journal foo previous locations of 'foo': no recorded locations Test that working copy changes are tracked $ echo a > a $ hg commit -Aqm a $ hg journal previous locations of '.': cb9a9f314b8b commit -Aqm a $ echo b > a $ hg commit -Aqm b $ hg journal previous locations of '.': 1e6c11564562 commit -Aqm b cb9a9f314b8b commit -Aqm a $ hg up 0 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg journal previous locations of '.': cb9a9f314b8b up 0 1e6c11564562 commit -Aqm b cb9a9f314b8b commit -Aqm a Test that bookmarks are tracked $ hg book -r tip bar $ hg journal bar previous locations of 'bar': 1e6c11564562 book -r tip bar $ hg book -f bar $ hg journal bar previous locations of 'bar': cb9a9f314b8b book -f bar 1e6c11564562 book -r tip bar $ hg up 1 files updated, 0 files merged, 0 files removed, 0 files unresolved updating bookmark bar $ hg journal bar previous locations of 'bar': 1e6c11564562 up cb9a9f314b8b book -f bar 1e6c11564562 book -r tip bar Test that bookmarks and working copy tracking is not mixed $ hg journal previous locations of '.': 1e6c11564562 up cb9a9f314b8b up 0 1e6c11564562 commit -Aqm b cb9a9f314b8b commit -Aqm a Test that you can list all entries as well as limit the list or filter on them $ hg book -r tip baz $ hg journal --all previous locations of the working copy and bookmarks: 1e6c11564562 baz book -r tip baz 1e6c11564562 bar up 1e6c11564562 . up cb9a9f314b8b bar book -f bar 1e6c11564562 bar book -r tip bar cb9a9f314b8b . up 0 1e6c11564562 . commit -Aqm b cb9a9f314b8b . commit -Aqm a $ hg journal --limit 2 previous locations of '.': 1e6c11564562 up cb9a9f314b8b up 0 $ hg journal bar previous locations of 'bar': 1e6c11564562 up cb9a9f314b8b book -f bar 1e6c11564562 book -r tip bar $ hg journal foo previous locations of 'foo': no recorded locations $ hg journal . previous locations of '.': 1e6c11564562 up cb9a9f314b8b up 0 1e6c11564562 commit -Aqm b cb9a9f314b8b commit -Aqm a $ hg journal "re:ba." previous locations of 're:ba.': 1e6c11564562 baz book -r tip baz 1e6c11564562 bar up cb9a9f314b8b bar book -f bar 1e6c11564562 bar book -r tip bar Test that verbose, JSON, template and commit output work $ hg journal --verbose --all previous locations of the working copy and bookmarks: 000000000000 -> 1e6c11564562 foobar baz 1970-01-01 00:00 +0000 book -r tip baz cb9a9f314b8b -> 1e6c11564562 foobar bar 1970-01-01 00:00 +0000 up cb9a9f314b8b -> 1e6c11564562 foobar . 1970-01-01 00:00 +0000 up 1e6c11564562 -> cb9a9f314b8b foobar bar 1970-01-01 00:00 +0000 book -f bar 000000000000 -> 1e6c11564562 foobar bar 1970-01-01 00:00 +0000 book -r tip bar 1e6c11564562 -> cb9a9f314b8b foobar . 1970-01-01 00:00 +0000 up 0 cb9a9f314b8b -> 1e6c11564562 foobar . 1970-01-01 00:00 +0000 commit -Aqm b 000000000000 -> cb9a9f314b8b foobar . 1970-01-01 00:00 +0000 commit -Aqm a $ hg journal --verbose -Tjson [ { "command": "up", "date": [5, 0], "name": ".", "newnodes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"], "oldnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], "user": "foobar" }, { "command": "up 0", "date": [2, 0], "name": ".", "newnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], "oldnodes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"], "user": "foobar" }, { "command": "commit -Aqm b", "date": [1, 0], "name": ".", "newnodes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"], "oldnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], "user": "foobar" }, { "command": "commit -Aqm a", "date": [0, 0], "name": ".", "newnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], "oldnodes": ["0000000000000000000000000000000000000000"], "user": "foobar" } ] $ cat <<EOF >> $HGRCPATH > [templates] > j = "{oldnodes % '{node|upper}'} -> {newnodes % '{node|upper}'} > - user: {user} > - command: {command} > - date: {date|rfc3339date} > - newnodes: {newnodes} > - oldnodes: {oldnodes} > " > EOF $ hg journal -Tj -l1 previous locations of '.': CB9A9F314B8B07BA71012FCDBC544B5A4D82FF5B -> 1E6C11564562B4ED919BACA798BC4338BD299D6A - user: foobar - command: up - date: 1970-01-01T00:00:05+00:00 - newnodes: 1e6c11564562b4ed919baca798bc4338bd299d6a - oldnodes: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b $ hg journal --commit previous locations of '.': 1e6c11564562 up changeset: 1:1e6c11564562 bookmark: bar bookmark: baz tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: b cb9a9f314b8b up 0 changeset: 0:cb9a9f314b8b user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: a 1e6c11564562 commit -Aqm b changeset: 1:1e6c11564562 bookmark: bar bookmark: baz tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: b cb9a9f314b8b commit -Aqm a changeset: 0:cb9a9f314b8b user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: a $ hg journal --commit -Tjson [ { "changesets": [{"bookmarks": ["bar", "baz"], "branch": "default", "date": [0, 0], "desc": "b", "node": "1e6c11564562b4ed919baca798bc4338bd299d6a", "parents": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], "phase": "draft", "rev": 1, "tags": ["tip"], "user": "test"}], "command": "up", "date": [5, 0], "name": ".", "newnodes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"], "oldnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], "user": "foobar" }, { "changesets": [{"bookmarks": [], "branch": "default", "date": [0, 0], "desc": "a", "node": "cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b", "parents": ["0000000000000000000000000000000000000000"], "phase": "draft", "rev": 0, "tags": [], "user": "test"}], "command": "up 0", "date": [2, 0], "name": ".", "newnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], "oldnodes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"], "user": "foobar" }, { "changesets": [{"bookmarks": ["bar", "baz"], "branch": "default", "date": [0, 0], "desc": "b", "node": "1e6c11564562b4ed919baca798bc4338bd299d6a", "parents": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], "phase": "draft", "rev": 1, "tags": ["tip"], "user": "test"}], "command": "commit -Aqm b", "date": [1, 0], "name": ".", "newnodes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"], "oldnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], "user": "foobar" }, { "changesets": [{"bookmarks": [], "branch": "default", "date": [0, 0], "desc": "a", "node": "cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b", "parents": ["0000000000000000000000000000000000000000"], "phase": "draft", "rev": 0, "tags": [], "user": "test"}], "command": "commit -Aqm a", "date": [0, 0], "name": ".", "newnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], "oldnodes": ["0000000000000000000000000000000000000000"], "user": "foobar" } ] $ hg journal --commit \ > -T'command: {command}\n{changesets % " rev: {rev}\n children: {children}\n"}' previous locations of '.': command: up rev: 1 children: command: up 0 rev: 0 children: 1:1e6c11564562 command: commit -Aqm b rev: 1 children: command: commit -Aqm a rev: 0 children: 1:1e6c11564562 Test for behaviour on unexpected storage version information $ printf '42\0' > .hg/namejournal $ hg journal previous locations of '.': abort: unknown journal file version '42' [255] $ hg book -r tip doomed unsupported journal file version '42'