Michael Tokarev
2025-Sep-10 13:49 UTC
[Samba] How to speed up small file writes? (WSL2 / Windows)
On 10.09.2025 15:25, Felix E. Klee via samba wrote:> Test data with 7633 scrambled emails, i.e. many small files: > > https://files.f76.eu/samba/2025-09-10+08_test.tgz > > Setup: > > * SMB Guest: Windows 11 Pro x64 > > * SMB Host: Ubuntu running in Linux WSL2 in the above Windows > > => Host and Guest are running on the same hardware. Networking should be > fast. > > My tests: > > 1. Extract the archive on Linux in a local EXT4 mount. That takes less > than eight seconds: > > [felix at felix-x1t3-11 test]$ time tar xfz 2025-09-10+08_test.tgz > > real 0m7.592s > user 0m6.114s > sys 0m3.590s > > 2. Extract the archive on Windows in a local NTFS mount. That takes > less than sixteen seconds: > > PS C:\Users\Felix\Desktop\test> Measure-Command { > >> tar xfz .\2025-09-10+08_test.tgz > >> } > > > Days : 0 > Hours : 0 > Minutes : 0 > Seconds : 15 > Milliseconds : 995 > Ticks : 159958396 > TotalDays : 0.000185137032407407 > TotalHours : 0.00444328877777778 > TotalMinutes : 0.266597326666667 > TotalSeconds : 15.9958396 > TotalMilliseconds : 15995.8396 > > 3. Extract the archive on Windows in the Linux directory from step 1, > mounted by SMB. That takes more than 176 seconds: > > PS Microsoft.PowerShell.Core\FileSystem::\\172.18.61.229\share\ > test> Measure-Command { > >> tar xfz .\2025-09-10+08_test.tgz > >> } > > > Days : 0 > Hours : 0 > Minutes : 2 > Seconds : 56 > Milliseconds : 254 > Ticks : 1762546126 > TotalDays : 0.00203998394212963 > TotalHours : 0.0489596146111111 > TotalMinutes : 2.93757687666667 > TotalSeconds : 176.2546126 > TotalMilliseconds : 176254.6126 > > => Access via Samba is 11 to 22 times slower than native access. It?s > basically unusably slow. I wonder if something can be done to improve > the speed.Please also do another test: windows to a network drive which is run by another windows machine (I dunno if you can do this on a single machine though). When I have to copy large amount of files from one windows machine to another, I usually do it using intermediate tar archive - creating such archive locally, next reading it from another machine extracting there. So it is just one open across network, instead of multiple opens/closes. Or else an operation which - with the help of temorary tar archive like this - increases from several minutes to multiple hours. That to say: windows networking is slow when opening files. Thanks, /mjt
Felix E. Klee
2025-Sep-12 02:01 UTC
[Samba] How to speed up small file writes? (WSL2 / Windows)
On Wed, Sep 10, 2025 at 9:49?PM Michael Tokarev <mjt at tls.msk.ru> wrote:> Please also do another test: windows to a network drive which > is run by another windows machine (I dunno if you can do this on > a single machine though).That?s a great suggestion! It would be possible to test Windows-to-Windows SMB performance with a Windows VM, but I am too lazy to set that up right now. What I did, however, is test extraction speed with the tar file hosted on Windows from Linux: root at felix-x1t3-11:/tmp/test# time tar xfz 2025-09-10+08_test.tgz real 0m38.990s user 0m3.082s sys 0m3.037s I also tried a few more tweaks to the Samba configuration by removing meta data preservation, see below. With that I can get down to 135 seconds: PS Microsoft.PowerShell.Core\FileSystem::\\172.18.61.229\share\test> Measure-Command { >> tar xfz .\2025-09-10+08_test.tgz >> } Days : 0 Hours : 0 Minutes : 2 Seconds : 15 Milliseconds : 199 Ticks : 1351991956 TotalDays : 0.00156480550462963 TotalHours : 0.0375553321111111 TotalMinutes : 2.25331992666667 TotalSeconds : 135.1991956 TotalMilliseconds : 135199.1956 That?s still 3.5 times slower than in the other direction: At least for small file writes, the SMB server built into Windows seems to be considerably faster than Samba! Next I want to try KSMBD. The goal is to get maximum small file write speed. No file meta data needs to be preserved. My current `/etc/samba/smb.conf`: [global] workgroup = WORKGROUP security = user map to guest = Bad User load printers = no disable spoolss = yes strict locking = no use sendfile = yes min receivefile size = 128k socket options = IPTOS_LOWDELAY TCP_NODELAY oplocks = yes aio read size = 1 aio write size = 1 kernel oplocks = no host msdfs = no strict sync = no smb encrypt = disabled ea support = no store dos attributes = no map archive = no nt acl support = no durable handles = no posix locking = no [share] path = /home/felix/tmp read only = no browseable = yes force user = felix create mask = 0644 directory mask = 0755