Mercurial > hg
view tests/test-merge-types.t @ 26623:5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Cloning can be an expensive operation for servers because the server
generates a bundle from existing repository data at request time. For
a large repository like mozilla-central, this consumes 4+ minutes
of CPU time on the server. It also results in significant network
utilization. Multiplied by hundreds or even thousands of clients and
the ensuing load can result in difficulties scaling the Mercurial server.
Despite generation of bundles being deterministic until the next
changeset is added, the generation of bundles to service a clone request
is not cached. Each clone thus performs redundant work. This is
wasteful.
This patch introduces the "clonebundles" extension and related
client-side functionality to help alleviate this deficiency. The
client-side feature is behind an experimental flag and is not enabled by
default.
It works as follows:
1) Server operator generates a bundle and makes it available on a
server (likely HTTP).
2) Server operator defines the URL of a bundle file in a
.hg/clonebundles.manifest file.
3) Client `hg clone`ing sees the server is advertising bundle URLs.
4) Client fetches and applies the advertised bundle.
5) Client performs equivalent of `hg pull` to fetch changes made since
the bundle was created.
Essentially, the server performs the expensive work of generating a
bundle once and all subsequent clones fetch a static file from
somewhere. Scaling static file serving is a much more manageable
problem than scaling a Python application like Mercurial. Assuming your
repository grows less than 1% per day, the end result is 99+% of CPU
and network load from clones is eliminated, allowing Mercurial servers
to scale more easily. Serving static files also means data can be
transferred to clients as fast as they can consume it, rather than as
fast as servers can generate it. This makes clones faster.
Mozilla has implemented similar functionality of this patch on
hg.mozilla.org using a custom extension. We are hosting bundle files in
Amazon S3 and CloudFront (a CDN) and have successfully offloaded
>1 TB/day in data transfer from hg.mozilla.org, freeing up significant
bandwidth and CPU resources. The positive impact has been stellar and
I believe it has proved its value to be included in Mercurial core. I
feel it is important for the client-side support to be enabled in core
by default because it means that clients will get faster, more reliable
clones and will enable server operators to reduce load without
requiring any client-side configuration changes (assuming clients are
up to date, of course).
The scope of this feature is narrowly and specifically tailored to
cloning, despite "serve pulls from pre-generated bundles" being a valid
and useful feature. I would eventually like for Mercurial servers to
support transferring *all* repository data via statically hosted files.
You could imagine a server that siphons all pushed data to bundle files
and instructs clients to apply a stream of bundles to reconstruct all
repository data. This feature, while useful and powerful, is
significantly more work to implement because it requires the server
component have awareness of discovery and a mapping of which changesets
are in which files. Full, clone bundles, by contrast, are much simpler.
The wire protocol command is named "clonebundles" instead of something
more generic like "staticbundles" to leave the door open for a new, more
powerful and more generic server-side component with minimal backwards
compatibility implications. The name "bundleclone" is used by Mozilla's
extension and would cause problems since there are subtle differences
in Mozilla's extension.
Mozilla's experience with this idea has taught us that some form of
"content negotiation" is required. Not all clients will support all
bundle formats or even URLs (advanced TLS requirements, etc). To ensure
the highest uptake possible, a server needs to advertise multiple
versions of bundles and clients need to be able to choose the most
appropriate from that list one. The "attributes" in each
server-advertised entry facilitate this filtering and sorting. Their
use will become apparent in subsequent patches.
Initial inspiration and credit for the idea of cloning from static files
belongs to Augie Fackler and his "lookaside clone" extension proof of
concept.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 09 Oct 2015 11:22:01 -0700 |
parents | 8e6d5b7317e6 |
children | 4b966aaadc45 |
line wrap: on
line source
#require symlink execbit $ tellmeabout() { > if [ -h $1 ]; then > echo $1 is a symlink: > $TESTDIR/readlink.py $1 > elif [ -x $1 ]; then > echo $1 is an executable file with content: > cat $1 > else > echo $1 is a plain file with content: > cat $1 > fi > } $ hg init test1 $ cd test1 $ echo a > a $ hg ci -Aqmadd $ chmod +x a $ hg ci -mexecutable $ hg up -q 0 $ rm a $ ln -s symlink a $ hg ci -msymlink created new head Symlink is local parent, executable is other: $ hg merge --debug searching for copies back to rev 1 resolving manifests branchmerge: True, force: False, partial: False ancestor: c334dc3be0da, local: 521a1e40188f+, remote: 3574f3e69b1c preserving a for resolve of a a: versions differ -> m (premerge) picked tool ':merge' for a (binary False symlink True) merging a my a@521a1e40188f+ other a@3574f3e69b1c ancestor a@c334dc3be0da warning: internal :merge cannot merge symlinks for a warning: conflicts while merging a! (edit, then use 'hg resolve --mark') 0 files updated, 0 files merged, 0 files removed, 1 files unresolved use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon [1] $ tellmeabout a a is a symlink: a -> symlink $ hg resolve a --tool internal:other (no more unresolved files) $ tellmeabout a a is an executable file with content: a $ hg st M a ? a.orig Symlink is other parent, executable is local: $ hg update -C 1 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg merge --debug --tool :union searching for copies back to rev 1 resolving manifests branchmerge: True, force: False, partial: False ancestor: c334dc3be0da, local: 3574f3e69b1c+, remote: 521a1e40188f preserving a for resolve of a a: versions differ -> m (premerge) picked tool ':union' for a (binary False symlink True) merging a my a@3574f3e69b1c+ other a@521a1e40188f ancestor a@c334dc3be0da warning: internal :union cannot merge symlinks for a warning: conflicts while merging a! (edit, then use 'hg resolve --mark') 0 files updated, 0 files merged, 0 files removed, 1 files unresolved use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon [1] $ tellmeabout a a is an executable file with content: a $ hg update -C 1 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg merge --debug --tool :merge3 searching for copies back to rev 1 resolving manifests branchmerge: True, force: False, partial: False ancestor: c334dc3be0da, local: 3574f3e69b1c+, remote: 521a1e40188f preserving a for resolve of a a: versions differ -> m (premerge) picked tool ':merge3' for a (binary False symlink True) merging a my a@3574f3e69b1c+ other a@521a1e40188f ancestor a@c334dc3be0da warning: internal :merge3 cannot merge symlinks for a warning: conflicts while merging a! (edit, then use 'hg resolve --mark') 0 files updated, 0 files merged, 0 files removed, 1 files unresolved use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon [1] $ tellmeabout a a is an executable file with content: a Update to link without local change should get us a symlink (issue3316): $ hg up -C 0 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg up 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg st ? a.orig Update to link with local change should cause a merge prompt (issue3200): $ hg up -Cq 0 $ echo data > a $ HGMERGE= hg up -y --debug searching for copies back to rev 2 resolving manifests branchmerge: False, force: False, partial: False ancestor: c334dc3be0da, local: c334dc3be0da+, remote: 521a1e40188f preserving a for resolve of a a: versions differ -> m (premerge) (couldn't find merge tool hgmerge|tool hgmerge can't handle symlinks) (re) picked tool ':prompt' for a (binary False symlink True) no tool found to merge a keep (l)ocal or take (o)ther? l 0 files updated, 1 files merged, 0 files removed, 0 files unresolved $ hg diff --git diff --git a/a b/a old mode 120000 new mode 100644 --- a/a +++ b/a @@ -1,1 +1,1 @@ -symlink \ No newline at end of file +data Test only 'l' change - happens rarely, except when recovering from situations where that was what happened. $ hg init test2 $ cd test2 $ printf base > f $ hg ci -Aqm0 $ echo file > f $ echo content >> f $ hg ci -qm1 $ hg up -qr0 $ rm f $ ln -s base f $ hg ci -qm2 $ hg merge merging f warning: internal :merge cannot merge symlinks for f warning: conflicts while merging f! (edit, then use 'hg resolve --mark') 0 files updated, 0 files merged, 0 files removed, 1 files unresolved use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon [1] $ tellmeabout f f is a symlink: f -> base $ hg up -Cqr1 $ hg merge merging f warning: internal :merge cannot merge symlinks for f warning: conflicts while merging f! (edit, then use 'hg resolve --mark') 0 files updated, 0 files merged, 0 files removed, 1 files unresolved use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon [1] $ tellmeabout f f is a plain file with content: file content $ cd .. Test removed 'x' flag merged with change to symlink $ hg init test3 $ cd test3 $ echo f > f $ chmod +x f $ hg ci -Aqm0 $ chmod -x f $ hg ci -qm1 $ hg up -qr0 $ rm f $ ln -s dangling f $ hg ci -qm2 $ hg merge merging f warning: internal :merge cannot merge symlinks for f warning: conflicts while merging f! (edit, then use 'hg resolve --mark') 0 files updated, 0 files merged, 0 files removed, 1 files unresolved use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon [1] $ tellmeabout f f is a symlink: f -> dangling $ hg up -Cqr1 $ hg merge merging f warning: internal :merge cannot merge symlinks for f warning: conflicts while merging f! (edit, then use 'hg resolve --mark') 0 files updated, 0 files merged, 0 files removed, 1 files unresolved use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon [1] $ tellmeabout f f is a plain file with content: f Test removed 'x' flag merged with content change - both ways $ hg up -Cqr0 $ echo change > f $ hg ci -qm3 $ hg merge -r1 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) $ tellmeabout f f is a plain file with content: change $ hg up -qCr1 $ hg merge -r3 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) $ tellmeabout f f is a plain file with content: change $ cd .. Test merge with no common ancestor: a: just different b: x vs -, different (cannot calculate x, cannot ask merge tool) c: x vs -, same (cannot calculate x, merge tool is no good) d: x vs l, different e: x vs l, same f: - vs l, different g: - vs l, same h: l vs l, different (where same means the filelog entry is shared and there thus is an ancestor!) $ hg init test4 $ cd test4 $ echo 0 > 0 $ hg ci -Aqm0 $ echo 1 > a $ echo 1 > b $ chmod +x b $ echo x > c $ chmod +x c $ echo 1 > d $ chmod +x d $ printf x > e $ chmod +x e $ echo 1 > f $ printf x > g $ ln -s 1 h $ hg ci -qAm1 $ hg up -qr0 $ echo 2 > a $ echo 2 > b $ echo x > c $ ln -s 2 d $ ln -s x e $ ln -s 2 f $ ln -s x g $ ln -s 2 h $ hg ci -Aqm2 $ hg merge merging a warning: cannot merge flags for b merging b warning: cannot merge flags for c merging d warning: internal :merge cannot merge symlinks for d warning: conflicts while merging d! (edit, then use 'hg resolve --mark') merging f warning: internal :merge cannot merge symlinks for f warning: conflicts while merging f! (edit, then use 'hg resolve --mark') merging h warning: internal :merge cannot merge symlinks for h warning: conflicts while merging h! (edit, then use 'hg resolve --mark') warning: conflicts while merging a! (edit, then use 'hg resolve --mark') warning: conflicts while merging b! (edit, then use 'hg resolve --mark') 3 files updated, 0 files merged, 0 files removed, 5 files unresolved use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon [1] $ hg resolve -l U a U b U d U f U h $ tellmeabout a a is a plain file with content: <<<<<<< local: 0139c5610547 - test: 2 2 ======= 1 >>>>>>> other: 97e29675e796 - test: 1 $ tellmeabout b b is a plain file with content: <<<<<<< local: 0139c5610547 - test: 2 2 ======= 1 >>>>>>> other: 97e29675e796 - test: 1 $ tellmeabout c c is a plain file with content: x $ tellmeabout d d is a symlink: d -> 2 $ tellmeabout e e is a symlink: e -> x $ tellmeabout f f is a symlink: f -> 2 $ tellmeabout g g is a symlink: g -> x $ tellmeabout h h is a symlink: h -> 2 $ hg up -Cqr1 $ hg merge merging a warning: cannot merge flags for b merging b warning: cannot merge flags for c merging d warning: internal :merge cannot merge symlinks for d warning: conflicts while merging d! (edit, then use 'hg resolve --mark') merging f warning: internal :merge cannot merge symlinks for f warning: conflicts while merging f! (edit, then use 'hg resolve --mark') merging h warning: internal :merge cannot merge symlinks for h warning: conflicts while merging h! (edit, then use 'hg resolve --mark') warning: conflicts while merging a! (edit, then use 'hg resolve --mark') warning: conflicts while merging b! (edit, then use 'hg resolve --mark') 3 files updated, 0 files merged, 0 files removed, 5 files unresolved use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon [1] $ tellmeabout a a is a plain file with content: <<<<<<< local: 97e29675e796 - test: 1 1 ======= 2 >>>>>>> other: 0139c5610547 - test: 2 $ tellmeabout b b is an executable file with content: <<<<<<< local: 97e29675e796 - test: 1 1 ======= 2 >>>>>>> other: 0139c5610547 - test: 2 $ tellmeabout c c is an executable file with content: x $ tellmeabout d d is an executable file with content: 1 $ tellmeabout e e is an executable file with content: x (no-eol) $ tellmeabout f f is a plain file with content: 1 $ tellmeabout g g is a plain file with content: x (no-eol) $ tellmeabout h h is a symlink: h -> 1 $ cd ..