MX-Tweak Feature Request: User cache in RAM

Report Bugs, Issues and non- package Requests
Message
Author
User avatar
agnivo007
Posts: 720
Joined: Mon May 04, 2020 11:39 pm

MX-Tweak Feature Request: User cache in RAM

#1 Post by agnivo007 »

Users may find this particularly useful for installations on SSD/SD/Flash media to prevent excessive writes, especially when web browsers are used.
Also, it helps keep /home directory slim, better app response times and aids housekeeping.

[X]Checkbox : User cache in RAM (warning: contents cleared on every boot)
Creates /home/user/.xsessionrc file as:

Code: Select all

export XDG_CACHE_HOME=/dev/shm/$(whoami)
mkdir -p /dev/shm/$(whoami)
chmod 700 /dev/shm/$(whoami)
export XDG_RUNTIME_DIR=$XDG_CACHE_HOME
- Roy, Kolkata, IN. "REDUCE-REUSE-RECYCLE-REPURPOSE"
MX-21-AHS-KDE on [ H110M-H : Modded BIOS | Core i3-9350K | 8GB DDR4 | SP A60 NVMe PCIe3x4 | Samsung Evo 870 SSD | WD Black Mobile HDD ]

User avatar
dolphin_oracle
Developer
Posts: 22798
Joined: Sun Dec 16, 2007 12:17 pm

Re: MX-Tweak Feature Request: User cache in RAM

#2 Post by dolphin_oracle »

one directory on the file system does that replace?
http://www.youtube.com/runwiththedolphin
lenovo ThinkPad X1 Extreme Gen 4 - MX-23
FYI: mx "test" repo is not the same thing as debian testing repo.
Live system help document: https://mxlinux.org/wiki/help-antix-live-usb-system/

User avatar
fehlix
Developer
Posts: 12944
Joined: Wed Apr 11, 2018 5:09 pm

Re: MX-Tweak Feature Request: User cache in RAM

#3 Post by fehlix »

according to XDG Base Directory Specification
$XDG_CACHE_HOME defines the base directory relative to which user specific non-essential data files should be stored. If $XDG_CACHE_HOME is either not set or empty, a default equal to $HOME/.cache should be used.
The question remains whether an app do respect this specification.

User avatar
fehlix
Developer
Posts: 12944
Joined: Wed Apr 11, 2018 5:09 pm

Re: MX-Tweak Feature Request: User cache in RAM

#4 Post by fehlix »

agnivo007 wrote: Sat Aug 29, 2020 12:56 am Users may find this particularly useful for installations on SSD/SD/Flash media to prevent excessive writes, especially when web browsers are used.
Also, it helps keep /home directory slim, better app response times and aids housekeeping.

[X]Checkbox : User cache in RAM (warning: contents cleared on every boot)
Creates /home/user/.xsessionrc file as:

Code: Select all

export XDG_CACHE_HOME=/dev/shm/$(whoami)
mkdir -p /dev/shm/$(whoami)
chmod 700 /dev/shm/$(whoami)
export XDG_RUNTIME_DIR=$XDG_CACHE_HOME
I'm not sure about this one:

Code: Select all

export XDG_RUNTIME_DIR=$XDG_CACHE_HOME
b/c XDG_RUNTIME_DIR is already set to /run/user/$UID

User avatar
dolphin_oracle
Developer
Posts: 22798
Joined: Sun Dec 16, 2007 12:17 pm

Re: MX-Tweak Feature Request: User cache in RAM

#5 Post by dolphin_oracle »

there are some items in .cache that persist across reboots, including the fontcache, and even more if a user uses flatpaks.

in particular the fontcache would need rebuilt every boot if the cache were moved to ram, or things will not look correctly.
http://www.youtube.com/runwiththedolphin
lenovo ThinkPad X1 Extreme Gen 4 - MX-23
FYI: mx "test" repo is not the same thing as debian testing repo.
Live system help document: https://mxlinux.org/wiki/help-antix-live-usb-system/

User avatar
agnivo007
Posts: 720
Joined: Mon May 04, 2020 11:39 pm

Re: MX-Tweak Feature Request: User cache in RAM

#6 Post by agnivo007 »

I have been using the above code for weeks now and zero problems on Firefox, Opera and Brave browsers which thrash disk cache a lot.
And yes, logged-in sessions seems to persist too after reboot, the apps above seem to honor the XDG envs.

Deleted /home/user/.cache after putting in .xsessionrc and it works as no files are created anymore in that folder but in /dev/shm/user/

Image
Last edited by agnivo007 on Sat Aug 29, 2020 12:16 pm, edited 2 times in total.
- Roy, Kolkata, IN. "REDUCE-REUSE-RECYCLE-REPURPOSE"
MX-21-AHS-KDE on [ H110M-H : Modded BIOS | Core i3-9350K | 8GB DDR4 | SP A60 NVMe PCIe3x4 | Samsung Evo 870 SSD | WD Black Mobile HDD ]

User avatar
agnivo007
Posts: 720
Joined: Mon May 04, 2020 11:39 pm

Re: MX-Tweak Feature Request: User cache in RAM

#7 Post by agnivo007 »

fehlix wrote: Sat Aug 29, 2020 7:47 am b/c XDG_RUNTIME_DIR is already set to /run/user/$UID
What I posted was not distro specific, so if that is the case with MX, it can be omitted...
- Roy, Kolkata, IN. "REDUCE-REUSE-RECYCLE-REPURPOSE"
MX-21-AHS-KDE on [ H110M-H : Modded BIOS | Core i3-9350K | 8GB DDR4 | SP A60 NVMe PCIe3x4 | Samsung Evo 870 SSD | WD Black Mobile HDD ]

SwampRabbit
Posts: 3602
Joined: Tue Jun 14, 2016 2:02 pm

Re: MX-Tweak Feature Request: User cache in RAM

#8 Post by SwampRabbit »

agnivo007 wrote: Sat Aug 29, 2020 12:07 pm IDeleted /home/user/.cache after putting in .xsessionrc and it works as no files are created anymore in that folder but in /dev/shm/user/
I think this is a cool suggestion with possibilities.

Out of curiosity, how long have you gone without rebooting?

Have you checked a few times to see how large /dev/shm/user/ is getting after a day or two of use?

Asking because I think this option has uses, but it could be bad for many users with limited RAM, and users who don't pay attention to warnings like what you smartly included lol.

I think saving flash media (SD cards/USBs, etc) from getting thrashed would be good, SSDs... maybe older ones, but the newer ones, they can take a huge beating.
NEW USERS START HERE FAQS, MX Manual, and How to Break Your System - Don't use Ubuntu PPAs! Always post your Quick System Info (QSI) when asking for help.

User avatar
fehlix
Developer
Posts: 12944
Joined: Wed Apr 11, 2018 5:09 pm

Re: MX-Tweak Feature Request: User cache in RAM

#9 Post by fehlix »

I'd probably go in the direction and set for those apps, cache usage:
E.g for firefox I do allow only ram-cache, nothing written into the cache folder:
ff_about-cache.png
for those chromium based, apps I'd also use some flags like

Code: Select all

--disk-cache-dir=/run/shm/vivaldi 
--disk-cache-dir=/run/shm/brave
--disk-cache-dir=/run/shm/chromium
etc.
This would avoid any other stuff like fontconfig cache or thumbnails needs to be rebuild after every reboot,
or in case of fonconfig probably not available. So some fonts might get not displayed properly.
You do not have the required permissions to view the files attached to this post.

Post Reply

Return to “Bugs and Non-Package Requests Forum”