https://bugs.kde.org/show_bug.cgi?id=528731
Bug ID: 528731
Summary: Directory listing of FTP folders is very slow (N+1
problem)
Classification: Frameworks and Libraries
Product: frameworks-kio
Version First 6.32.0
Reported In:
Platform: Other
OS: Linux
Status: REPORTED
Severity: normal
Priority: NOR
Component: FTP
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Target Milestone: ---
DESCRIPTION
When I open a folder in FTP in Dolphin, the contents are slow to load because
kio attempts to stat every entry in the directory. When I open a terminal in
that folder, initial startup/cd takes several seconds at the `cd
/run/user/1000/kio-fuse-.../ftp/(ip address)` screen.
STEPS TO REPRODUCE
1. Open Dolphin to ftp://...
2. Press F4 to open embedded terminal.
OBSERVED RESULT
Slow startup.
Due to a bug in https://invent.kde.org/frameworks/kio/-/merge_requests/2402,
when browsing a server supporting MLST/MLSD, `FtpInternal::stat()` calls LIST,
attempts to parse the results as MLSD, fails to find the file, and
`ftpStatAnswerNotFound()` prints "Not found, but assuming found, because some
servers don't allow listing". If I fix it to parse the results as MLSD, then
`maybeEmitStatEntry()` tries to issue a MDTM for every file being statted,
*doubling* the network calls.
Frankly I think this is an obvious N+1 problem, since the initial
`FtpInternal::listDir()` call already returns the modification date of every
file, and if MLSD is enabled, it can tell whether the file is a file or folder,
rendering the subsequent stat() call unnecessary. If LIST is being used, then
it can rely on the access's `d` flag to distinguish files and folders (maybe
not in case of Netware, but that's a legacy codepath at this point). So there
is no need to perform N network calls scanning each file of a folder being
opened.
I tried profiling what `KIOWORKER_DEBUG_WAIT=ftp dolphin` was doing, but Samply
reported bizarre 250ms pauses including in *local* date/filesystem calculations
(apparently it doesn't support sampling what call stack it's blocked on while
off-CPU). Ctrl+C profiling in gdb fingered `FtpInternal::stat` as expected.
EXPECTED RESULT
No N+1 network requests when opening a folder over network. Would this require
changes to Dolphin or kio-fuse's usage of the API? Caching data (until when?)
I'm not sure who invokes Ftp::listDir(). The entirety of Dolphin has only a
single (AI-commented) call to `listDir` (not just KIO::listDir) in directory
size computation, not listing. I tried attaching gdb to Dolphin and
breakpointing `listDir`, but gdb with debuginfod currently crashes so I cannot
do that at the moment.
SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 6.8.2
KDE Frameworks Version: 6.31.0
Qt Version: 6.12.0
Kernel Version: 7.4.0-rc1-1-drm-tip-git-gd11bbfdac0f3 (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-8559U CPU @ 2.70GHz
Memory: 16 GiB of RAM (15.5 GiB usable)
Graphics Processor: Intel® Iris® Plus Graphics 655
Manufacturer: Intel(R) Client Systems
Product Name: NUC8i7BEH
System Version: J72992-303
ADDITIONAL INFORMATION
--
You are receiving this mail because:
You are watching all bug changes.