This is an archive of the discontinued Mercurial Phabricator instance.

exchange: send bundle2 stream clones uncompressed
ClosedPublic

Authored by indygreg on Jan 20 2018, 7:44 PM.

Details

Summary

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.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

indygreg created this revision.Jan 20 2018, 7:44 PM
lothiraldan added inline comments.
mercurial/bundle2.py
605

The double-negation (preferuncompressed = False) sounds complicated. Some other parts of the code are also using uncompressed but maybe we could use prefercompressed = True here as an improvement.

indygreg updated this revision to Diff 4984.Jan 22 2018, 3:32 PM
durin42 accepted this revision.Jan 22 2018, 4:09 PM
This revision is now accepted and ready to land.Jan 22 2018, 4:09 PM
This revision was automatically updated to reflect the committed changes.