hierynomus / smbj

Server Message Block (SMB2, SMB3) implementation in Java
Other
713 stars 180 forks source link

File transfer speeds 2x slower with 3.1.1 dialect compared to other dialects, from Windows 10 PC #687

Open bubbleguuum opened 2 years ago

bubbleguuum commented 2 years ago

While testing download speed of large files, I noticed that 3.1.1 dialect is 2x slower than all other dialects (including 3.0.2) That's from a Windows 10 PC, 21H2, build 19044.1466.

The config for the client is the default one with just withTransactBufferSize(64 * 1024), which is needed for the 3.1.1 dialect to work at all. I tested that using this same buffer size with the other dialects has no impact on their download speeds.

The file are accessed via:

 File file  = diskShare.openFile(absolutePath,
                    EnumSet.of(AccessMask.FILE_READ_DATA),
                    EnumSet.of(FileAttributes.FILE_ATTRIBUTE_NORMAL),
                    EnumSet.of(SMB2ShareAccess.FILE_SHARE_READ),
                    SMB2CreateDisposition.FILE_OPEN,
                    EnumSet.noneOf(SMB2CreateOptions.class));
file.read(outputStream);

The only workaround for now I've found is to disable 3.1.1 dialect in the config:

withDialects(SMB_3_0_2, SMB_3_0, SMB_2_1, SMB_2_0_2)

This issue does not happen when I do the same test from my Samba Server (I checked it uses 3.1.1).

hierynomus commented 2 years ago

Not sure, I understand exactly, but I think your scenario is the following:

If you connect to a Windows 10 SMB Server, you're getting a drop in speed if you use dialect 3.1.1? The main difference between 3.1.1 and all other dialects is that it will encrypt traffic. As you're not seeing this drop when connecting to a *nix Samba server using the same client, I'm guessing that the server is slower to respond in the case of Windows 10.

bubbleguuum commented 2 years ago

If you connect to a Windows 10 SMB Server, you're getting a drop in speed if you use dialect 3.1.1?

Correct. I get about 3MB/s with 3.1.1 vs 6-7MB/s with all other dialects. Only on the Windows 10 server.

Does 3.1.1 encryption always take effect even if the config has withEncryptData(false) (which is the default) ?

The Windows 10 PC and the machine running the Samba server have comparable CPUs in term of speed.

hierynomus commented 2 years ago

Your best bet would be to see where the slowdown is by enabling trace logging. SMBJ then logs the time it took and the time to response