saving memory with ramdisk -> compressed filesystem with 2.2?

Sep 25, 2003 4 Replies

Hi,



I have a product which boots from a cdrom, using a ramdisk for its root filesystem. This scheme allows for silent operation after boot, and allows the user to remove the CD at run time.



Of course it also uses a good deal of additional RAM, and I'd like to reduce this. For example, a binary running from the the ramdisk takes up memory on the ramdisk itself, the same amount of memory in terms of cached disk reads, and code size plus runtime allocations as a process. I thought perhaps I could reduce one or both of the first two.



Questions:



Can I compress the ramdisk in memory? I was thinking about using cloop e2compr or squashfs on the ramdisk. Any ideas why this wouldn't work conceptually? Practically, has anyone used one of these with the



2.2 kernel? (I'm stuck with it for the time being.)

Alternatively, can I turn off read caching for the ramdisk? Correct me if I'm wrong, but it seems redundant to be caching files in ram when reading them off a ramdisk. I realize that the cached pages will get evicted if memory is running low, but I'd like to avoid the situation where a file read from the ramdisk replaces one read from CD.



Incidentally, just throwing in more RAM isn't an option, as this has to work with existing units in the field.



Thanks, Greg


Are you sure ? From some reading I understand that the RAM FS prevents caching and is able to "load" executables without moving them. But I might be wrong

AFAIK, there are several compressed RAM fine systems (CRAMFS might be another name). But here of course you loose the feature that executable stay in place when loaded. But it helps a lot with certain type of data files.

-Michael

This is true for RAMFS, the RAM _filesystem_, while I believe Greg refers to a RAM _disk_, which is a block device driver. Actually RAMFS (or the newer TMPFS) might be the just what he is looking for, but these are not available in 2.2 series kernels AFAIK.

... plus, CRAMFS is a read-only filesystem.

Obviously, compression and execute-in-place (as with RAMFS) are mutually exclusive things, so it's a tradeoff. Depending on how much of the data lying around in files contains executable code, one or the other would be better.

Rob

Robert Kaiser email: rkaiser AT sysgo DOT de SYSGO AG http://www.elinos.com Klein-Winternheim / Germany http://www.sysgo.de

I would be pleasantly surprised if that were the case, but I don't think it is, at least with the 2.2 series kernel I'm using.

As a demonstration, if I cat files from my ramdisk to /dev/null, the entry for "Cached" under /proc/meminfo goes up by roughly the size of the files in question, and the entry for "MemFree" goes down by the same amount.

Are you talking about a regular ramdisk, or the newer "ramfs" introduced in kernel 2.4? Maybe these features have been added to the ramdisk driver since 2.2?

This is also the first I've heard about execute-in-place from a ramdisk. URLs?

Greg

Thanks, Rob.

It sounds like TMPFS will be a nice solution, but I guess I'll have to wait until we can get things ported to 2.4+.

Greg

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required