Mercurial > hg
view tests/test-inherit-mode.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 | e4ac7e63c213 |
children | 3e91d9978bec |
line wrap: on
line source
#require unix-permissions test that new files created in .hg inherit the permissions from .hg/store $ mkdir dir just in case somebody has a strange $TMPDIR $ chmod g-s dir $ cd dir $ cat >printmodes.py <<EOF > from __future__ import absolute_import, print_function > import os > import sys > > allnames = [] > isdir = {} > for root, dirs, files in os.walk(sys.argv[1]): > for d in dirs: > name = os.path.join(root, d) > isdir[name] = 1 > allnames.append(name) > for f in files: > name = os.path.join(root, f) > allnames.append(name) > allnames.sort() > for name in allnames: > suffix = name in isdir and '/' or '' > print('%05o %s%s' % (os.lstat(name).st_mode & 0o7777, name, suffix)) > EOF $ cat >mode.py <<EOF > from __future__ import absolute_import, print_function > import os > import sys > print('%05o' % os.lstat(sys.argv[1]).st_mode) > EOF $ umask 077 $ hg init repo $ cd repo $ chmod 0770 .hg/store .hg/cache .hg/wcache before commit store can be written by the group, other files cannot store is setgid $ "$PYTHON" ../printmodes.py . 00700 ./.hg/ 00600 ./.hg/00changelog.i 00770 ./.hg/cache/ 00600 ./.hg/requires 00770 ./.hg/store/ 00770 ./.hg/wcache/ $ mkdir dir $ touch foo dir/bar $ hg ci -qAm 'add files' after commit working dir files can only be written by the owner files created in .hg can be written by the group (in particular, store/**, dirstate, branch cache file, undo files) new directories are setgid $ "$PYTHON" ../printmodes.py . 00700 ./.hg/ 00600 ./.hg/00changelog.i 00770 ./.hg/cache/ 00660 ./.hg/cache/branch2-served 00660 ./.hg/cache/rbc-names-v1 00660 ./.hg/cache/rbc-revs-v1 00660 ./.hg/dirstate 00660 ./.hg/fsmonitor.state (fsmonitor !) 00660 ./.hg/last-message.txt 00600 ./.hg/requires 00770 ./.hg/store/ 00660 ./.hg/store/00changelog.i 00660 ./.hg/store/00manifest.i 00770 ./.hg/store/data/ 00770 ./.hg/store/data/dir/ 00660 ./.hg/store/data/dir/bar.i (reporevlogstore !) 00660 ./.hg/store/data/foo.i (reporevlogstore !) 00770 ./.hg/store/data/dir/bar/ (reposimplestore !) 00660 ./.hg/store/data/dir/bar/b80de5d138758541c5f05265ad144ab9fa86d1db (reposimplestore !) 00660 ./.hg/store/data/dir/bar/index (reposimplestore !) 00770 ./.hg/store/data/foo/ (reposimplestore !) 00660 ./.hg/store/data/foo/b80de5d138758541c5f05265ad144ab9fa86d1db (reposimplestore !) 00660 ./.hg/store/data/foo/index (reposimplestore !) 00660 ./.hg/store/fncache (repofncache !) 00660 ./.hg/store/phaseroots 00660 ./.hg/store/undo 00660 ./.hg/store/undo.backupfiles 00660 ./.hg/store/undo.phaseroots 00660 ./.hg/undo.backup.dirstate 00660 ./.hg/undo.bookmarks 00660 ./.hg/undo.branch 00660 ./.hg/undo.desc 00660 ./.hg/undo.dirstate 00770 ./.hg/wcache/ 00711 ./.hg/wcache/checkisexec 007.. ./.hg/wcache/checklink (re) 00600 ./.hg/wcache/checklink-target 00660 ./.hg/wcache/manifestfulltextcache (reporevlogstore !) 00700 ./dir/ 00600 ./dir/bar 00600 ./foo $ umask 007 $ hg init ../push before push group can write everything $ "$PYTHON" ../printmodes.py ../push 00770 ../push/.hg/ 00660 ../push/.hg/00changelog.i 00770 ../push/.hg/cache/ 00660 ../push/.hg/requires 00770 ../push/.hg/store/ 00770 ../push/.hg/wcache/ $ umask 077 $ hg -q push ../push after push group can still write everything $ "$PYTHON" ../printmodes.py ../push 00770 ../push/.hg/ 00660 ../push/.hg/00changelog.i 00770 ../push/.hg/cache/ 00660 ../push/.hg/cache/branch2-base 00660 ../push/.hg/dirstate 00660 ../push/.hg/requires 00770 ../push/.hg/store/ 00660 ../push/.hg/store/00changelog.i 00660 ../push/.hg/store/00manifest.i 00770 ../push/.hg/store/data/ 00770 ../push/.hg/store/data/dir/ 00660 ../push/.hg/store/data/dir/bar.i (reporevlogstore !) 00660 ../push/.hg/store/data/foo.i (reporevlogstore !) 00770 ../push/.hg/store/data/dir/bar/ (reposimplestore !) 00660 ../push/.hg/store/data/dir/bar/b80de5d138758541c5f05265ad144ab9fa86d1db (reposimplestore !) 00660 ../push/.hg/store/data/dir/bar/index (reposimplestore !) 00770 ../push/.hg/store/data/foo/ (reposimplestore !) 00660 ../push/.hg/store/data/foo/b80de5d138758541c5f05265ad144ab9fa86d1db (reposimplestore !) 00660 ../push/.hg/store/data/foo/index (reposimplestore !) 00660 ../push/.hg/store/fncache (repofncache !) 00660 ../push/.hg/store/undo 00660 ../push/.hg/store/undo.backupfiles 00660 ../push/.hg/store/undo.phaseroots 00660 ../push/.hg/undo.bookmarks 00660 ../push/.hg/undo.branch 00660 ../push/.hg/undo.desc 00660 ../push/.hg/undo.dirstate 00770 ../push/.hg/wcache/ Test that we don't lose the setgid bit when we call chmod. Not all systems support setgid directories (e.g. HFS+), so just check that directories have the same mode. $ cd .. $ hg init setgid $ cd setgid $ chmod g+rwx .hg/store $ chmod g+s .hg/store 2> /dev/null || true $ mkdir dir $ touch dir/file $ hg ci -qAm 'add dir/file' $ storemode=`"$PYTHON" ../mode.py .hg/store` $ dirmode=`"$PYTHON" ../mode.py .hg/store/data/dir` $ if [ "$storemode" != "$dirmode" ]; then > echo "$storemode != $dirmode" > fi $ cd .. $ cd .. # g-s dir