sapling/eden/fs/utils/NfsSocket.h
Xavier Deguillard f2e7099799 nfs: allow mountd and nfsd to bind to a unix socket on macOS
Summary:
Due to NFS being designed as a network filesystem, it default to binding on a
TCP socket. For EdenFS, since we're not expecting to mount an actual remote
filesystem, we bind these sockets to localhost. Unfortunately, TCP sockets have
some inherent overhead due to being designed to be reliable over a non-reliable
medium.

On macOS, Apple provides a way to mount an NFS server that is listening on a
unix domain socket. Thanks for unix socket being reliable, the TCP overhead
goes away leading to some higher throughput and lower latency for the NFS
server. For EdenFS, timing `rg foobar` over a directory containing 27k files gives:

NFS over TCP:
rg foobar > /dev/null  0.80s user 5.44s system 567% cpu 1.100 total

NFS over UDS:
rg foobar > /dev/null  0.77s user 5.27s system 679% cpu 0.888 total

osxfuse:
rg foobar > /dev/null  0.87s user 5.59s system 662% cpu 0.975 total

The main drawback of going through a unix socket is that D27717945 (bcf6aa465c) appears to
no longer be effective due to
8f02f2a044/bsd/nfs/nfs_vfsops.c (L3739)

Reviewed By: kmancini

Differential Revision: D28261422

fbshipit-source-id: 25dc1dc78cdb50d6c6550a86ef01ea2c894c110f
2021-05-12 13:06:57 -07:00

19 lines
395 B
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#pragma once
#include <folly/SocketAddress.h>
#include <optional>
#include "eden/fs/utils/PathFuncs.h"
namespace facebook::eden {
folly::SocketAddress makeNfsSocket(std::optional<AbsolutePath> unixSocketPath);
}