Bug 461818 - Excessive use of inotify instances in kate
Summary: Excessive use of inotify instances in kate
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: application (show other bugs)
Version: Git
Platform: Other Linux
: NOR minor
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-14 13:27 UTC by Pozsgay Máté
Modified: 2022-11-26 20:50 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pozsgay Máté 2022-11-14 13:27:39 UTC
SUMMARY
Kate spawns many inotify instances.

STEPS TO REPRODUCE
1. Start Kate
2. Open some project

OBSERVED RESULT
Kate spawns 10-15 inotify instances

EXPECTED RESULT
Kate should limit the inotify instances as the default number of allowed inotify instances per user is 127. Using multiple kate instances can easily use up all the available instances causing numerous problems in other applications.

SOFTWARE/OS VERSIONS
Kate: 22.11.70
Linux/KDE Plasma: Ubuntu 22.04.1 LTS 
(available in About System)
KDE Plasma Version: 5.24.6
KDE Frameworks Version: 5.100.0
Qt Version: 5.13.3

ADDITIONAL INFORMATION
I used the following script to investigate the issue: https://github.com/fatso83/dotfiles/blob/master/utils/scripts/inotify-consumers
Below there is an example of the output. As you can see PyCharm uses 3217 watches, but only a singe instance. This is not a problem, since the max_user_watches limit is quite large (65535).
On the other hand Kate uses 10+ watch instance for the 30+ files. This is a problem, because the max_user_instances limit is only 128 by default. Running 3 kate instance uses up 30% of the available watch instances.

   INOTIFY   INSTANCES
   WATCHES      PER
    COUNT     PROCESS   PID USER         COMMAND
------------------------------------------------------------
    3217         1       19116 pozsgai     /snap/pycharm-professional/306/bin/fsnotifier
      92         4        3188 pozsgai     /lib/systemd/systemd --user
      78         1        3707 pozsgai     /usr/libexec/xdg-desktop-portal-gtk
      77         1        3646 pozsgai     /usr/libexec/xdg-desktop-portal-gnome
      54         4        3731 pozsgai     /usr/bin/kded5
      37        12       80717 pozsgai     /home/pozsgai/projects/kde/build/kde/applications/kate/bin/kate
      36         1        3227 pozsgai     /usr/libexec/tracker-miner-fs-3
      30        13       19236 pozsgai     /home/pozsgai/projects/kde/build/kde/applications/kate/bin/kate
      29        14       28352 pozsgai     /home/pozsgai/projects/kde/build/kde/applications/kate/bin/kate
      28         8        5511 pozsgai     /opt/google/chrome/chrome --enable-crashpad
Comment 1 Christoph Cullmann 2022-11-19 18:12:10 UTC
I guess we should try to share our QFileSystemWatcher instances.
I think the issue is we create one or two per project if I don't read the code wrongly.
Comment 2 Christoph Cullmann 2022-11-19 20:39:41 UTC
https://invent.kde.org/utilities/kate/-/merge_requests/1017
Comment 3 Christoph Cullmann 2022-11-20 18:49:17 UTC
https://invent.kde.org/utilities/kate/-/merge_requests/1019
Comment 4 Christoph Cullmann 2022-11-20 18:51:23 UTC
These two requests shall limit the number of watchers we use a lot.
Comment 5 Christoph Cullmann 2022-11-26 20:50:14 UTC
I think it should work now as intended.