Monday, December 18, 2017

Windows 7 / SMB2 slow network copy performance

Troubleshooting a tricky performance problem and wondering if this behavior is normal/expected.



This seems to be related to SMB2, as switching to SMB1 resolves things. The question is whether this is expected (i.e. design of SMB2) and, if so, is there a solution/workaround?



Here’s a simplified version of the problem:




1.Connect two Windows 7 machines via crossover cable.



2.Start a large file copy.




3.While that copy is underway, start a small file copy. The second copy process is very slow.



4.However, if you instead connect to the other machine “another” way (i.e. via IP instead of FQDN, or via Netbios name instead of IP, etc.), copy performance is relatively good.




It appears that the large copy is “bottlenecking” the original connection – i.e. as soon as you pause the large copy, the small copy finishes quickly.



It’s not saturating the bandwidth/stack completely though (since the second copy via a "different connection” finishes quickly).




How to reproduce the problem:



I've created some batch files that demonstrate this (all the code is listed at the bottom of the question – you need to create 5 separate batch files called go.bat, test.bat, copy1.bat, copy2.bat, copybig.bat):




Setup:




  1. Create test directory on remote ComputerB (c:\test)

  2. Create test directory on local ComputerA (c:\test)


  3. Put the 5 test batch files in ComputerA’s c:\test directory

  4. Edit go.bat and modify the last line as follows:
    The format is “call test.bat 1 2 3”, where: 1 = remote path via
    hostname 2 = local folder 3 = remote path via IP (e.g.: call
    test.bat \\ComputerB\c$\test c:\test \\ComputerB’sIPAddress\c$\test)



Execution:





  1. Open a command prompt as an administrator (so it can create the empty test files) and run go.bat




Here’s what the batch files do:




-Checks ComputerA to see if the three files exist (1GB, 10MB-1, 10MB-2) . If the files aren’t there, creates them.



-Deletes the local log file and ComputerB test files




-Starts copying the 1GB file from ComputerA to ComputerB



-Waits two seconds



-Starts copying the 10MB-1 file from ComputerA to ComputerB



-Starts copying the 10MB-2 file from ComputerA to ComputerB (but using its IP address)



-Logs, with timestamps, what’s happening to log.txt





Results:



What seems to happen consistently is this:




-The big 1GB file copy establishes a connection with the remote machine



-The small 10MB-1 file copy starts and eventually finishes but is really slow because it’s “sharing” the existing connection with the 1GB copy connection




-The small 10MB-2 file copy that uses the IP address finishes quickly because it establishes a “new/separate” connection



-At any point, if you hit pause during the big copy, the small 10MB-1 copy finishes quickly.




Batch file code:



--go.bat--
cls

rem The format is test.bat 1 2 3, where:
rem 1 = destination path with hostname
rem 2 = local path
rem 3 = destination path with IP

call test.bat \\ComputerB\c$\test c:\test \\ComputerB'sIP\c$\test
--go.bat--


--test.bat--

if exist %2\1GB goto 1
fsutil file createnew 1GB 1048576000

:1
if exist %2\10MB-1 goto 2
fsutil file createnew 10MB-1 10485760

:2
if exist %2\10MB-2 goto 3
fsutil file createnew 10MB-2 10485760


:3

del /q /f log.txt
del /q /f %1\10MB-1
del /q /f %1\10MB-2
del /q /f %1\1GB

set var1=%1
set var2=%2

set var3=%3

echo Calling CopyBig.bat %time% >> log.txt
start CopyBig.bat %var1% %var2% %var3%

echo Pausing for two seconds %time% >> log.txt
ping 127.0.0.1 -n 3

echo Calling Copy1.bat %time% >> log.txt
start copy1.bat %var1% %var2% %var3%


echo Calling Copy2.bat %time% >> log.txt
start copy2.bat %var1% %var2% %var3%
--test.bat--


--copybig.bat--
echo Starting Big Robocopy %time% >> log.txt
robocopy %2 %1 1GB
echo Done Big Robocopy %time% >> log.txt

--copybig.bat--


--copy1.bat--
echo Starting 1st Robocopy %time% >> log.txt
robocopy %2 %1 10MB-1
echo Done 1st Robocopy %time% >> log.txt
--copy1.bat--



--copy2.bat--
echo Starting 2nd Robocopy %time% >> log.txt
robocopy %2 %3 10MB-2
echo Done 2nd Robocopy %time% >> log.txt
--copy2.bat--

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...