Ampix0
Posts: 94
Joined: Sat Oct 22, 2011 3:03 am

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

Sat Nov 26, 2011 3:20 pm

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?

kme
Posts: 448
Joined: Sun Sep 04, 2011 9:37 am

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

Sat Nov 26, 2011 3:51 pm

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...

gene
Posts: 3
Joined: Sat Nov 26, 2011 4:07 pm

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

Sat Nov 26, 2011 4:13 pm

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.

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

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

Sat Nov 26, 2011 4:15 pm

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.

User avatar
jojopi
Posts: 3084
Joined: Tue Oct 11, 2011 8:38 pm

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

Sat Nov 26, 2011 4:31 pm

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.

Chris Tyler
Posts: 70
Joined: Thu Jul 28, 2011 12:16 pm
Contact: Website

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

Sat Nov 26, 2011 4:59 pm

It's been said that swapping hard to SD and crashing are virtually indistinguishable.

kme
Posts: 448
Joined: Sun Sep 04, 2011 9:37 am

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

Sat Nov 26, 2011 5:00 pm

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!

obarthelemy
Posts: 1399
Joined: Tue Aug 09, 2011 10:53 pm

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

Sat Nov 26, 2011 5:28 pm

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.

dattaway
Posts: 20
Joined: Tue Nov 15, 2011 11:41 pm

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

Sat Nov 26, 2011 8:26 pm

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.

Ampix0
Posts: 94
Joined: Sat Oct 22, 2011 3:03 am

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

Sun Nov 27, 2011 4:17 pm

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.

gordan
Posts: 11
Joined: Mon Nov 28, 2011 12:10 pm

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

Mon Nov 28, 2011 12:43 pm

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.

Dagger
Posts: 6
Joined: Sun Nov 13, 2011 1:26 pm

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

Mon Nov 28, 2011 3:22 pm

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.

Svartalf
Posts: 596
Joined: Fri Jul 29, 2011 6:50 pm

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

Mon Nov 28, 2011 8:44 pm

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.

Return to “Other projects”