You are not logged in.

#1 2011-01-22 09:45:35

cdwijs
Member
Registered: 2010-04-24
Posts: 294

use tmpfs/ramdisk to speed up laptop?

Hi All,

I have a laptop with 3 gig of RAM, and a slow harddrive.

Basically I want to cache code, and run data directly, not-cached from the hard drive. For instance, when I use VLC to watch a movie, vlc would be cached in RAM, so it starts instantly, but the movie itself does not need to be cached at all. In fact, it hurts when the movie is cached, because then the movie will push programs out of the cache.

I have 2 partitions on my hard drive, one for data (/home and /storage) and one for the system (all other directories). It would be nice if I can mount /storage with the parameter "don't cache this pratition" I have not yet found such a parameter.

I could use a ramdisk with all my programs in it. This ramdisk will always be in RAM, so also my programs will always in ram. The problem with this approach is that I have 3 gig of ram (so my ramdrive can be 1.5GB), and my programs (/usr) is about 5 GB, so it will not fit.

What would happen when I create a tempfs mountpoint of 5 GB, and copy the entire /usr directory structure in it at boot time? It would require a swap partition of 3.5GB. Will this solution keep the most used programs in RAM, and the rest of the programs in swap, or is this a really stupid idea?

best regards,
Cedric

Last edited by cdwijs (2011-01-22 09:46:10)

Offline

#2 2011-01-22 10:05:10

Ramses de Norre
Member
From: Leuven - Belgium
Registered: 2007-03-27
Posts: 1,289

Re: use tmpfs/ramdisk to speed up laptop?

How do you think to handle writes to /usr? What if packages are updated?
Also, I assume you use some memory for running your programs, which you can't use as a cache.

Normally, Linux quite effectively retains data in memory if there is unused memory.

I personally don't see the benefits of faster startup outweigh the disadvantages of cache consistency problems, but I do have /tmp, /var/tmp, /var/run and /var/lock in RAM, the few directories which can be lost without any headaches.

Offline

#3 2011-01-22 10:18:42

cdwijs
Member
Registered: 2010-04-24
Posts: 294

Re: use tmpfs/ramdisk to speed up laptop?

Ramses de Norre wrote:

Normally, Linux quite effectively retains data in memory if there is unused memory.

This is exactly the problem. linux does not see the difference in data and programs, it tries to keep both in memory. This means that during copying a large amout of data, a lot of programs will be removed from memory. When I then try to start those programs during the copy operation, linux has to get them again from the busy harddrive. This takes a long time.

What I'm trying to figure out is to tell linux to only keep programs in memory as much as possible, and data not.

Best regards,
cedric

Offline

#4 2011-01-22 13:01:49

defears
Member
Registered: 2010-07-26
Posts: 218

Re: use tmpfs/ramdisk to speed up laptop?

Try preload.

Offline

#5 2011-01-22 15:56:49

pankajmore
Member
Registered: 2010-07-06
Posts: 23

Re: use tmpfs/ramdisk to speed up laptop?

defears wrote:

Try preload.

Actually go-preload might be more suitable for his needs. AFAIK , there is no way kernel can distinguish between data and "programs". go-preload uses mpadlock which essentially locks the programs you assign into RAM , so that they cant be swaped. I put my most used programs in go-preload and they always start up instantly since they are essentially locked into memory at boot time.

The problem u are asking for is very real and I also feel there should be a better way. Let other more experienced members come up with their suggestions.

Offline

#6 2011-01-22 17:53:16

cdwijs
Member
Registered: 2010-04-24
Posts: 294

Re: use tmpfs/ramdisk to speed up laptop?

pankajmore wrote:

Actually go-preload might be more suitable for his needs. AFAIK , there is no way kernel can distinguish between data and "programs". go-preload uses mpadlock which essentially locks the programs you assign into RAM , so that they cant be swaped. I put my most used programs in go-preload and they always start up instantly since they are essentially locked into memory at boot time.

go-preload sounds like exactly what I need. Thank you for the suggestion. Would this work correctly when I have, say, firefox locked in ram, and I update firefox (with pacman -Suy)? Or should I re-run StartPreload.sh after everytime I update my system?

Link to go-preload: http://forums.gentoo.org/viewtopic-t-62 … eload.html

Best regards,
Cedric

Offline

#7 2011-02-02 11:44:05

bruce
Member
Registered: 2008-11-27
Posts: 57

Re: use tmpfs/ramdisk to speed up laptop?

If you want to stick with you original idea, could you use a modified version of this technique: http://forums.gentoo.org/viewtopic-t-646289.html ?
(ie compressing /usr enough to fit it in your space restriction? )

Offline

Board footer

Powered by FluxBB