zlatinb / muwire

MuWire file sharing client for I2P
GNU General Public License v3.0
192 stars 27 forks source link

MuWire more than 10K inotify watches count is OK? #120

Closed slrslr closed 2 years ago

slrslr commented 2 years ago

Hello, by running wget https://raw.githubusercontent.com/fatso83/dotfiles/master/utils/scripts/inotify-consumers -c -O -|bash i have found that

the process

/usr/lib/jvm/java-11-openjdk-amd64/bin/java -Djava.util.logging.config.file=logging.properties -XX:+HeapDumpOnOutOfMemoryError -XX:+ExitOnOutOfMemoryError ... (likely muwire)

is marked to use more than 10 thousand inotify watches (it is used once library indexing finish - 200K files). Anotgher TOP3 processes are: Darkmx 8200, fopnu 8900, rhythmbox player 2300. Others are very low watches. Total usage hitting the limit of around 30K where the default Linux OS limit is 8192...

I have seen some inotify related issues so i wanted to ask if this value is normal or can cause issues or if SW can be adjusted so the usage is reduced?

Linux open jdk 11 MW 0.8.10

zlatinb commented 2 years ago

MW registers an inotify with every directory that is fully shared - that is, the directory itself was shared, not just all files in it. It does that in order to detect newly added or removed files from the library. So if you have that many shared directories you would have that many inotify watches.

At the moment it is possible to manually remove the watch, but you need to do that for each directory separately in Tools->Advanced Sharing->click on directory->Configure->uncheck Auto watch. I can probably make the process easier by allowing multiple selection on that table, and I can add a global setting whether to automatically watch directories.

I haven't received any complaints related to the high number of inotify yet; let me know if you want me to add those features.

slrslr commented 2 years ago

Thank You and sorry for bothering.

I do no not understand these things, and on https://unix.stackexchange.com/questions/13751/kernel-inotify-watch-limit-reached they say that if 500K watchers are used, it takes "only" 512MB of unswappable kernel memory. So it does not seem to be a big deal when i have just 10K used by MW.

I will likely just keep "fs.inotify.max_user_watches" kernel value higher than default as it appeared to trigger some warnings as linked earlier. Thank you and all the best to you.

zlatinb commented 2 years ago

Hi, in the recent commits referenced above I added the ability to configure whether a shared folders is watched from the library menu. If you build from source, you will be able to right-click on a shared folder, select Configure and from there turn off auto-watching for all subfolders. That way you can get rid of all the iNotify watches if you wish to do so.