...
 
Commits (12)
......@@ -666,6 +666,9 @@ coreconfigitem(
b'experimental', b'exp-persistent-nodemap', default=False,
)
coreconfigitem(
b'experimental', b'exp-persistent-nodemap.mmap', default=True,
)
coreconfigitem(
b'experimental', b'server.filesdata.recommended-batch-size', default=50000,
)
coreconfigitem(
......
......@@ -2093,6 +2093,12 @@ def debugnamecomplete(ui, repo, *args):
False,
_(b'check that the data on disk data are correct.'),
),
(
'',
b'metadata',
False,
_(b'display the on disk meta data for the nodemap'),
),
],
)
def debugnodemap(ui, repo, **args):
......@@ -2106,13 +2112,27 @@ def debugnodemap(ui, repo, **args):
elif args['dump_disk']:
unfi = repo.unfiltered()
cl = unfi.changelog
data = nodemap.persisted_data(cl)
ui.write(data)
nm_data = nodemap.persisted_data(cl)
if nm_data is not None:
docket, data = nm_data
ui.write(data[:])
elif args['check']:
unfi = repo.unfiltered()
cl = unfi.changelog
data = nodemap.persisted_data(cl)
return nodemap.check_data(ui, cl.index, data)
nm_data = nodemap.persisted_data(cl)
if nm_data is not None:
docket, data = nm_data
return nodemap.check_data(ui, cl.index, data)
elif args['metadata']:
unfi = repo.unfiltered()
cl = unfi.changelog
nm_data = nodemap.persisted_data(cl)
if nm_data is not None:
docket, data = nm_data
ui.write((b"uid: %s\n") % docket.uid)
ui.write((b"tip-rev: %d\n") % docket.tip_rev)
ui.write((b"data-length: %s\n") % docket.data_length)
ui.write((b"data-unused: %s\n") % docket.data_unused)
@command(
......
......@@ -931,6 +931,8 @@ def resolverevlogstorevfsoptions(ui, requirements, features):
options[b'rust.index'] = True
if ui.configbool('experimental', 'exp-persistent-nodemap'):
options[b'exp-persistent-nodemap'] = True
if ui.configbool('experimental', 'exp-persistent-nodemap.mmap'):
options[b'exp-persistent-nodemap.mmap'] = True
if ui.configbool('devel', 'persistent-nodemap'):
options[b'devel-force-nodemap'] = True
......
......@@ -156,13 +156,33 @@ class PersistentNodeMapIndexObject(IndexObject):
index."""
return nodemaputil.persistent_data(self)
def update_nodemap_data(self, nm_data):
def nodemap_data_incremental(self):
"""Return bytes containing a incremental serialization of a nodemap
This containst the data for an append-only update of the data provided
in the last call to `update_nodemap_data`.
"""
if self._nm_root is None:
return None
docket = self._nm_docket
changed, data = nodemaputil.update_persistent_data(
self, self._nm_root, self._nm_max_idx, self._nm_docket.tip_rev
)
self._nm_root = self._nm_max_idx = self._nm_docket = None
return docket, changed, data
def update_nodemap_data(self, docket, nm_data):
"""provide full serialiazed data from a nodemap
The data are expected to come from disk. See `nodemap_data_all` for a
produceur of such data."""
if nm_data is not None:
nodemaputil.parse_data(nm_data)
self._nm_root, self._nm_max_idx = nodemaputil.parse_data(nm_data)
if self._nm_root:
self._nm_docket = docket
else:
self._nm_root = self._nm_max_idx = self._nm_docket = None
class InlinedIndexObject(BaseIndexObject):
......
......@@ -455,6 +455,7 @@ class revlog(object):
self._maxchainlen = None
self._deltabothparents = True
self.index = None
self._nodemap_docket = None
# Mapping of partial identifiers to full nodes.
self._pcache = {}
# Mapping of revision integer to full node.
......@@ -544,6 +545,9 @@ class revlog(object):
indexdata = b''
self._initempty = True
try:
nodemap_data = nodemaputil.persisted_data(self)
if nodemap_data is not None:
self._nodemap_docket = nodemap_data[0]
with self._indexfp() as f:
if (
mmapindexthreshold is not None
......@@ -635,7 +639,7 @@ class revlog(object):
if use_nodemap:
nodemap_data = nodemaputil.persisted_data(self)
if nodemap_data is not None:
index.update_nodemap_data(nodemap_data)
index.update_nodemap_data(*nodemap_data)
except (ValueError, IndexError):
raise error.RevlogError(
_(b"index %s is corrupted") % self.indexfile
......
......@@ -290,7 +290,7 @@ Show all commands + options
debugmanifestfulltextcache: clear, add
debugmergestate:
debugnamecomplete:
debugnodemap: dump-new, dump-disk, check
debugnodemap: dump-new, dump-disk, check, metadata
debugobsolete: flags, record-parents, rev, exclusive, index, delete, date, user, template
debugp1copies: rev
debugp2copies: rev
......
......@@ -12,8 +12,13 @@ Test the persistent on-disk nodemap
> persistent-nodemap=yes
> EOF
$ hg debugbuilddag .+5000
$ hg debugnodemap --metadata
uid: ???????????????? (glob)
tip-rev: 5000
data-length: 245760
data-unused: 0
$ f --size .hg/store/00changelog.n
.hg/store/00changelog.n: size=18
.hg/store/00changelog.n: size=42
$ f --sha256 .hg/store/00changelog-*.nd
.hg/store/00changelog-????????????????.nd: sha256=bc400bf49f11e83bbd25630439feee6628a80a8602d2e38972eac44cc3efe10c (glob)
$ hg debugnodemap --dump-new | f --sha256 --size
......@@ -47,10 +52,69 @@ add a new commit
$ echo foo > foo
$ hg add foo
$ hg ci -m 'foo'
#if pure
$ hg debugnodemap --metadata
uid: ???????????????? (glob)
tip-rev: 5001
data-length: 246144
data-unused: 384
#else
$ hg debugnodemap --metadata
uid: ???????????????? (glob)
tip-rev: 5001
data-length: 245760
data-unused: 0
#endif
$ f --size .hg/store/00changelog.n
.hg/store/00changelog.n: size=18
.hg/store/00changelog.n: size=42
(The pure code use the debug code that perform incremental update, the C code reencode from scratch)
#if pure
$ f --sha256 .hg/store/00changelog-*.nd --size
.hg/store/00changelog-????????????????.nd: size=246144, sha256=c0498fb1a78a5776978427bacd92477766c2182f738fbb0125d8a05e6112d43a (glob)
#else
$ f --sha256 .hg/store/00changelog-*.nd --size
.hg/store/00changelog-????????????????.nd: size=245760, sha256=e6ee5d59afaab2cb1afae1077715be280578d29df508bd3dd9d74a994bc555e7 (glob)
#endif
$ hg debugnodemap --check
revision in index: 5002
revision in nodemap: 5002
Test code path without mmap
---------------------------
$ echo bar > bar
$ hg add bar
$ hg ci -m 'bar' --config experimental.exp-persistent-nodemap.mmap=no
$ hg debugnodemap --check --config experimental.exp-persistent-nodemap.mmap=yes
revision in index: 5003
revision in nodemap: 5003
$ hg debugnodemap --check --config experimental.exp-persistent-nodemap.mmap=no
revision in index: 5003
revision in nodemap: 5003
#if pure
$ hg debugnodemap --metadata
uid: ???????????????? (glob)
tip-rev: 5002
data-length: 246656
data-unused: 768
$ f --sha256 .hg/store/00changelog-*.nd --size
.hg/store/00changelog-????????????????.nd: size=246656, sha256=8221807a0860a7a65002d2d3e0d33512d28aa6db2433db966e56aa17dcf6329f (glob)
#else
$ hg debugnodemap --metadata
uid: ???????????????? (glob)
tip-rev: 5002
data-length: 245888
data-unused: 0
$ f --sha256 .hg/store/00changelog-*.nd --size
.hg/store/00changelog-????????????????.nd: size=245888, sha256=42233b63e5567fd362fb7847fa7a9f4d40ad93c28f8571197b356a69fe8bd271 (glob)
#endif