Felix E. Klee
2025-Sep-10 12:25 UTC
[Samba] How to speed up small file writes? (WSL2 / Windows)
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.
I know WSL2 has built-in cross-platform file access via 9P. However,
performance there is not great either, and eventually I would like to
migrate from WSL2 to Linux in Hyper-V. NFS would be an alternative to
Samba, but an earlier test showed very bad small file performance as
well.
Additional details:
* `smbd --version`:
Version 4.21.4-Ubuntu-4.21.4+dfsg-1ubuntu3.4
* `/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
[share]
path = /home/felix/tmp
read only = no
browseable = yes
force user = felix
create mask = 0644
directory mask = 0755
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