Bug 424073

Summary: Slow start on automounted home
Product: [Applications] kate Reporter: Klaus Vink Slott <klaus>
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED INTENTIONAL    
Severity: minor CC: christoph
Priority: NOR    
Version First Reported In: 18.12.3   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Klaus Vink Slott 2020-07-10 15:54:58 UTC
SUMMARY
Searches /home for files triggers automounter which causes slow startup

STEPS TO REPRODUCE
1. configure or test on a system using automount for /home
2. start kate 

OBSERVED RESULT
Extract from using strace:
17:09:01.751209 openat(AT_FDCWD, "/dev/tty", O_RDONLY) = 12
17:09:01.751243 getcwd("/home/klaus", 4096) = 12
17:09:01.751283 lstat("/home", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
17:09:01.751313 lstat("/home/klaus", {st_mode=S_IFDIR|0710, st_size=8192, ...}) = 0
17:09:01.751353 stat("/home/klaus/.kateproject", 0x7fffe2994d30) = -1 ENOENT (No such file or directory)
17:09:01.751385 stat("/home/klaus/.git", 0x7fffe2994cf0) = -1 ENOENT (No such file or directory)
17:09:01.751416 stat("/home/klaus/.svn", 0x7fffe2994cf0) = -1 ENOENT (No such file or directory)
17:09:01.751446 stat("/home/klaus/.hg", 0x7fffe2994cf0) = -1 ENOENT (No such file or directory)
17:09:01.751481 stat("/home", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
17:09:01.751512 lstat("/home", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
17:09:01.751544 stat("/home/.kateproject", 0x7fffe2994d30) = -1 ENOENT (No such file or directory)
17:09:04.994289 stat("/home/.git", 0x7fffe2994cf0) = -1 ENOENT (No such file or directory)
17:09:08.263022 stat("/home/.svn", 0x7fffe2994cf0) = -1 ENOENT (No such file or directory)
17:09:11.522903 stat("/home/.hg", 0x7fffe2994cf0) = -1 ENOENT (No such file or directory)
17:09:14.774833 stat("/", {st_mode=S_IFDIR|0755, st_size=174, ...}) = 0
17:09:14.774890 stat("/.kateproject", 0x7fffe2994d30) = -1 ENOENT (No such file or directory)
17:09:14.774937 stat("/.git", 0x7fffe2994cf0) = -1 ENOENT (No such file or directory)
17:09:14.774967 stat("/.svn", 0x7fffe2994cf0) = -1 ENOENT (No such file or directory)
17:09:14.774995 stat("/.hg", 0x7fffe2994cf0) = -1 ENOENT (No such file or directory)
17:09:14.775040 close(12)               = 0


EXPECTED RESULT
not searching for anything but ~/ 

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
OpenSUSE 15.1
KDE Frameworks 5.55.0
Qt 5.9.7 (bygget imod 5.9.7)
vinduessystemet xcb

ADDITIONAL INFORMATION
I am not sure why kate is looking for .[something] files in /home. But on a system with automounted homedirectories this triggers the automounter to go hunting for something to mount. If this could be avoided it would speed up launch considerably
Comment 1 Christoph Cullmann 2020-07-10 18:30:39 UTC
You can turn off the project plugin, that will avoid this. (this is intentional to find the project valid for the currently launched Kate instance)

But even without that, e.g. other stuff that is typically in home will be seearch, like the .config/* stuff.
Comment 2 Klaus Vink Slott 2020-07-10 18:50:17 UTC
Please allow me a second round to get this confirmed:

Note that I am not talking about users home katalog, eg /home/user/.git These is already mounted and accessible at launch and gives no delay.

But kate is searching for config files outside the current users home eg. /home/.git - I have never seen any software having any configuration files at this location.
Comment 3 Christoph Cullmann 2020-07-10 18:54:12 UTC
Kate will search upwards up to the root. (or at least some levels, e.g. for .kateconfig files, too)

There is no way to blacklist directories and I will not start to add such a feature given there are multiple things that scan upwards.

That in your case this leads to unfortunate delays is not nice, but I see no generic solution for that. (one could think to not span file system borders, but that would be needed to implemented, too)
Comment 4 Klaus Vink Slott 2020-07-10 19:14:38 UTC
Thanks for taking time to answer this although it was not the answer I was hoping for. To me it seems that kate is crippled in a professional environment with automounted user catalogs.
I'll take a look if I can improve the situation by making the automounter ignore . prefixed mountpoints.
Comment 5 Christoph Cullmann 2020-07-11 15:13:56 UTC
Sorry that this makes it not that usable for you.

On the other side, a lot of tools do exactly that to e.g. discover their projects, git will do just the same, just call some git status somewhere, it will search upwards like Kate does to detect if it is inside a project, up to the / (for .git/.git/HEAD/HEAD..)

stat("/home/cullmann/tmp", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/home/cullmann/tmp/.git", 0x7fff51173db0) = -1 ENOENT (No such file or directory)
lstat("/home/cullmann/tmp/.git/HEAD", 0x7fff51173c70) = -1 ENOENT (No such file or directory)
lstat("/home/cullmann/tmp/HEAD", 0x7fff51173c70) = -1 ENOENT (No such file or directory)
stat("/home/cullmann", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
stat("/home/cullmann/.git", 0x7fff51173db0) = -1 ENOENT (No such file or directory)
lstat("/home/cullmann/.git/HEAD", 0x7fff51173c70) = -1 ENOENT (No such file or directory)
lstat("/home/cullmann/HEAD", 0x7fff51173c70) = -1 ENOENT (No such file or directory)
stat("/home", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/home/.git", 0x7fff51173db0)      = -1 ENOENT (No such file or directory)
lstat("/home/.git/HEAD", 0x7fff51173c70) = -1 ENOENT (No such file or directory)
lstat("/home/HEAD", 0x7fff51173c70)     = -1 ENOENT (No such file or directory)
stat("/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/.git", 0x7fff51173db0)           = -1 ENOENT (No such file or directory)
lstat("/.git/HEAD", 0x7fff51173c70)     = -1 ENOENT (No such file or directory)
lstat("/HEAD", 0x7fff51173c70)          = -1 ENOENT (No such file or directory)