https://bugs.winehq.org/show_bug.cgi?id=54933
Bug ID: 54933 Summary: Wine slow on certain fuse filesystems, with fix Product: Wine Version: 8.8 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: ntdll Assignee: wine-bugs@winehq.org Reporter: hwertz10@gmail.com Distribution: ---
Created attachment 74452 --> https://bugs.winehq.org/attachment.cgi?id=74452 CIOPFS speed patch
I found a description of users experiencing slowdowns (even using explorer.exe) on an MTP filesystem, and I experienced similar slowdowns on an s3ql filesystem. In short, even using explorer on certain filesystems is slow, and opening programs that open up more than a handful of files is very slow off these filesystems.: https://forum.winehq.org/viewtopic.php?t=36400
I found the root cause courtesy of strace -- in dlls/ntdll/unix/file.c in get_dir_case_sensitivity_stat (which is called very frequently, I think on any file open or creation, among others), there is a fstatat system call, then a check on that result to see if the filesystem is a FUSE filesystem, then if it is it looks for a .ciopfs directory (because presumably CIOPFS -- Case Insensitive On Purpose Filesystem -- places a .ciopfs in every directory specifically so wine can do this test.) It turns out the fstatat call gets used and free inode count, used and free disk space, etc. along with filesystem type, and on my large s3ql filesystem at least this takes *8/10ths* of a second, versus the .ciopfs lookup being in dentry cache -- I don't recall if it used 0.0001 or 0.00001 seconds, but either way extremely fast compared to the other call.
Reversing the order of these calls (check for .ciopfs first, then if it's there run fstatat and check result to see if it's a FUSE filesystem) should not cause a performance regression on any filesystem (since it's usually going to be out of the dentry cache) while avoiding this slowdown on a filesystems with slow filesystem stats.
Just a note, I see the equivalent "is filesystem case sensitive?" check for MacOS actually only runs any tests once then caches the results; using a similar "case sensitivity" cache for Linux would also be effective (since it would only run this piece of code once per wine run then.)
Finally, I wonder if CIOPFS is actually used? I see the last update on it is from 2011, it may have turned out that Wine's case insensitivity support is fast enough that CIOPFS did not prove useful. If it's not actually being used by anyone, removing the CIOPFS tests from file.c could be a reasonable thing to do.
Please find attached a small patch to implement this change for Linux -- it simply reverses the order of 3 lines of code, so it runs the (fast) .ciopfs directory existence test first, then only runs the (on some filesystems much slower) fstatat call and "is it FUSE filesystem?" test if the.ciopfs directory actually exists.
Thanks, and keep up the good work!!! --Henry
https://bugs.winehq.org/show_bug.cgi?id=54933
--- Comment #1 from Henry Wertz hwertz10@gmail.com --- Just to add, I recently upgrades to s3ql-5.0.0 and it has a statfs cache (it stores the results for 30 seconds). The comment in the code says VSCode repeatedly makes statfs calls and it was put in to speed that up; but it's equally effective at speeding up wine's continuous use of fstatat.