diff mercurial/exchange.py @ 35787:a84dbc87dae9

exchange: send bundle2 stream clones uncompressed Stream clones don't compress well. And compression undermines a point of stream clones which is to trade significant CPU reductions by increasing size. Building upon our introduction of metadata to communicate bundle information back to callers of exchange.getbundlechunks(), we add an attribute to the bundler that communicates whether the bundle is best left uncompressed. We return this attribute as part of the bundle metadata. And the wire protocol honors it when determining whether to compress the wire protocol response. The added test demonstrates that the raw result from the wire protocol is not compressed. It also demonstrates that the server will serve stream responses when the feature isn't enabled. We'll address that in another commit. The effect of this change is that server-side CPU usage for bundle2 stream clones is significantly reduced by removing zstd compression. For the mozilla-unified repository: before: 37.69 user 8.01 system after: 27.38 user 7.34 system Assuming things are CPU bound, that ~10s reduction would translate to faster clones on the client. zstd can decompress at >1 GB/s. So the overhead from decompression on the client is small in the grand scheme of things. But if zlib compression were being used, the overhead would be much greater. Differential Revision: https://phab.mercurial-scm.org/D1926
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 22 Jan 2018 12:12:29 -0800
parents ba15580e53d5
children b116a66bcc44
line wrap: on
line diff
--- a/mercurial/exchange.py	Mon Jan 22 12:38:04 2018 -0800
+++ b/mercurial/exchange.py	Mon Jan 22 12:12:29 2018 -0800
@@ -1763,6 +1763,8 @@
         func(bundler, repo, source, bundlecaps=bundlecaps, b2caps=b2caps,
              **pycompat.strkwargs(kwargs))
 
+    info['prefercompressed'] = bundler.prefercompressed
+
     return info, bundler.getchunks()
 
 @getbundle2partsgenerator('stream')
@@ -1770,6 +1772,12 @@
                      b2caps=None, heads=None, common=None, **kwargs):
     if not kwargs.get('stream', False):
         return
+
+    # Stream clones don't compress well. And compression undermines a
+    # goal of stream clones, which is to be fast. Communicate the desire
+    # to avoid compression to consumers of the bundle.
+    bundler.prefercompressed = False
+
     filecount, bytecount, it = streamclone.generatev2(repo)
     requirements = ' '.join(sorted(repo.requirements))
     part = bundler.newpart('stream', data=it)