graysky2 / profile-sync-daemon

Symlinks and syncs browser profile dirs to RAM thus reducing HDD/SDD calls and speeding-up browsers.
https://wiki.archlinux.org/index.php/Profile-sync-daemon
Other
913 stars 88 forks source link

High i/o load after unit start #345

Open Pheidologeton opened 2 years ago

Pheidologeton commented 2 years ago

I have disabled crashrecovery in psd.conf, but psd still calls find to find crashrecovery in the home folder. Since I have a lot of small files (40+ million) in /home/user, this takes a long time and causes a lot of i/o.

albel727 commented 5 months ago

The person at #318 had the right idea: find should take -maxdepth 1 switch and search for the recovery dirs with the right prefix, i.e. all usages of find should change like

-find "${DIR%/*}" -type d -name '*crashrecovery*' -print0
+find "${DIR%/*}" -maxdepth 1 -type d -name "${DIR##*/}-backup-crashrecovery-*" -print0

This drastically reduces I/O and makes the rm -rf safer, when the backup dir happens to be in $HOME.

graysky2 commented 5 months ago

@albel727 - thanks for pointing that out. Can you please try the latest commit and report back. Seems to work for me with limited testing. Would be nice if someone could test with firefox/multiple profiles.

albel727 commented 5 months ago

I see your latest commit, but I can't test it at this time. I can only say, that I've been running similarly patched version myself and it worked for me too.

The only problem with this commit as it is, is that it worsens another bug, which was mentioned in #318 too. Namely that enforce() forgets to call load_env_for $browser and set the $DIR variable and hence uses some random $DIR, that happened to stuck from some previously invoked function. It almost didn't matter before, because *crashrecovery* pattern was sloppy enough to find most backup dirs anyway. But with the new exact search this is no longer the case and so it will lead to most backup dirs no longer getting removed.

This is easy to fix by just adding the correct load_env_for with a loop over $DIRArr or even by unifying enforce() and cleanup() (the latter is basically the former with $BACKUP_LIMIT = 0).

Compare the wrong code in enforce() https://github.com/graysky2/profile-sync-daemon/blob/9491a03303f85ed31d781e962d82583ade77cacc/common/profile-sync-daemon.in#L589-L590 with the correct code in cleanup() https://github.com/graysky2/profile-sync-daemon/blob/9491a03303f85ed31d781e962d82583ade77cacc/common/profile-sync-daemon.in#L363-L368