I have been struggling to fix a performance problem with a SMB/CIFS share when performing small writes.
First, let me describe my current network setup:
Server
- Synology DS215j (with SMB3 support enabled)
Clients (same computer dual-booted wired Gig-E)
- Ubuntu 14.04.5 LTS, Trusty Tahr
- Windows 8.1
smb.conf
[global]
printcap name=cups
winbind enum groups=yes
include=/var/tmp/nginx/smb.netbios.aliases.conf
socket options=TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536
security=user
local master=no
realm=*
passdb backend=smbpasswd
printing=cups
max protocol=SMB3
winbind enum users=yes
load printers=yes
workgroup=WORKGROUP
I'm currently testing the small write performance with the following program written in C++ (on GitHub here):
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
int main(int argc, char* argv[])
{
ofstream outFile(argv[1]);
for(int i = 0; i < 1000000; i++)
{
outFile << "Line #" << i << endl;
}
outFile.flush();
outFile.close();
return 0;
}
Linux mount configuration:
//192.168.1.10/nas-main on /mnt/nas-main type cifs (rw,noexec,nodev)
Program run-time on Linux (peaks network output at ~100Mbps):
$ time ./nas-write-test /mnt/nas-main/home/will/test.txt
real 0m0.965s
user 0m0.148s
sys 0m0.672s
PCAP snapshot showing chunking of many lines into a single TCP packet:
Program run-time on Windows as measured by PowerShell:
> Measure-Command {start-process .\nas-write-test.exe -argumentlist "Z:\home\will\test-win.txt" -wait}
Days : 0
Hours : 0
Minutes : 9
Seconds : 29
Milliseconds : 316
Ticks : 5693166949
TotalDays : 0.00658931359837963
TotalHours : 0.158143526361111
TotalMinutes : 9.48861158166667
TotalSeconds : 569.3166949
TotalMilliseconds : 569316.6949
PCAP snapshot on Windows showing single line per SMB Write Request:
This same program takes about 10 minutes (~2.3Mbps) on Windows. Obviously, the Windows PCAP shows a very noisy SMB conversation with very low payload efficiency.
Are there any settings on Windows that can improve small write performance? It seems from looking at packet captures that Windows doesn't buffer the writes properly and immediately sends out the data one line at a time. Whereas, on Linux, the data is heavily buffered and thus has far superior performance. Let me know if the PCAP files would be helpful, and I can find a way to upload them.
Update 10/27/16:
As mentioned by @sehafoc, I reduced the Samba servers max protocol
setting to SMB1 with the following:
max protocol=NT1
The above setting resulted in the exact same behavior.
I also removed the variable of Samba by creating a share on another Windows 10 machine, and it also exhibits the same behavior as the Samba server, so I'm beginning to believe this is a write caching bug with Windows clients in general.
Update: 10/06/17:
Full Linux packet capture (14MB)
Full Windows packet capture (375MB)
Update: 10/12/17:
I also setup an NFS share and Windows does write with no buffering for this as well. So, it's definitely an underlying Windows client issue as far as I can tell, which is definitely unfortunate :-/
Any help would be appreciated!