大网数据广告活动
服务器运维问答

How to get decent NFS performance for workloads like git?

· 52CE 我爱测

I manage a vagrant setup for our developers running OSX to manage VirtualBox systems for development. In order to support inotify inside the linux machine, we eschew the usual method of sharing directories with VirtualBox: instea…

问题原文

原帖链接 · Cera · CC BY-SA 3.0

I manage a vagrant setup for our developers running OSX to manage VirtualBox systems for development.

In order to support inotify inside the linux machine, we eschew the usual method of sharing directories with VirtualBox: instead, the Virtualbox machine exposes an NFS share, which is mounted in OSX.

Git (and related tools like sourcetree) are run in OSX, on the shared directory. The performance of this is extremely poor: it often takes up to 5 seconds just to run git status. Cloning a small repository into the mounted NFS drive can take a couple of minutes (5-10 seconds on a local drive).

Obviously NFS performance will be worse than writing straight to a local SSD, but the NFS is just running over a virtual private network interface with Virtualbox.

I ran a couple of benchmarks. The first:

dd if=/dev/zero of=test bs=16 count=16384

Each result is based on 100 samples.

# local drive
Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
0.990   1.000   1.020   1.021   1.030   1.130

# on the shared NFS drive
Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
6.000   6.278   6.390   6.482   6.570   7.630

# inside the VirtualBox instance
Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
0.3600  0.4800  0.5150  0.5552  0.5400  1.4500

The second benchmark:

ioping -c 500

local avg: 6 microseconds
local IOPS: 65.5 k

NFS Latency avg: 703 microseconds
NFS OPS: 1.4 k

Clearly some latency is inevitable, but this is bad enough that it makes some simple tasks quite painful.

The owner of the volume is running Ubuntu 12.10 (Quantal), with default settings. The system mounting the volume is running OSX Mavericks.

At the moment the main nfsd connection is running over UDP, which seems ideal over a virtual connection. I'm not sure whether statsd and lockd are running over TCP and UDP.

I tried mounting with the async flag, and with rwsize boosted, and it made little difference.

What opportunities are there for seriously improving the performance of NFS in this environment?

社区高分解答

原帖链接 · heyyo · CC BY-SA 4.0

Update: core.preloadindex is enabled by default now so this answer will make no difference.

Try to use this Git setting, which makes a huge performance difference on NFS shares:

git config core.preloadindex true

Quote from the documentation available at: https://git-scm.com/docs/git-config#git-config-corepreloadIndex

This can speed up operations like git diff and git status especially on filesystems like NFS that have weak caching semantics and thus relatively high IO latencies. When enabled, Git will do the index comparison to the filesystem data in parallel, allowing overlapping IO’s. Defaults to true.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2014-03-10)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。