GNOME Bugzilla – Bug 785074
Slow directory listing with gvfs-smb
Last modified: 2018-09-21 18:08:09 UTC
Possibly related to #543640 although I'm seeing about the same thing with "gio list" and ls. Directory enumeration (when running ls, browsing from nautilus etc.) is very slow. ls calls lstat on each file. Wireshark shows that gvfs-smb is using SMB2, but does a Create/GetInfo/Close sequence on each lstat() call. ls -l takes 11 seconds for a 500-file directory, gio ls takes 8 seconds but does the same calls. mount.cifs defaults to SMB1 and uses FIND_NEXT2 for lstat and QUERY_PATH_INFO for getxattr. With that, ls takes 100 ms and ls -l takes 3s. mount.cifs -o vers=3.0 uses SMB2_FIND_ID_FULL_DIRECTORY_INFO. With that, ls takes around 80 ms and ls -l around 100 ms, but the difference is probably in the time it takes to display the output.
Looking at initiate_cifs_search() and cifs_filldir() in https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/tree/fs/cifs/readdir.c it seems that the kernel driver preloads the information for the directory entries.
Created attachment 365858 [details] Script to create test file tree for copy performance measurement
I observed the same slowdown. I added a small script that creates a file tree for measuring the performance. Each file is very small. On average, 4 files per seconds are transfered. I saw also numerous redundant SMB2 requests in the tcpdump logs (altough, that test eas done with gvfs-fuse). Gvfs checks if the file is a directory, gets all the meta info, does that for every directory from the mount base to the file, if the file already exists it create a temporary file and move the file once the transfer is done. Each of these request takes 7ms to complete on my file server and these delays add up quickly.
GVfs won't ever be equally fast as CIFS kernel client. But "gio copy" can approximate to speed of smbclient. How fast is "smbclient -c ls" in comparison to "gio copy"? We can't do much with redundant requests from clients FUSE...
This issue wasn't about the overhead of FUSE, but about the protocol implementation. I think the kernel driver prefetches information about the directory contents when it open, and then returns the cached results. Or this is what I remember, at least. GVfs is much more chatty. > How fast is "smbclient -c ls" in comparison to "gio copy"? If you meant "gio list": gio list [...] 0.09s user 0.01s system 0% cpu 1:12.21 total smbclient [...] 0.07s user 0.01s system 16% cpu 0.483 total on the same directory of ~3200 files.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gvfs/issues/306.