RasPi NFS が遅い

はじめに

RaspberryPi で NFS サーバを立てた.

heavymoon.hateblo.jp

くそほど遅いので原因を調べた.

どれほど遅いのか

母艦PCからRasPi-NFSへ dd してみた結果は下の通り.
ブロックサイズやカウントを適当に変化させても概ね 11MB/s となった.

$ time dd if=/dev/zero of=/var/data/test.tmp bs=256M count=4
4+0 レコード入力
4+0 レコード出力
1073741824 バイト (1.1 GB) コピーされました、 96.352 秒、 11.1 MB/秒

real    1m36.388s
user    0m0.001s
sys 0m1.099s

察しの良い人であればこの時点で原因の検討がつくのかもしれない.

RasPiの状態を調べる

母艦PCで dd したときのRasPiのリソースを確認する.
CPUとメモリは十分に余裕が有る.

$ top -b -n 1
top - 23:42:10 up 16 days,  5:46,  1 user,  load average: 0.88, 0.44, 0.51
Tasks: 119 total,   1 running,  73 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.3 us,  0.1 sy,  0.0 ni, 99.2 id,  0.2 wa,  0.0 hi,  0.1 si,  0.0 st
KiB Mem :   949448 total,    32120 free,   406672 used,   510656 buff/cache
KiB Swap:        0 total,        0 free,        0 used.   474124 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 4971 root      20   0       0      0      0 S  17.6  0.0  34:42.85 nfsd
18127 xxxx    20   0   10260   3068   2628 R   5.9  0.3   0:00.03 top
    1 root      20   0   28236   2476   1140 S   0.0  0.3   0:33.83 systemd
<<以下略>>

USBの対応スピードを確認する.
480Mbps で接続されており十分に余裕が有る.

$ lsusb -t
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/5p, 480M
        |__ Port 1: Dev 3, If 0, Class=Vendor Specific Class, Driver=smsc95xx, 480M
        |__ Port 5: Dev 4, If 0, Class=Mass Storage, Driver=usb-storage, 480M    # これをNFSとして利用している

$ sudo lsusb -s 001:004 -vv
<<中略>>
  SuperSpeed USB Device Capability:
    bLength                10
    bDescriptorType        16
    bDevCapabilityType      3
    bmAttributes         0x00
    wSpeedsSupported   0x000e
      Device can operate at Full Speed (12Mbps)
      Device can operate at High Speed (480Mbps)
      Device can operate at SuperSpeed (5Gbps)
    bFunctionalitySupport   1
      Lowest fully-functional device speed is Full Speed (12Mbps)
    bU1DevExitLat          10 micro seconds
    bU2DevExitLat        2047 micro seconds
<<以下略>>

NICの対応スピードを確認する.
有線LANのスペックは下の通り.

Raspberry Pi 3 model B(UD-RP3) 仕様 | Raspberry Pi(ラズベリーパイ) | IODATA アイ・オー・データ機器

RJ-45 x1:IEEE802.3i(10BASE-T)、IEEE802.3u(100BASE-TX

一応コマンドでも確認.
100Mbps 出る様子.

$ cat /sys/class/net/eth0/speed 
100

おわりに

ということで,RasPiのスペックを眺めれば言うまでも無いのだけれど,NICで頭打ちになっている様子.

USB2.0だけどLANアダプタを使えば2倍ちょっとくらいスピードアップするらしい.

www.jeffgeerling.com

2000円以内で2倍程度の性能アップ,,,RasPi3B+買うよりは安いけれど,,,別のサーバ立てる?,,,どうしようか,,,