make the EdenFS tree prefetch depth configurable

Summary:
D18263067 updated the `CMD_FETCH_TREE` handler to fetch tree with a depth
of 1, rather than using fetching the entire recursive tree structure.
I think this has contributed to some of the recent user-reported slowness for
fetch operations, as fetching a large directory structure now triggers many
more individual requests for each separate tree.

This diff adds a configuration parameter to control the tree fetch depth.  I
have set the default value at 3, which should hopefully provide a reasonable
level of tree prefetching without completely fetching all contents of deep
trees.

Reviewed By: wez

Differential Revision: D18942585

fbshipit-source-id: 6a8d749434520baee25a4277712c44b916adcb3f
This commit is contained in:
Adam Simpkins 2019-12-11 20:51:45 -08:00 committed by Facebook Github Bot
parent 1498d3d9d0
commit 264f6565f6
3 changed files with 21 additions and 2 deletions

View File

@ -215,6 +215,13 @@ class HgServer(object):
continue
self._commands[value.__COMMAND_ID__] = value
# Fetch the configuration for the depth to use when fetching trees.
# Setting this to a value larger than 1 causes the CMD_FETCH_TREE code to
# pre-fetch more children trees in addition to the specific tree that was
# requested. This helps avoiding multiple round-trips when traversing into a
# directory.
self._treefetchdepth = self.repo.ui.configint("edenfs", "tree-fetch-depth")
def serve(self):
# Send a CMD_STARTED response to indicate we have started,
# and include some information about the repository configuration.
@ -497,12 +504,12 @@ class HgServer(object):
if path:
# We have to call repo._prefetchtrees() directly if we have a path.
# We cannot compute the set of base nodes in this case.
self.repo._prefetchtrees(path, mfnodes, [], [], depth=1)
self.repo._prefetchtrees(path, mfnodes, [], [], depth=self._treefetchdepth)
self.repo.commitpending()
else:
# When querying the top-level node use repo.prefetchtrees()
# It will compute a reasonable set of base nodes to send in the query.
self.repo.prefetchtrees(mfnodes, depth=1)
self.repo.prefetchtrees(mfnodes, depth=self._treefetchdepth)
self.repo.commitpending()
def send_chunk(self, request, *data, **kwargs):

View File

@ -225,6 +225,7 @@ coreconfigitem("diff", "nobinary", default=False)
coreconfigitem("diff", "noprefix", default=False)
coreconfigitem("discovery", "fastdiscovery", False)
coreconfigitem("discovery", "knownserverbookmarks", default=[])
coreconfigitem("edenfs", "tree-fetch-depth", default=3)
coreconfigitem("email", "bcc", default=None)
coreconfigitem("email", "cc", default=None)
coreconfigitem("email", "charsets", default=list)

View File

@ -965,6 +965,17 @@ The following options apply to all hosts.
Optional. Bookmarks that should normally be present on client and server.
Can be used to make fastdiscovery more precise
``edenfs``
---------
Options that control the behavior of EdenFS.
``tree-fetch-depth``
How many layers of children trees to fetch when downloading a directory listing from
the servers. Higher values increase the latency of individual fetch operations, but
potentially help save having to send separate fetch requests later to download any
child trees that are needed.
``email``
---------