This is an archive of the discontinued Mercurial Phabricator instance.

changegroup: capture revision delta in a data structure
ClosedPublic

Authored by indygreg on Aug 3 2018, 5:04 PM.

Details

Summary

The current changegroup generation code is tightly coupled to
the revlog API. This tight coupling makes it difficult to implement
alternate storage backends without requiring a large surface area
of the revlog API to be exposed. This is not desirable.

In order to support changegroup generation with non-revlog storage,
we'll need to abstract the concept of delta generation.

This commit is the first step down that road. We introduce a
data structure for representing a delta in a changegroup.

The API still leaves a lot to be desired. But at least we now
have separation between data and actions performed on it.

As part of this, we tweak behavior slightly: we no longer
concatenate the delta prefix with the metadata header. Instead,
we track and emit the prefix as a separate chunk. This shouldn't
have any meaningful impact since all the chunks just get sent to
the wire, the compressor, etc.

Because we're introducing a new object, this does add some
overhead to changegroup execution. hg perfchangegroupchangelog
on my clone of the Mercurial repo (~40,000 visible revisions in
the changelog) slows down a bit:

! wall 1.268600 comb 1.270000 user 1.270000 sys 0.000000 (best of 8)
! wall 1.419479 comb 1.410000 user 1.410000 sys 0.000000 (best of 8)

With for hg bundle -t none-v2 -a /dev/null:

before: real 6.610 secs (user 6.460+0.000 sys 0.140+0.000)
after: real 7.210 secs (user 7.060+0.000 sys 0.140+0.000)

I plan to claw back this regression in future commits. And I may
even do away with this data structure once the refactor is complete.
For now, it makes things easier to comprehend.

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.