Page 1 of 1

Re: 30mb/s SDHC + Partition = RAM?

Posted: Sat Nov 26, 2011 3:20 pm
by Ampix0
Not that anyone uses this (and I don't know how well it works) but I know on Windows you can use a flashdrive as RAM. I'm sure it's slow and useless.

But out SDHC cards will be incredibly fast, especially the 30mb/s one I bought.

is it at all possible to add to the ram of the r-pi by using a partition of the card as RAM?

Re: 30mb/s SDHC + Partition = RAM?

Posted: Sat Nov 26, 2011 3:51 pm
by kme
You better check your units and learn to use them correctly. 30 milli bit/s? You probably mean 30 Mb/s which isn't anything like 30 MB/s. Caps does matter you know...

Re: 30mb/s SDHC + Partition = RAM?

Posted: Sat Nov 26, 2011 4:13 pm
by gene
He means 30MB/sec. Probably a card like this: http://amazon.com/gp/product/B003EGBHHW/

The SD card slot goes through the USB controller, if I'm not mistaken. It would be incredibly slow for using as RAM.

Re: 30mb/s SDHC + Partition = RAM?

Posted: Sat Nov 26, 2011 4:15 pm
by tufty
You will probably be restricted (at least) by the drivers. There have been problems even with certain class 10 cards buggerating Linux's MMC stack (possibly down to the firmware on the cards themselves misbehaving), and I don't know if much testing has been done with cards faster than that. On top of that is the possibility you won't be able to clock the hardware fast enough to get 30MB/s.

Re: 30mb/s SDHC + Partition = RAM?

Posted: Sat Nov 26, 2011 4:31 pm
by jojopi
All modern operating systems implement virtual memory, where they use part of the hard disk as swap space. The OS can allocate more memory to applications than there is RAM, by paging the less recently used data in and out of swap. If you run too many applications at once then swapping becomes very slow, but it is usually better than programs crashing with "out of memory" errors.

So yes, the RasPi will use part of the SD card as swap space.

Incidentally, SDHC is not as fast as a hard disk for continuous transfers -- modern drives will do well over 100MByte/s. But the access time (latency) on flash storage can be better due to the lack of moving parts. That is why Windows allows you to swap to flash.

It remains to be seen what the performance of RasPi's SD slot will be like. But any kind of swapping is always much slower than having more RAM.

Re: 30mb/s SDHC + Partition = RAM?

Posted: Sat Nov 26, 2011 4:59 pm
by Chris Tyler
It's been said that swapping hard to SD and crashing are virtually indistinguishable.

Re: 30mb/s SDHC + Partition = RAM?

Posted: Sat Nov 26, 2011 5:00 pm
by kme
Quote from Chris Tyler on November 26, 2011, 16:59
It's been said that swapping hard to SD and crashing are virtually indistinguishable.+1!

Re: 30mb/s SDHC + Partition = RAM?

Posted: Sat Nov 26, 2011 5:28 pm
by obarthelemy
Windows *doesn't* use SD cards as RAM. It can do 3 things with Flash RAM, usually on a USB stick rather than a SD:
- ReadyBoost, which is a permanent cache of small OS and frequently run applications files; Windows takes advantage of Flash RAM's low latency to copy small files there, and speed up boot and application launch. Depends on picking the right files: small, read not written...
- Swap file, which is really, better on a mecanical HD
- Hibernation file, also better on a HD unless you want to go to sleep slowly and wake up faster.

Most worthy of the 3 is ReadyBoost, but even that is kinda marginal. Linux has no equivalent of it, except when using ZFS I've been told. ZFS is a heavy-duty filesystem that makes little sense in the Pi.

Re: 30mb/s SDHC + Partition = RAM?

Posted: Sat Nov 26, 2011 8:26 pm
by dattaway
There are a few ways to do it, but here is one way to make a 1GB swap file assuming your filesystem is on the sd card:

dd if=/dev/zero of=/root/myswapfile bs=1M count=1024
mkswap /root/myswapfile
swapon /root/myswapfile

Instant 1GB ram! (virtual memory) It works, but I have found sd writes are rather slow.

Re: 30mb/s SDHC + Partition = RAM?

Posted: Sun Nov 27, 2011 4:17 pm
by Ampix0
Quote from dattaway on November 26, 2011, 20:26
There are a few ways to do it, but here is one way to make a 1GB swap file assuming your filesystem is on the sd card:

dd if=/dev/zero of=/root/myswapfile bs=1M count=1024
mkswap /root/myswapfile
swapon /root/myswapfile

Instant 1GB ram! (virtual memory) It works, but I have found sd writes are rather slow.
A regular SD card yes. But what about a Class 10 card? That is a minimum of 10Mb/s that seems to be like it would suffice just fine.

Re: 30mb/s SDHC + Partition = RAM?

Posted: Mon Nov 28, 2011 12:43 pm
by gordan
The whole "Class 10" and umpteen MB/s alleged transfers are pure specmanship.
(specmanship, n.: The art of using misrepresentation and half-truths for purposes of marketing.)

Yes, you CAN, theoretically, see 10MB/s of writes - if they are sequential, and the card is new and unused, using a FS designed specifically to be good at sequential operations and nothing else (e.g. FAT). In practice, however, even that is unlikely after he card has been churned a bit. And yes, you will get 1000+ of random-read IOPS.

However, even on the festest Class 10 SD cards from the best manufacturers (SanDisk, Lexar, Kingston), you will get maybe up to as much as 20 random-write IOPS (hint: an ancient 5400rpm can do about 100 IOPS, read or write, so a SD card is about 5x slower on writes).

The slow writes will make the general percieved performance of using an SD card quite painful. It's workable - if you optimize your ext* fs for the card, and you LD_PRELOAD libeatmydata.so (eats fsyncs), and you put all the write-heavy stuff that doesn't need to be persisted across reboots on tmpfs (/tmp, /var/tmp, /var/cache/yum, /var/lib/yum, possibly even /var/log and a few other things, e.g. $HOME/.mozilla/firefox/.../cache). Coupled with zram and zcache, that makes for a reasonably usable system (although 256MB of RAM is going to be somewhat crippling for serious use of a R-Pi - small RAM and slow disk are not a good combination).

I use SD cards for primary disk storage on my SheevaPlugs, AC100s, DreamPlugs and Genesi Efika and the performance is quite acceptable - but all of those have 512MB of RAM. This is one of the reason I am moving over to newer Dream/Sheeva/Guru Plugs - eSATA + SSD combo makes for a system that feels as responsive as a full fat x86 desktop. Granted, by disabling tmpfs backing for the scratch space you will hammer your flash more, but it's the price you pay for having a big more breathing room out of tiny RAM.

Re: 30mb/s SDHC + Partition = RAM?

Posted: Mon Nov 28, 2011 3:22 pm
by Dagger
That's why you don't buy a Class 10 card.

I've been looking at benchmarks, and it looks like most Class 10 cards get something like 30 kB/s random write speeds (7.5 IOPS -- about 133ms per I/O!), which is indeed much slower than any hard drive. However, there are some cards that get around 1 MB/s (~250 IOPs); these seem to all be Class 2 or 4 cards, so if you're just going to buy a random card without looking at benchmarks, you'll have better luck getting a suitable one by restricting yourself to Class 4.

For reference, see http://img30.imageshack.us/img.....1at120.png (taken from http://forums.whirlpool.net.au.....?t=1582172) and http://forum.xda-developers.co.....tcount=144.

Re: 30mb/s SDHC + Partition = RAM?

Posted: Mon Nov 28, 2011 8:44 pm
by Svartalf
Quote from Ampix0 on November 27, 2011, 16:17
A regular SD card yes. But what about a Class 10 card? That is a minimum of 10Mb/s that seems to be like it would suffice just fine.

Heh... Sort of. RAM speed's still much higher than that class of SD card.