SMBD process goes 100% and copy speed collapse, ARC request demand metadata issue ?

Nicolas_Studiokgb

Contributor
Joined
Aug 7, 2020
Messages
130

This is latest experimental build with 4.15 if you feel like taking it for a spin ixnas:dirent_optimization = true is the parameter to enable the fast-path for dir listing (though it only helps marginally for extremely pathological cases - like 200K files in a dir on MacOS). I still have some cleanups to do before merge for U5 (where it will be off-by-default till there is enough testing).
So first test with default mac settings


107GB 16k Copy 13h11>>13h16 =5min (same as before)
Browsing : fine 2 sec to open a folder (about 2,5 files) (same as before)
Delete : 13h22>>13h26 = 4 minutes (Pic à 15M) smbd 70% (1minute less)

Main difference : only 15M in ARC demand metadata and a clearly larger ARC demand data (about 400k instead of almost nothing in all previous tests)

1684236721492.png


I'll try disabling apple extensions just to have an idea.

Thanks
 
Last edited:

Nicolas_Studiokgb

Contributor
Joined
Aug 7, 2020
Messages
130

This is latest experimental build with 4.15 if you feel like taking it for a spin ixnas:dirent_optimization = true is the parameter to enable the fast-path for dir listing (though it only helps marginally for extremely pathological cases - like 200K files in a dir on MacOS). I still have some cleanups to do before merge for U5 (where it will be off-by-default till there is enough testing).
Tested with Apple extensions disabled :

107GB 16k Copy 15h18>>15h22 =4 min (faster)
Browsing : fine 2 sec to open a folder (about 2,5 files) (same)
Delete : 15h27>>15h29.30 = 2min30s minutes (arc metadata top à 15M / arc data less than 10k) (really faster)

Question : do we really need apple extensions with apple client ? performance is way better without.

1684243937227.png
 

Nicolas_Studiokgb

Contributor
Joined
Aug 7, 2020
Messages
130
No. They are off by default for a reason. The only time you must have them enabled is if you have time machine shares.
Ah ok
Let's go this way so

So do we need "fruit" optimizations if Apple Ext are disabled ? (fruit:streamname_optimization=true for example)

Thanks
 

tiberiusQ

Contributor
Joined
Jul 10, 2017
Messages
190
No. They are off by default for a reason. The only time you must have them enabled is if you have time machine shares.

The help text says: " These protocol extensions can be used by macOS to improve the performance and behavioral characteristics of SMB shares. This is required for Time Machine support "

That's why people enable them, including me ;-(
 

Nicolas_Studiokgb

Contributor
Joined
Aug 7, 2020
Messages
130
No. They are off by default for a reason. The only time you must have them enabled is if you have time machine shares.
Hello @anodos , hope you're fine.

Did you release some more test version I can work on to optimize our apple smb networking case ?

Thanks a lot for your time.
 

Nicolas_Studiokgb

Contributor
Joined
Aug 7, 2020
Messages
130
Hi All
Hi @anodos

I was comparing today with our installed Winserver 2008R2 in smb (LSI hardware Raid 5 8x8tbsata)
I'm connected Gigabit to this one so copy time is not the point but delete time is clearly faster
it's about 1m15sec to delete my usual 107GB 16k item.
Browsing is as truenas, (not lightspeed but ok) (8k item / folder)

in comparison on the same old server on AFP (with Acronis file-connect/ExtremZip)
browsing is instantaneaous, I mean no waiting time at all to see folder content
Deleting is way faster (300 files/sec instead of less than 100 in smb) but plagged with error message about file in use (it seams to be recurent with AFP and I didn't investigate as it's over for afp now)

I'll try with afp on truenas and post here asap

thanks
 

awasb

Patron
Joined
Jan 11, 2021
Messages
415
AFP is deprecated. It may work. It may cease to do so any time with any macOS "update".
 

Nicolas_Studiokgb

Contributor
Joined
Aug 7, 2020
Messages
130
Yes
AFP is deprecated. It may work. It may cease to do so any time with any macOS "update".
Yes I completely know that but it's interesting to see that in some aspect this old deprecated tech is faster than newer one. It means that there is also room for improvements as there are no reason in the end that SMB wouldn't achieve equal performance
 

Nicolas_Studiokgb

Contributor
Joined
Aug 7, 2020
Messages
130
just tested this morning in afp over truenas and we have the same "faster than SMB" performance.
 

Nicolas_Studiokgb

Contributor
Joined
Aug 7, 2020
Messages
130
No. They are off by default for a reason. The only time you must have them enabled is if you have time machine shares.

Hello @anodos

I saw U5 is out now.

Do we need to manually add
ixnas:dirent_optimization = true
and
fruit:streamname_optimization = true

or do those command are activated by default ?

Thanks for your support
 

tiberiusQ

Contributor
Joined
Jul 10, 2017
Messages
190
Hello @anodos

I saw U5 is out now.

Do we need to manually add
ixnas:dirent_optimization = true
and
fruit:streamname_optimization = true

or do those command are activated by default ?

Thanks for your support
Hi,

Regarding U5. and fruit:streamname_optimization = true
Do I need to add it on a per share basis ?


Thx & Best
Ref. to testparm -s it seems to be necessary to enable it on a per share basis - right ?
If so, I do not understand this :
HISTORICAL NOTE: after positive feedback from early testers this was changed to being enabled by default in 13.0-U5

And what is ixnas:dirent_optimization = true

Can you please clarify @anodos

Thx & Best
 

anodos

Sambassador
iXsystems
Joined
Mar 6, 2014
Messages
9,554
Ref. to testparm -s it seems to be necessary to enable it on a per share basis - right ?
If so, I do not understand this :
HISTORICAL NOTE: after positive feedback from early testers this was changed to being enabled by default in 13.0-U5

And what is ixnas:dirent_optimization = true

Can you please clarify @anodos

Thx & Best
libparm does not show defaults for parametric entries, e.g. "fruit:<x>".

And what is ixnas:dirent_optimization = true
that's an experimental non-default option that basically reduces cost for opening files / listing dirs via SMB. These will improve some situations with clients, but not all. If a client is going to repeatedly open / close every file in a directory repeatedly every time it 'lists' it, e.g. MacOS, then you will always have painful experience when you start putting thousands of files in a dir. You're either going to generate lots of useless load on SMB server or MDS server if you have spotlight.
 

tiberiusQ

Contributor
Joined
Jul 10, 2017
Messages
190
libparm does not show defaults for parametric entries, e.g. "fruit:<x>".


that's an experimental non-default option that basically reduces cost for opening files / listing dirs via SMB. These will improve some situations with clients, but not all. If a client is going to repeatedly open / close every file in a directory repeatedly every time it 'lists' it, e.g. MacOS, then you will always have painful experience when you start putting thousands of files in a dir. You're either going to generate lots of useless load on SMB server or MDS server if you have spotlight.
Thanks for your detailed response !
 

mJh78B

Dabbler
Joined
Apr 2, 2022
Messages
20
I'm also seeing some pretty astonishingly bad performance from a macOS client (Sonoma 14.2.1) to TrueNAS Core 13.0-U6.1. Default settings (no tuneables), but on a Time Machine-capable SMB share.

I'm seeing 100% smbd CPU usage, and am working with a folder containing about 15k files. Simply opening and saving a simple text file to the folder is a multi-second operation.

From the terminal on macOS, I tried moving some of the files to a sub-directory to reduce the file count:
Code:
% mkdir json
% mv *.json json


While this was going on I started researching the speed issue, leading me here. When I came back about half an hour later it had only moved about 300 files. I could literally see network spikes for each file move individually on the Activity Monitor network graph. I cancelled that move and issued the same command locally on the TrueNAS machine which was completed instantaneously.

TrueNAS hardware, which has otherwise easily been capable of saturating a 1Gbit network connection:
CPU: 8x i7-3770, virtualized under Proxmox VE 7.4
RAM: 8GB non-ECC
HDD: 7x 8TB Seagate IronWolf RAIDZ2
NIC: VirtIO
 

simonj

Dabbler
Joined
Feb 28, 2022
Messages
32
I'm also seeing some pretty astonishingly bad performance from a macOS client (Sonoma 14.2.1) to TrueNAS Core 13.0-U6.1. Default settings (no tuneables), but on a Time Machine-capable SMB share.

I'm seeing 100% smbd CPU usage, and am working with a folder containing about 15k files. Simply opening and saving a simple text file to the folder is a multi-second operation.

From the terminal on macOS, I tried moving some of the files to a sub-directory to reduce the file count:
Code:
% mkdir json
% mv *.json json


While this was going on I started researching the speed issue, leading me here. When I came back about half an hour later it had only moved about 300 files. I could literally see network spikes for each file move individually on the Activity Monitor network graph. I cancelled that move and issued the same command locally on the TrueNAS machine which was completed instantaneously.

TrueNAS hardware, which has otherwise easily been capable of saturating a 1Gbit network connection:
CPU: 8x i7-3770, virtualized under Proxmox VE 7.4
RAM: 8GB non-ECC
HDD: 7x 8TB Seagate IronWolf RAIDZ2
NIC: VirtIO
Hi. Here also still the same. Eg. deleting a folder containing many files is an overnight operation from a Mac client on a TrueNAS server. We're doing film post-production. We have accepted that TrueNAS doesn't play well with folders containing many files (image sequences) and Mac clients and settled with using direct attached NVME drives for that and only using the servers for single video files and archiving. This seems not even a TrueNAS problem but a general issue with open source Samba.
What did definitely help a bit is to disable the Apple Extensions.

1704958563079.png


We tried SMB multichannel and that might have improved the situation a bit but not substantially.
Linux clients don't show any of those problems.

iSCSI shares on TrueNAS obviosuly don't show those problems but then there's not shared access. We tested TigerStore, which lets you share iSCSI volumes among clients. This does work well and fast also with image sequences and Mac clients but is a rather complicated setup so we didn't go for it yet.

Seems to be an unsolved problem for now and if you need to work with accessing directories containing many files from Mac clients over SMB on TrueNAS (or any open source server) this will simply not be a viable thing.
 

mJh78B

Dabbler
Joined
Apr 2, 2022
Messages
20
Hi. Here also still the same. Eg. deleting a folder containing many files is an overnight operation from a Mac client on a TrueNAS server. We're doing film post-production. We have accepted that TrueNAS doesn't play well with folders containing many files (image sequences) and Mac clients and settled with using direct attached NVME drives for that and only using the servers for single video files and archiving. This seems not even a TrueNAS problem but a general issue with open source Samba.
What did definitely help a bit is to disable the Apple Extensions.

View attachment 74478

We tried SMB multichannel and that might have improved the situation a bit but not substantially.
Linux clients don't show any of those problems.

iSCSI shares on TrueNAS obviosuly don't show those problems but then there's not shared access. We tested TigerStore, which lets you share iSCSI volumes among clients. This does work well and fast also with image sequences and Mac clients but is a rather complicated setup so we didn't go for it yet.

Seems to be an unsolved problem for now and if you need to work with accessing directories containing many files from Mac clients over SMB on TrueNAS (or any open source server) this will simply not be a viable thing.
Yeah, it really is a shame. I did originally search for discussions about samba, but there seemed to be the most activity on these TrueNAS forums. After looking into it more, as expected, macOS is primarily to blame here I believe.

For my example of moving files, I had a look in Wireshark and though I don't really know much about the SMB protocol, I think the names of the requests make it somewhat clear what's going on and why it's taking so long. So, to move one file from test/1000 to test2/1000 while Finder has the test folder open, macOS asks TrueNAS/samba to do all of the following.

Screenshot 2024-01-11 at 3.56.58 PM.png


Not sure what a single file move should look like in Wireshark, but it really seems like item #36 is all that should be required. However, it makes tons of requests to search for files and get their information from the directories containing thousands of files so that presumably macOS can do its own error checking. When doing this for many files at once, it interleaves these requests, which makes it pretty obvious why smbd is dying (especially the ones asking for pattern *, which return 70kB of data; the rest should boil down to a single stat() syscall). Each SMB2_FIND_ID_BOTH_DIRECTORY_INFO request has the "restart scans" flag set. Not sure what that means but it sounds like it might have something to do with preventing cached results.

Additionally, when you have a directory containing image or audio files, it will try to read from the files visible in the Finder window to load thumbnail information.

When Finder isn't watching the folder, there are about half as many requests, still including tons of requests for metadata.

What's weird is macOS can in some instances handle directories containing huge numbers of files over SMB shares. I just checked and one of my Time Machine sparse bundles has over 400,000 band files in one directory on the same TrueNAS share, which, through internal Time Machine magic, is handled just fine.

I suspect this problem could be addressed via some kind of caching or modification to the way samba handles requests for fruity clients but it doesn't sound like anyone has figured out how to fully fix the performance issues yet (though there were some mentions of a newer samba version being better?).

I had a dumb idea last night since someone said macOS client <-> macOS server works much better. Just virtualize a macOS machine on the same box as TrueNAS, connect them via iSCSI or something, then have macOS be the SMB server. I'm sure there would be no problems with this configuration whatsoever, especially given how easy it is to virtualize macOS...
 

simonj

Dabbler
Joined
Feb 28, 2022
Messages
32
Yeah, it really is a shame. I did originally search for discussions about samba, but there seemed to be the most activity on these TrueNAS forums. After looking into it more, as expected, macOS is primarily to blame here I believe.
Yes. This seems to be a Mac problem. However, Mac servers handle this well and also a QNAP server we had previously worked well with lots of files trough some custom proprietary SMB extension. I guess also specific media servers like the ones from SNS must be customized to work well with Mac clients.

So I assume it would be possible to make Samba work well for Mac clients in high performance media workflows but probably this is too small a niche for TrueNAS devs to really dig into.

For now I guess it is iSCSI, the idea you had with a virtualized Mac Server or a specific media storage server like SNS.
 
Top