maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N900 (https://talk.maemo.org/forumdisplay.php?f=44)
-   -   Using Micro SD Card as Virtual Ram on Nokia N900? (https://talk.maemo.org/showthread.php?t=42357)

mrebanza 2010-01-27 04:22

Using Micro SD Card as Virtual Ram on Nokia N900?
 
On the G1 their is the SuperD Hack that uses some of (or all of) the Video Cards Storage as extra Ram... Is it possible and or has it been done on the N900 and since the biult in 32GB Hard Drive is so big is it possible to use the Micro SD Card as Virtual Ram on Nokia N900? This would make it super fast? :cool:

b666m 2010-01-27 04:35

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
mhm?
from nokia's n900 homepage:

Quote:

Total available application memory up to 1 GB (256 MB RAM, 768 MB virtual memory)
it's already using the card as virtual memory (if needed). maybe it's possible to change the value from 768MB to something else.
but i have to say that 1GB ram is far more than most of us will ever use. ^^
(except you want to calculate PI with many decimal places... xD)

mrebanza 2010-01-27 04:54

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Oh so the 1GB virtual total comes standard on the N900?

If so that's GREAT!

rewt 2010-01-27 05:08

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
For those who need more VM, and wish to use their entire MicroSD card for this purpose:

(WARNING: This will erase the entire MicroSD card, or worse, some or all of your internal memory if you mistype the device name.. If you plan to proceed, I recommend that you have some idea what you are doing)

In x-term:

Code:

sudo gainroot
mkswap /dev/mmcblk1p1
swapon /dev/mmcblk1p1

The last line will have to be rerun each time your device is rebooted, unless you add an init script to run it.

b666m 2010-01-27 05:09

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Quote:

Originally Posted by mrebanza (Post 496812)
Oh so the 1GB virtual total comes standard on the N900?

If so that's GREAT!

jep.
no need to worry about that you're running out of ram too fast. ;)

mrebanza 2010-01-27 10:26

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
@rewt thats freeking great so I can use my 4GB Micro SD as 4GB of RAM!!!!

That is amazing . . . Imagine if I upgraded to 16GB would the system be able to handle all of it?

PS @rewt Thanks for the great info!!!!!!

Rob1n 2010-01-27 10:45

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Quote:

Originally Posted by mrebanza (Post 497125)
@rewt thats freeking great so I can use my 4GB Micro SD as 4GB of RAM!!!!

That is amazing . . . Imagine if I upgraded to 16GB would the system be able to handle all of it?

PS @rewt Thanks for the great info!!!!!!

4G of very slow RAM, yes. And 16GB should be possible as well. I don't see why you'd need it though - I've never come close to using up the 1G that's setup on there at the moment.

And you may also be able to use swap files instead, which saves wasting all the SD card, e.g:
Code:

dd if=/dev/zero of=/media/mmc1/swap1.img bs=1M count=1024
mkswap /media/mmc1/swap1.img
swapon /media/mmc1/swap1.img

This hangs at swapon on my N900 though, so you may need the card formatted as ext3 instead of FAT32.

mrebanza 2010-01-27 10:48

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
I thought Micro SD was fast????

jaark 2010-01-27 10:55

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Quote:

Originally Posted by Rob1n (Post 497152)
4G of very slow RAM, yes. And 16GB should be possible as well. I don't see why you'd need it though - I've never come close to using up the 1G that's setup on there at the moment.

Exactly, there is a big difference between real RAM and virtual RAM.

I can't think of many situations where you would be using that much virtual ram and not have significant performance issues due to the system constantly swapping data back and forth (remember 'disk thrashing' on older windows boxes when they started to run out of ram?) Also storage on an SD card will be much, much slower than that on the internal swap area.

Due to the prevalence of native code, here should be less need for virtual ram than on other systems - and application binary and shared libraries etc. are often 'loaded' by mapping them into memory as though they were part of a virtual memory pagefile, under normal circumstances no binary executable code would hit your main virtual memory file.

Rob1n 2010-01-27 11:07

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Quote:

Originally Posted by mrebanza (Post 497157)
I thought Micro SD was fast????

Not really - according to Wikipedia it has a maximum read/write speed of 10MByte/s, whereas a desktop HDD will manage about 70. RAM is somewhere up in the thousands - I don't know off-hand what speed memory is in the N900, but modern desktop RAM is 4-6000.

jakiman 2010-01-27 11:19

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Yeah, this will allow memory hungry apps to at least "run" but not "fast". Still good to know. =)

shadowjk 2010-01-27 11:19

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
The 10megabytes/sec speed is only achieved with large sequential access. Random writes access, which swapping is, yields less than 1 megabyte/s in most cases, and worst case it degrades to less than 100kbyte/s. SD/mmc storage isn't designed for random access :)

TA-t3 2010-01-27 14:24

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Be careful with terminology, folks.

o RAM: RAM is always physical RAM. In the N900 there's 256MB of it.
o There's no such thing as 'virtual RAM'.
o Swap space: Resides in the built-in flash storage (there's 768MB of it on the N900), or could be set up on microSD as well).
o Virtual memory: This is (on Linux) the sum of swap and RAM. On the N900 it's 1GB (768+256).

Virtual memory is what the applications can potentially use (not considering some limitations added by the kernel). Virtual memory is the only thing applications know about. If you have no swap space allocated, only the 256MB physical RAM, then your virtual memory size would be 256MB. There's no such thing as 'not having virtual memory set up'. You mean _swap_ here.

o Swap space is always slower than RAM. Maybe in the future this could change, when/if some of the stuff being worked on in the labs manifests itself. Then maybe we'll have RAM, SD cards, USB sticks, other mass storage, all built from the same magical, non-volatile, super-fast stuff.

o Adding swap will not make for a faster device, only for a device which can sustain more applications running at the same time, or using more data, without going down in flames. There was a myth, for a while, that the N800 and N810 would be faster if you enabled swap space. This was only in the imagination - I tested this. And there's no rational reason it should be faster, except in very carefully thought out scenarios that won't happen with normal use.

o Adding excessive amounts of swap _will_ make your device slower, eventually. Particularly if you keep your applications (e.g. browser) running at all times.

rewt 2010-01-27 15:15

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
@TA-t3: Good info. Sometimes I forget that these things aren't always so clear to everyone...

nightfire 2010-03-22 04:45

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
If anyone is curious, I submit that moving your swap to your microsdhc card dramatically increases performance. It offloads swap I/O from the internal MMC, which frees it up for concurrent access (ie. program/library loading).

I created a 512mb slice on my microsd card, and modified the boot scripts to use it instead (excluding the 768mb mmc swap area completely) and the device is significantly more responsive when you have more than a few processes running. :)

This should be an option out-of-the-box (assuming the user is fairly warned about being unable to eject the microsdhc card while running).

Also note that you need a separate partition; a swap file seems to lock /sbin/swapon (bug?), and in any case you'd lose the ability to mount the vfat partition via USB (filesystem in use).

Alex Atkin UK 2010-03-22 06:19

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Quote:

Originally Posted by nightfire (Post 576643)
If anyone is curious, I submit that moving your swap to your microsdhc card dramatically increases performance. It offloads swap I/O from the internal MMC, which frees it up for concurrent access (ie. program/library loading).

I created a 512mb slice on my microsd card, and modified the boot scripts to use it instead (excluding the 768mb mmc swap area completely) and the device is significantly more responsive when you have more than a few processes running. :)

This should be an option out-of-the-box (assuming the user is fairly warned about being unable to eject the microsdhc card while running).

Also note that you need a separate partition; a swap file seems to lock /sbin/swapon (bug?), and in any case you'd lose the ability to mount the vfat partition via USB (filesystem in use).

Except, the most common programs/libraries are stored on the root partition, which is its own dedicated much faster flash memory built-in to the CPU package.

Only optified programs are stored on the eMMC, the same flash chip used for swap. So it should only make a difference in certain very specific circumstances. There is also a question of how the bus works in the N900, for all we know the microSD and eMMC have to contend for the same bandwidth.

Obviously that does not explain your positive results of moving the swap to microSD though. I usually find the N900 far more responsive after a reboot anyway, so are you sure you are not mistaking fresh boot speediness for swap speed improvement?

If it does help though, why not keep both swap partitions? Surely it being able to stripe between two separate devices should be even faster still?

byte_76 2010-03-22 08:36

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Quote:

Originally Posted by nightfire (Post 576643)
If anyone is curious, I submit that moving your swap to your microsdhc card dramatically increases performance. It offloads swap I/O from the internal MMC, which frees it up for concurrent access (ie. program/library loading).

I created a 512mb slice on my microsd card, and modified the boot scripts to use it instead (excluding the 768mb mmc swap area completely) and the device is significantly more responsive when you have more than a few processes running. :)

This should be an option out-of-the-box (assuming the user is fairly warned about being unable to eject the microsdhc card while running).

Also note that you need a separate partition; a swap file seems to lock /sbin/swapon (bug?), and in any case you'd lose the ability to mount the vfat partition via USB (filesystem in use).

Please share all the steps to configure this!

Would the striping idea work? It certainly seems logical.

superg05 2010-03-22 08:46

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Speed depends on SD Class class 6 and class 10 are the fastest at the moment but there is only class 6 micro sd cause class 10 was just released

demiurgus 2010-03-22 09:19

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Quote:

Originally Posted by byte_76 (Post 576739)
Would the striping idea work? It certainly seems logical.

There is no need to configure striping for swap partitions. If you have more than one the kernel will use them interchangeably anyway.

nightfire 2010-03-22 15:54

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Good point on rootfs being on a separate partition. I do run a lot of optified apps, and many apps access a lot of files in ~ (though small, still wait in the queue during heavy swap I/O).

My uptime's ~6 days right now and I have 8 apps running, and it's showing no signs of slowing down. Everything is still lightning fast. My microsd card is a 4gb sandisk. Not sure the class, but maybe it is faster at the block size the swap is using. I should check that. I did a quick I/O test with dd/sync, and it seemed to be slightly slower than the internal MMC. I should retest with more granularity.

I can write up a howto as soon as I get to the office. :) It's pretty straightforward.

I'll also note some program load / switch times for reference and comparison.

plaban 2010-04-02 17:08

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
I want to try it.Please someone make a wiki.

mikhmv 2010-04-02 17:17

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Quote:

Originally Posted by plaban (Post 592817)
I want to try it.Please someone make a wiki.

What do you want to see?
I can write how to do it.
Exist 2 ways to do it.
1. Increase Swap volume on internal flash (eMMC). In this case you will need to copy somewhere all files from internal memory (only from /home/user/MyDocs).
2. use swap on microSD card. In this case you will need to copy all files from your SD card.

What do you prefer?

plaban 2010-04-02 17:20

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
I want to use sd card

plaban 2010-04-02 17:28

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
I have used this
dd if=/dev/zero of=/media/mmc1/swap1.img bs=1M count=1024
mkswap /media/mmc1/swap1.img
swapon /media/mmc1/swap1.img

now a swap file of size 209 mb created in sd card.I want to know do I need run the code every time I reboot the device? What will happen if i remove the sd card?

plaban 2010-04-02 18:10

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Yes the device now feels more responsive and fast.Application opening and closing is seems faster.But need more confirmation.

plaban 2010-04-02 18:45

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
No one interested to try it ??

omri 2010-04-02 18:58

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Quote:

Originally Posted by plaban (Post 592926)
No one interested to try it ??

I tried it right now - exactly your steps (as root).
I also had the problem of swapon locking up.
Did you have to do something special for that not to happen? (my sd card is FAT formatted, BTW)

plaban 2010-04-02 19:05

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
I have formatted the card from mobile before using it.

nightfire 2010-04-02 19:09

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
There's a bug in the stock kernel (or possibly busybox) that breaks swapfiles; best bet is to make a new partition on the microsd card, type 82. It's faster anyway.

The easiest way is to plug your n900 in via USB and partition from a linux host (standard /sbin/fdisk).

Konceptz 2010-04-02 19:28

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Quote:

Originally Posted by demiurgus (Post 576789)
There is no need to configure striping for swap partitions. If you have more than one the kernel will use them interchangeably anyway.

I think this is somewhat pointless as the reason for striping was to use both hard drive's spin speed to increase data rate where the bottleneck is always the hard drive.

In this case, "conventional" seek time bottlenecks are eliminated due to the type of memory. Unless something is wrong with implementation, the default swap setup should be pretty much 100% of the speed you can get for "virtual memory".

But there are far more factors than "it should work this way". Therefore, if many people are coming up with a much faster swap solution by switching to a class 6 card, maybe we can also see if we can't pinpoint the slow down? (ie. throughput, kernel handling, etc..)

omri 2010-04-02 19:30

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Quote:

Originally Posted by plaban (Post 592948)
I have formatted the card from mobile before using it.

Do you happen to remember the exact commands you used?

plaban 2010-04-02 19:33

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
I used File Manager to format the card

shadowjk 2010-04-02 20:09

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Quote:

Originally Posted by Konceptz (Post 592971)
I think this is somewhat pointless as the reason for striping was to use both hard drive's spin speed to increase data rate where the bottleneck is always the hard drive.

In this case, "conventional" seek time bottlenecks are eliminated due to the type of memory. Unless something is wrong with implementation, the default swap setup should be pretty much 100% of the speed you can get for "virtual memory".

But there are far more factors than "it should work this way". Therefore, if many people are coming up with a much faster swap solution by switching to a class 6 card, maybe we can also see if we can't pinpoint the slow down? (ie. throughput, kernel handling, etc..)

emmc/sd behave worse than a harddrive really...

The internal block size is something like 256k, if you write 4k (page size), then write 4K somewhere else, then the emmc/sd must internally read 256k, modify the 4k, write back 256k. This makes emmc/sd behave alot like a hard drive that hates seeks.

256 / 4 is 64, that is, worst case speed is the sequential write speed divided by 64. Or, in the case of a class 6 microsdhc card, the worst case speed is 96 kilobytes/sec.

Most swap activity is random I/O.

But anyway, even if this was not the case, striping across two devices doubles the bandwidth anyway.

nightfire 2010-04-02 20:26

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Quote:

Originally Posted by Konceptz (Post 592971)
I think this is somewhat pointless as the reason for striping was to use both hard drive's spin speed to increase data rate where the bottleneck is always the hard drive.

In this case, "conventional" seek time bottlenecks are eliminated due to the type of memory. Unless something is wrong with implementation, the default swap setup should be pretty much 100% of the speed you can get for "virtual memory".

But there are far more factors than "it should work this way". Therefore, if many people are coming up with a much faster swap solution by switching to a class 6 card, maybe we can also see if we can't pinpoint the slow down? (ie. throughput, kernel handling, etc..)

That's sequential raid; striped raid increases throughput by parallelizing I/O. The access time on flash might be low, but the throughput isn't high, so reading/writing concurrent devices should increase performance.

Sequential raid has no effect on streaming I/O, but allows concurrent yet disparate requests to execute concurrently.

Having said all that, I was hoping to reduce disk load on the internal MMC so that its queue would stay more empty. But, someone pointed out that most of the system is on another block device anyway, so it would only affect /home (ie. opt, user files, etc).

*edit* I just re-read your post and my response might not make sense. :) I meant that striping across multiple devices increases bandwidth at the cost of slightly increasing access time. Sequential raid has no effect on bandwidth, but can reduce access time in some cases. In our case, striping across two block devices (ie. internal MMC + SD) could help us increase total swap bandwidth.

nightfire 2010-04-02 20:34

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Hmm.. I wonder if there are any potential performance gains by setting the page size to the MMC / SD block size (if possible) or forcing the kernel to only swap, say, 64 pages at a time. Is it possible the kernel is writing out 4kb pages in separate I/O operations?

nielsvg 2010-04-02 20:36

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
can we do something wrong with running this scripts? is this more pro or can a noobie dare the same?

Elhana 2010-04-02 21:07

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Quote:

Originally Posted by nielsvg (Post 593054)
can we do something wrong with running this scripts? is this more pro or can a noobie dare the same?

A good rule is if you don't understand what a command does - don't run it or be ready to reflash. At least "fdisk", rest are mostly harmless.
edit: "mkswap /dev/mmcblk1p1" will erase all data on a sd card ofc.

shadowjk 2010-04-03 09:33

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
page-cliuster size is already set to 128k, iirc. It helps at the start, but after some time the swap area has become fragmented enough that swapout becomes more 4k random writes

plaban 2010-04-03 09:35

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Did a test,at first run 30 apps at the same time without sd swap.After that rebooted and created swap in micro sd and run same 3p apps.I noticed that there is a little performance increase.

nightfire 2010-04-03 20:40

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Quote:

Originally Posted by shadowjk (Post 593551)
page-cliuster size is already set to 128k, iirc. It helps at the start, but after some time the swap area has become fragmented enough that swapout becomes more 4k random writes

Oh I meant the RAM page size. I don't know if it's adjustable on the CPU/MMU or not, but with 256k the atomic unit, you could only ever page in/out 256k.


All times are GMT. The time now is 04:01.

vBulletin® Version 3.8.8