This is an archive of the discontinued Mercurial Phabricator instance.

exchangev2: fetch file revisions
ClosedPublic

Authored by indygreg on Sep 5 2018, 12:20 PM.

Details

Summary

Now that the server has an API for fetching file data, we can call into
it to fetch file revisions.

The implementation is relatively straightforward: we examine the
manifests that we fetched and find all new file revisions referenced
by them. We build up a mapping from file path to file nodes to
manifest node. (The mapping to first manifest node allows us to
map back to first changelog node/revision, which is used for the
linkrev.)

Once that map is built up, we iterate over it in a deterministic
manner and fetch and store file data. The code is very similar
to manifest fetching. So similar that we could probably extract the
common bits into a generic function.

With file data retrieval implemented, hg clone and hg pull are
effectively feature complete, at least as far as the completeness
of data transfer for essential repository data (changesets, manifests,
files, phases, and bookmarks). We're still missing support for
obsolescence markers, the hgtags fnodes cache, and the branchmap
cache. But these are non-essential for the moment (and will be
implemented later).

This is a good point to assess the state of exchangev2 in terms of
performance. I ran a local hg clone for the mozilla-unified
repository using both version 1 and version 2 of the wire protocols
and exchange methods. This is effectively comparing the performance
of the wire protocol overhead and "getbundle" versus domain-specific
commands. Wire protocol version 2 doesn't have compression implemented
yet. So I tested version 1 with server.compressionengines=none to
remove compression overhead from the equation.

server
before: user 220.420+0.000 sys 14.420+0.000
after: user 321.980+0.000 sys 18.990+0.000

client
before: real 561.650 secs (user 497.670+0.000 sys 28.160+0.000)
after: real 1226.260 secs (user 944.240+0.000 sys 354.150+0.000)

We have substantial regressions on both client and server. This
is obviously not desirable. I'm aware of some reasons:

  • Lack of hgtagsfnodes transfer (contributes significant CPU to client).
  • Lack of branch cache transfer (contributes significant CPU to client).
  • Little to no profiling / optimization performed on wire protocol version 2 code.
  • There appears to be a memory leak on the client and that is likely causing swapping on my machine.
  • Using multiple threads on the client may be counter-productive because Python.
  • We're not compressing on the server.
  • We're tracking file nodes on the client via manifest diffing rather than using linkrev shortcuts on the server.

I'm pretty confident that most of these issues are addressable.

But even if we can't get wire protocol version 2 on performance parity
with "getbundle," I still think it is important to have the set of low
level data-specific retrieval commands that we have implemented so
far. This is because the existence of such commands allows flexibility
in how clients access server data.

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.Sep 5 2018, 12:20 PM
durin42 accepted this revision.Sep 12 2018, 11:12 AM
This revision is now accepted and ready to land.Sep 12 2018, 11:12 AM
indygreg updated this revision to Diff 10970.Sep 12 2018, 1:11 PM
This revision was automatically updated to reflect the committed changes.