Forum
  • Search
  • Member List
  • Calendar
Hello There, Guest! Login Register — Login with Facebook

[IDEA] Making best use of 512mb Pi with tmpfs
Thank you for your donation

Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode | Linear Mode
Idea: Making best use of 512mb Pi with tmpfs
9th Apr, 2013, 08:06 AM
Post: #1
JayBlanc Offline
Registered
Posts: 20
Joined: Apr 2013
Reputation: 4
Making best use of 512mb Pi with tmpfs
THIS IS DEPRICATED, DO NOT TRY IT.

This will no longer have a beneficial effect with future changes to memory handling and swap space in the next version. I recommend reversing the changes if you made them.

---------------------
Having a recent Rev.B I've modified my xbian set up to make a bit better use of the memory available.

First, I've mounted /tmp as a tmpfs. The defaults are fine because half of hardware memory as the top limit appears okay for the intended use. (Deliberately leaving /var/tmp alone as that may have large files written to it.)

Add the following line to /etc/fstab
Code:
tmpfs   /tmp         tmpfs   nodev,nosuid    0    0

Stopping XBMC, I symlink ~/.xbmc/temp to /tmp/, ~/.xbmc/userdata/addon_data/cache and ~/.xbmc/userdata/addon_data/script.common.plugin.cache to /tmp/, then reboot.

Terminal

sudo /etc/init.d/xbmc stop
rm /home/xbian/.xbmc/temp
ln -s /tmp /home/xbian/.xbmc/temp
rm /home/xbian/.xbmc/userdata/addon_data/cache
ln -s /tmp /home/xbian/.xbmc/userdata/addon_data/cache
rm /home/xbian/.xbmc/userdata/addon_data/script.common.plugin.cache
ln -s /tmp /home/xbian/.xbmc/userdata/addon_data/script.common.plugin.cache

Then create cron.daily script that reaps old files from /tmp/ to try and prevent overflow on a device that is rarely rebooted.

Code:
#!/bin/sh
#/etc/cron.daily/reaptmp

find /tmp/ -type f -mtime +3 -exec rm {} \;

Remember to run chmod a+r on the file so it will run every day. Then reboot.

Benefit: Noticeable responsiveness improvements in addons that create and process temporary files. Particularly ones that process downloaded rss/xml files, or download subtitle files.

Drawbacks: Caches cleared on reboot. But reboots are hopefully uncommon for XBian.

If anything fills /tmp/ with data over ~190mb, it's going to fail. I've yet to see this happen, and I don't know of any xbmc addon that would do this. If you know of a addon that uses creates temporary files over ~190mb, you might want to ask the addon's creator to store these files in a cache in it's addon_data directory. .xbmc/temp/ and common_cache appear to be intended for small temporary files only. tmpfs can be expanded beyond free memory, because it uses swap, but it can never be set above total hardware memory due to memory allocation handling.

There is the minor possibility that this could cause an issue due to file name collisions with something else. I haven't seen this happen on xbian, but it might be worth making a init script that properly creates a unique directory name in /tmp/ and creates the symlinks on boot.
Find all posts by this user
Quote this message in a reply
9th Apr, 2013, 08:52 AM
Post: #2
Koenkk Offline
Registered
Posts: 1,238
Joined: Dec 2012
Reputation: 112
Making best use of 512mb Pi with tmpfs
good idea, but like you already said, we need to make 100% this causes no failures. Therefore it would be nice if people can test this and post their results here.

Please read rules and do a search before you post! . FAQs . How to post log file? . Looking for answers? Please start here
Find all posts by this user
Quote this message in a reply
9th Apr, 2013, 06:15 PM
Post: #3
CurlyMo Offline
Registered
Posts: 3,501
Joined: Dec 2012
Reputation: 202
RE: Making best use of 512mb Pi with tmpfs
I would wait for all the things Matus is implementing because he is already working on better ram usage due to different tmpfs solutions.

pilight - modular domotica solution
Visit this user's website Find all posts by this user
Quote this message in a reply
13th Apr, 2013, 05:19 AM
Post: #4
JayBlanc Offline
Registered
Posts: 20
Joined: Apr 2013
Reputation: 4
RE: Making best use of 512mb Pi with tmpfs
This seems to conflict with the zram improvements that are coming up, and needs to be reverted if you want to take advantage of them without the system bogging down. With zram swap loopback, I'm noticing a great improvement in responsiveness.
Find all posts by this user
Quote this message in a reply
15th Apr, 2013, 02:03 PM
Post: #5
mk01 Offline
Registered
Posts: 2,485
Joined: Mar 2013
Reputation: 209
RE: Making best use of 512mb Pi with tmpfs
despite the changes which are comming, I still like the idea of putting xbmc ./temp and some other caching files into memory.

debian is finally implementing standard linux features (8 years old!!!) like tmpfs shm on it etc - as standard feature.

@JayBlanc specially for this purpose I would choose /run/shm, not /tmp and /tmp I would leave solid. It's ok for you if you knows you system, but general many things can go wrong. /tmp is defined in posix with no limit in size. linux is changing /tmp from permanent to clean on reboot storage, but still no size limit.

feel free to play with /etc/default/tmpfs file, everything is managed via init according to those params.

and if you use mount --bind instead of delete / create symlinks, it will be completely transparent

(fstab records)
/run/shm /home/xbian/.xbmc/temp none bind 0 0
/run/shm /home/xbian/.xbmc/userdata/addon_data/script.common.plugin.cache none bind 0 0

Please read rules and do a search before you post! . FAQs . How to post log file? . Looking for answers? Please start here
Find all posts by this user
Quote this message in a reply
16th Apr, 2013, 02:53 AM
Post: #6
namtih Offline
Tester
Posts: 269
Joined: Dec 2012
Reputation: 28
RE: Making best use of 512mb Pi with tmpfs
Perhaps another idea would be vmtouch:
http://forum.xbian.org/thread-193-post-1783.html#pid1783

I added it to my startup script combined with some paths/files like
Code:
#!/bin/sh

#Preload Files
#touch /home/xbian/.xbmc/userdata/Database/zzstart_`date +%F_%T`
vmtouch -t /home/xbian/.xbmc/userdata/Database
vmtouch -t /home/xbian/.xbmc/userdata/addon_data/script.common.plugin.cache
vmtouch -t /home/xbian/.xbmc/addons/plugin.video.youtube
vmtouch -t /home/xbian/.xbmc/addons/plugin.video.dokumonster
vmtouch -t /home/xbian/.xbmc/addons/plugin.video.imdb.trailers
vmtouch -t /home/xbian/.xbmc/addons/plugin.video.the.trailers
#vmtouch -t /home/xbian/.xbmc/addons/plugin.video.hdtrailers_net-master
vmtouch -t /home/xbian/.xbmc/addons/script.globalsearch
vmtouch -t /usr/local/share/xbmc
vmtouch -t /usr/local/lib/xbmc
vmtouch -t /usr/lib/arm-linux-gnueabihf/gconv/gconv-modules.cache
#vmtouch -t /usr/share/pyload
vmtouch -t /usr/share/python
vmtouch -t /usr/bin/python2.7
vmtouch -t /usr/lib/python2.7
#vmtouch -t /home/xbian/.xbmc/addons/skin.realaskadark/fonts
#vmtouch -t /home/xbian/.xbmc/addons/skin.realaskadark/media/overlays
#vmtouch -t /home/xbian/.xbmc/addons/skin.realaskadark/media/views
vmtouch -t /home/xbian/.xbmc/addons/skin.refocus.big/fonts
vmtouch -t /home/xbian/.xbmc/addons/skin.refocus.big/media/overlays
vmtouch -t /home/xbian/.xbmc/addons/skin.refocus.big/media/views
vmtouch -t /usr/local/share/downloaddaemon
vmtouch -t /usr/local/bin/DownloadDaemon
vmtouch -t /usr/sbin/openvpn
vmtouch -t /etc/downloaddaemon
vmtouch -t /etc/openvpn/ovpn
vmtouch -t /lib/arm-linux-gnueabihf
vmtouch -t /bin/ntfs-3g
#touch /run/zzstop_`date +%F_%T`
exit 0
Find all posts by this user
Quote this message in a reply
21st Jun, 2013, 07:18 AM
Post: #7
JayBlanc Offline
Registered
Posts: 20
Joined: Apr 2013
Reputation: 4
RE: Making best use of 512mb Pi with tmpfs
Just a note that putting .xbmc/temp into a tmpfs absolutely breaks things in rar playback, because rar files get copied there.
Find all posts by this user
Quote this message in a reply
23rd Jun, 2013, 01:22 AM
Post: #8
mk01 Offline
Registered
Posts: 2,485
Joined: Mar 2013
Reputation: 209
RE: Making best use of 512mb Pi with tmpfs
@JayBlanc, you don't have the expansion memory module installed, to provide 8GB of ram? (it is for B model only).

Please read rules and do a search before you post! . FAQs . How to post log file? . Looking for answers? Please start here
Find all posts by this user
Quote this message in a reply
23rd Jun, 2013, 05:44 AM
Post: #9
f1vefour Offline
Administrator
******
Posts: 1,342
Joined: Mar 2013
Reputation: 58
Re: RE: Making best use of 512mb Pi with tmpfs
(23rd Jun, 2013 01:22 AM)mk01 Wrote:  @JayBlanc, you don't have the expansion memory module installed, to provide 8GB of ram? (it is for B model only).

You have a link for this?

Please read rules and do a search before you post! | FAQs | How to post log file? | Can't find an answer? Contact us.
Visit this user's website Find all posts by this user
Quote this message in a reply
« Next Oldest | Next Newest »
Post Reply 


  • View a Printable Version
  • Send this Thread to a Friend
  • Subscribe to this thread
Forum Jump:

Current time: 13th May, 2025, 10:15 PM Powered By MyBB, © 2002-2025 MyBB Group.