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
910 stars 88 forks source link

why psd not manage .cache? #63

Closed nefelim4ag closed 10 years ago

nefelim4ag commented 10 years ago

I think all browser content must be on ram, may be i mistake? google-chrome writes and uses and uses ~/.cache/google-chrome

graysky2 commented 10 years ago

I have this documented in the man page for psd. Basically, yes, many browsers use ~/.cache/foo for their cache dirs. I do not want to make psd more complicated by having it sync both the profile and the cache dir. There are some workarounds mentioned:

1) Change behavior within the browser 2) Mount ~/.cache to tmpfs in /etc/fstab

Example from my /etc/fstab: tmpfs /home/facade/.cache tmpfs noatime,nodev,nosuid,size=120M 0 0

grossws commented 7 years ago

FTR, on distros with systemd it also can be achieved with unit /etc/systemd/system/home-<username>-.cache.mount:

[Unit]
Description=user cache dir
ConditionPathIsSymbolicLink=!/home/gross/.cache
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target
After=home.mount

[Mount]
What=tmpfs
Where=/home/gross/.cache
Type=tmpfs
Options=mode=0755,strictatime,nosuid,nodev,uid=gross,gid=gross

[Install]
WantedBy=local-fs.target

Of course, gross should be changed to your username (gid should exists), unit filename must be changed also. Written in assumption that /home is on separate partition thus home.mount used in After clause.

Then use systemctl daemon-reload && systemctl enable home-<username>-.cache.mount. Log out from DE/WM, clean ~/.cache and check that systemctl start home-<username>-.cache.mount succeeds before reboot.

parkerlreed commented 6 years ago

At that point isn't .cache going to be wiped? I would assume a browser cache is something you may want to keep between reboots.

EDIT: Since I wanted to see if it worked...

Edited an unused browser and put in my Chrome cache dir as the path.

[parker@gpdpocket browsers]$ pwd
/usr/share/psd/browsers
[parker@gpdpocket browsers]$ cat google-chrome
DIRArr[0]="/home/parker/.cache/google-chrome-beta"
PSNAME="chrome"

And that seems to work fine

[parker@gpdpocket browsers]$ pwd
/usr/share/psd/browsers
[parker@gpdpocket browsers]$ cat google-chrome
DIRArr[0]="/home/parker/.cache/google-chrome-beta"
PSNAME="chrome"
[parker@gpdpocket browsers]$ psd p
Profile-sync-daemon v6.31 on Arch Linux

 Systemd service is currently active.
 Systemd resync-timer is currently active.
 Overlayfs technology is currently inactive.

Psd will manage the following per /home/parker/.config/psd/.psd.conf:

 browser/psname:  google-chrome/chrome
 owner/group id:  parker/1000
 sync target:     /home/parker/.cache/google-chrome-beta
 tmpfs dir:       /run/user/1000/parker-google-chrome
 profile size:    96M
 recovery dirs:   none

 browser/psname:  google-chrome-beta/chrome
 owner/group id:  parker/1000
 sync target:     /home/parker/.config/google-chrome-beta
 tmpfs dir:       /run/user/1000/parker-google-chrome-beta
 profile size:    171M
 recovery dirs:   none

[parker@gpdpocket browsers]$ ls /run/user/1000/parker-google-chrome*
/run/user/1000/parker-google-chrome:
Default

/run/user/1000/parker-google-chrome-beta:
 Avatars                    CertificateRevocation    'Crash Reports'   Dictionaries      'First Run'     NativeMessagingHosts   PepperFlash  'Safe Browsing'   SingletonCookie   SingletonSocket    'Subresource Filter'
 BrowserMetrics-spare.pma   CertificateTransparency   Default          FileTypePolicies  'Local State'   OriginTrials           pnacl         ShaderCache      SingletonLock     SSLErrorAssistant
[parker@gpdpocket browsers]$ ls ~/.cache ~/.config | grep google-chrome
google-chrome-beta
google-chrome-beta-backup
google-chrome-beta
google-chrome-beta-backup
[parker@gpdpocket browsers]$ ls -lah ~/.cache ~/.config | grep google-chrome
lrwxrwxrwx  1 parker parker   35 Feb  1 14:40 google-chrome-beta -> /run/user/1000/parker-google-chrome
drwx------  3 parker parker 4.0K Feb  1 14:38 google-chrome-beta-backup
lrwxrwxrwx  1 parker parker   40 Feb  1 14:40 google-chrome-beta -> /run/user/1000/parker-google-chrome-beta
drwx------ 17 parker parker 4.0K Feb  1 14:40 google-chrome-beta-backup
graysky2 commented 6 years ago

I've scoped this outside of what I want to do with psd. For reference, my ~/.cache has been mounted to tmpfs for a long time now and I have no ill effects.

parkerlreed commented 6 years ago

@graysky2 Ahh cool. Good to know. Thanks a ton for all the work put into this project!

graysky2 commented 6 years ago

you're welcome, rock on

grossws commented 6 years ago

I'll also suggest to limit tmpfs size (by default it can are half of your RAM for .cache). If you're using systemd unit like I posted above, add size=400M (or any size you like) to Options directive. I found 400M more than enough for me, it usually keeps under 200M.

remort commented 3 years ago

Creating a copy of /usr/share/psd/browsers/google-chrome, f.e. /usr/share/psd/browsers/firefox-cache Editing it as follows:

DIRArr[0]="/home/remort/.cache/mozilla/firefox"
PSNAME="firefox-cache"

Adding firefox-cache to /home/remort/.config/psd/.psd.conf as following: BROWSERS="firefox firefox-cache"

Then closing firefox and restarting systemd psd service made the trick for me.

yutayu commented 3 years ago

How about using anyghin-sync-daemon?

Le jeudi 12 novembre 2020 à 04:58:05 UTC+9, remort notifications@github.com a écrit :

Creating a copy of /usr/share/psd/browsers/google-chrome, f.e. /usr/share/psd/browsers/firefox-cache Editing it as follows: DIRArr[0]="/home/remort/.cache/mozilla/firefox" PSNAME="firefox-cache"

Adding firefox-cache to /home/remort/.config/psd/.psd.conf as following: BROWSERS="firefox firefox-cache"

Then closing firefox and restarting systemd psd service made the trick for me.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

parkerlreed commented 3 years ago

Anything works as well but PSD is already running for me. Easier to let one daemon handle everything.

yutayu commented 3 years ago

If you think so , Asd can sync profile . Ask asd all :)

Le vendredi 13 novembre 2020 à 02:00:37 UTC+9, parkerlreed notifications@github.com a écrit :

Anything works as well but PSD is already running for me. Easier to let one daemon handle everything.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

remort commented 3 years ago

Same story. PSD is already in use. SystemD units approach shown above is a killer too by the way. Maybe next time.

yutayu commented 3 years ago

I mean that how about stopping psd and  use asd for profile and all sync.

Le vendredi 13 novembre 2020 à 02:09:46 UTC+9, remort notifications@github.com a écrit :

Same story. PSD is already in use. SystemD units approach shown above is a killer too by the way. Maybe next time.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.