##// END OF EJS Templates
compression: introduce a `storage.revlog.zlib.level` configuration...
compression: introduce a `storage.revlog.zlib.level` configuration This option control the zlib compression level used when compression revlog chunk. This is also a good excuse to pave the way for a similar configuration option for the zstd compression engine. Having a dedicated option for each compression algorithm is useful because they don't support the same range of values. Using a higher zlib compression impact CPU consumption at compression time, but does not directly affected decompression time. However dealing with small compressed chunk can directly help decompression and indirectly help other revlog logic. I ran some basic test on repositories using different level. I am using the mercurial, pypy, netbeans and mozilla-central clone from our benchmark suite. All tested repository use sparse-revlog and got all their delta recomputed. The different compression level has a small effect on the repository size (about 10% variation in the total range). My quick analysis is that revlog mostly store small delta, that are not affected by the compression level much. So the variation probably mostly comes from better compression of the snapshots revisions, and snapshot revision only represent a small portion of the repository content. I also made some basic timings measurements. The "read" timings are gathered using simple run of `hg perfrevlogrevisions`, the "write" timings using `hg perfrevlogwrite` (restricted to the last 5000 revisions for netbeans and mozilla central). The timings are gathered on a generic machine, (not one of our performance locked machine), so small variation might not be meaningful. However large trend remains relevant. Keep in mind that these numbers are not pure compression/decompression time. They also involve the full revlog logic. In particular the difference in chunk size has an impact on the delta chain structure, affecting performance when writing or reading them. On read/write performance, the compression level has a bigger impact. Counter-intuitively, the higher compression levels improve "write" performance for the large repositories in our tested setting. Maybe because the last 5000 delta chain end up having a very different shape in this specific spot? Or maybe because of a more general trend of better delta chains thanks to the smaller chunk and snapshot. This series does not intend to change the default compression level. However, these result call for a deeper analysis of this performance difference in the future. Full data ========= repo level .hg/store size 00manifest.d read write ---------------------------------------------------------------- mercurial 1 49,402,813 5,963,475 0.170159 53.250304 mercurial 6 47,197,397 5,875,730 0.182820 56.264320 mercurial 9 47,121,596 5,849,781 0.189219 56.293612 pypy 1 370,830,572 28,462,425 2.679217 460.721984 pypy 6 340,112,317 27,648,747 2.768691 467.537158 pypy 9 338,360,736 27,639,003 2.763495 476.589918 netbeans 1 1,281,847,810 165,495,457 122.477027 520.560316 netbeans 6 1,205,284,353 159,161,207 139.876147 715.930400 netbeans 9 1,197,135,671 155,034,586 141.620281 678.297064 mozilla 1 2,775,497,186 298,527,987 147.867662 751.263721 mozilla 6 2,596,856,420 286,597,671 170.572118 987.056093 mozilla 9 2,587,542,494 287,018,264 163.622338 739.803002

File last commit:

r42132:42e2c7c5 default
r42210:1fac9b93 default
Show More
split.py
177 lines | 6.3 KiB | text/x-python | PythonLexer
# split.py - split a changeset into smaller ones
#
# Copyright 2015 Laurent Charignon <lcharignon@fb.com>
# Copyright 2017 Facebook, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
"""command to split a changeset into smaller ones (EXPERIMENTAL)"""
from __future__ import absolute_import
from mercurial.i18n import _
from mercurial.node import (
nullid,
short,
)
from mercurial import (
bookmarks,
cmdutil,
commands,
error,
hg,
obsolete,
phases,
pycompat,
registrar,
revsetlang,
scmutil,
)
# allow people to use split without explicitly enabling rebase extension
from . import (
rebase,
)
cmdtable = {}
command = registrar.command(cmdtable)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
# leave the attribute unspecified.
testedwith = 'ships-with-hg-core'
@command('split',
[('r', 'rev', '', _("revision to split"), _('REV')),
('', 'rebase', True, _('rebase descendants after split')),
] + cmdutil.commitopts2,
_('hg split [--no-rebase] [[-r] REV]'),
helpcategory=command.CATEGORY_CHANGE_MANAGEMENT, helpbasic=True)
def split(ui, repo, *revs, **opts):
"""split a changeset into smaller ones
Repeatedly prompt changes and commit message for new changesets until there
is nothing left in the original changeset.
If --rev was not given, split the working directory parent.
By default, rebase connected non-obsoleted descendants onto the new
changeset. Use --no-rebase to avoid the rebase.
"""
opts = pycompat.byteskwargs(opts)
revlist = []
if opts.get('rev'):
revlist.append(opts.get('rev'))
revlist.extend(revs)
with repo.wlock(), repo.lock(), repo.transaction('split') as tr:
revs = scmutil.revrange(repo, revlist or ['.'])
if len(revs) > 1:
raise error.Abort(_('cannot split multiple revisions'))
rev = revs.first()
ctx = repo[rev]
if rev is None or ctx.node() == nullid:
ui.status(_('nothing to split\n'))
return 1
if ctx.node() is None:
raise error.Abort(_('cannot split working directory'))
# rewriteutil.precheck is not very useful here because:
# 1. null check is done above and it's more friendly to return 1
# instead of abort
# 2. mergestate check is done below by cmdutil.bailifchanged
# 3. unstable check is more complex here because of --rebase
#
# So only "public" check is useful and it's checked directly here.
if ctx.phase() == phases.public:
raise error.Abort(_('cannot split public changeset'),
hint=_("see 'hg help phases' for details"))
descendants = list(repo.revs('(%d::) - (%d)', rev, rev))
alloworphaned = obsolete.isenabled(repo, obsolete.allowunstableopt)
if opts.get('rebase'):
# Skip obsoleted descendants and their descendants so the rebase
# won't cause conflicts for sure.
torebase = list(repo.revs('%ld - (%ld & obsolete())::',
descendants, descendants))
if not alloworphaned and len(torebase) != len(descendants):
raise error.Abort(_('split would leave orphaned changesets '
'behind'))
else:
if not alloworphaned and descendants:
raise error.Abort(
_('cannot split changeset with children without rebase'))
torebase = ()
if len(ctx.parents()) > 1:
raise error.Abort(_('cannot split a merge changeset'))
cmdutil.bailifchanged(repo)
# Deactivate bookmark temporarily so it won't get moved unintentionally
bname = repo._activebookmark
if bname and repo._bookmarks[bname] != ctx.node():
bookmarks.deactivate(repo)
wnode = repo['.'].node()
top = None
try:
top = dosplit(ui, repo, tr, ctx, opts)
finally:
# top is None: split failed, need update --clean recovery.
# wnode == ctx.node(): wnode split, no need to update.
if top is None or wnode != ctx.node():
hg.clean(repo, wnode, show_stats=False)
if bname:
bookmarks.activate(repo, bname)
if torebase and top:
dorebase(ui, repo, torebase, top)
def dosplit(ui, repo, tr, ctx, opts):
committed = [] # [ctx]
# Set working parent to ctx.p1(), and keep working copy as ctx's content
if ctx.node() != repo.dirstate.p1():
hg.clean(repo, ctx.node(), show_stats=False)
with repo.dirstate.parentchange():
scmutil.movedirstate(repo, ctx.p1())
# Any modified, added, removed, deleted result means split is incomplete
incomplete = lambda repo: any(repo.status()[:4])
# Main split loop
while incomplete(repo):
if committed:
header = (_('HG: Splitting %s. So far it has been split into:\n')
% short(ctx.node()))
for c in committed:
firstline = c.description().split('\n', 1)[0]
header += _('HG: - %s: %s\n') % (short(c.node()), firstline)
header += _('HG: Write commit message for the next split '
'changeset.\n')
else:
header = _('HG: Splitting %s. Write commit message for the '
'first split changeset.\n') % short(ctx.node())
opts.update({
'edit': True,
'interactive': True,
'message': header + ctx.description(),
})
commands.commit(ui, repo, **pycompat.strkwargs(opts))
newctx = repo['.']
committed.append(newctx)
if not committed:
raise error.Abort(_('cannot split an empty revision'))
scmutil.cleanupnodes(repo, {ctx.node(): [c.node() for c in committed]},
operation='split', fixphase=True)
return committed[-1]
def dorebase(ui, repo, src, destctx):
rebase.rebase(ui, repo, rev=[revsetlang.formatspec('%ld', src)],
dest=revsetlang.formatspec('%d', destctx.rev()))