which is the better option for performance (with respect to speed and multitasking)
As I understand it zRam compresses unused apps within the system RAM. So there is a CPU cost as well as reduced available RAM for other apps.
Swap files don't restrict available RAM but writing to the sdcard impacts the speed of opening apps.
Can both be used at the same time? I don't think so, but maybe I'm wrong. And perhaps using both has a negative impact on performance.
If only one is a viable option, which one should I use?
for me swap is better
Related
After many tests I think that we really suffer from a lack of RAM. But the internal memory (NAND) should be the same speed as RAM I think. So why we don't use another 128Mb of NAND as additional RAM? A sort of swap part, but used as RAM and not as normal swap....
If someone related to the kernel would answer is it possible or not, it would be good)
DiMiK said:
After many tests I think that we really suffer from a lack of RAM. But the internal memory (NAND) should be the same speed as RAM I think. So why we don't use another 128Mb of NAND as additional RAM? A sort of swap part, but used as RAM and not as normal swap....
If someone related to the kernel would answer is it possible or not, it would be good)
Click to expand...
Click to collapse
Using it as RAM would propably require major changes to the kernel if it is even possible which I doubt it is. Using it as swap would be the possible alternative and I pretty sure that is very possible and would help performance but at a cost.
1. You would either have very little left for system and data or you would have to put system and/or data on the SD-card and that alone may make you lose anything you gain from putting swap on NAND.
2. I actually asked the swap-on nand question myself and well, we can't replace our NAND, at least not easily and swap is I/O intensive and intesive I/O will sooner or later wear out the NAND. So basicly this is not a good alternative unless you want to turn your phone into a paperweight sooner than you had planned.
So what we can do is using compcache and/or swap on SD-card. The easiest thing is to just enable some compcache. It uses RAM as swap and uses compression on the contents so we can hold more things in RAM that we would usually be able to. This means Android can keep more apps in "sleep" allowing for faster switching between apps but it will also decrease the possible amount of available RAM for the active app. I usually turn on compcache with the default setting which is to use 25% of the RAM for compressed swap. It might be placebo but IMHO it feels a it "smoother" to use after that.
Another alternative is to use a swap partition in the sdcard. Just using swap means you do not need to load any compcache kernel modules and there is no compression taking place so it's a good alterantive. However you need know your way around partitioning SD-cards to get this running so it's not as easy as just enabling compcache (assuming the build supports compcache).
For the really advanced you can enable compcache with backing swap. It means it uses a certain amount of compressed swap i RAM and when it runs out of space there it starts putting stuff on the SD-card swap partition. Once again, a bit tricky to setup but may be the best alternative.
Read more about it here: http://wiki.cyanogenmod.com/index.php/Compcache
kallt_kaffe said:
I usually turn on compcache with the default setting which is to use 25% of the RAM for compressed swap. It might be placebo but IMHO it feels a it "smoother" to use after that.
Click to expand...
Click to collapse
It make good effect: more applications can run simultaneously.
Hi again guys...
In Linux we have a SWAP partition for some time if RAM (Random Access Memory) will full OR for speed up applications by buffering in swap partition.
(Recommend Linux SWAP partition size: half of RAM)
so Android is Linux based and have kernel like Linux. Is it work to make a SWAP partition for SGS with swap file system?
You don't want that...
Android doesn't wipe RAM immediately anyway, so apps which are open and shutdown can be restarted again quickly (unless the RAM has been reused).
Also, apps on Android are designed to be shut down whenever free RAM runs out (its in the development guidelines that all applications should expect to be shut down at any time). Since most Android phones use high-speed NAND memory, when properly configured, apps load quicker too
The problem with swap is that it can lead to thrashing and loss of battery life. It's good for computers (because generally, you would rather lose performance and ensure you don't lose work), but on Android, applications should be killable at any time, and should have mechanisms to protect their work anyway.
It's probably possible to create a swap partition/file if you wish (try to swapon), but I foresee some potential side-effects, especially if you don't want to spend a lot of time managing memory manually.
i didn't think about battery life.
Thank you so muchhhhhhhhhh
I was actually exploring this option last night and stumbled that the kernel does allows swapon commands. I remembered trying it earlier on a stock rom but it was not available then.
Why I need the swap was because of the frequent shutdown of my launcher pro due to apps contenting for memory. The live wallpaper and heavy Widgets like pure messenger pro aren't helping much either, after much usage the device just slows down, lags and silently kills the background apps. The "minfree" settings were also tweaked but with much less desirable results was seen...
So I downloaded an app called "swapper2" from market and tested via 2 methods; Swap file and swap partition.
The performance of a swap file that sits in the NAND is not really that great. In fact it kinda lags me when memory is being swapped in and out of it. I think its the same problem with the i/o lag problems with any other rom
Then I tried a swap partition on my class 6 SD card. Although the lifespan of the card would be shortened and the battery life would be impacted, the performance is better compared to the earlier method.
In either method, the amont of apps that can be left opened at the foreground and background had increased and doesn't lag as more apps is being launched. Not bad for me but well, I guess it's all up to the user of the device at the end. Just my 2 cents...
I'll try the swap file method again over at the ext2 partition created by the lagfix and see how it goes next. Not sure if anyone interested though...
Sent from my GT-I9000 using XDA App
It seems that using the swap partition doesn't have the lag compared to using the swap file method.
It may be due to the I/O of multiple storage (parallelism ?) is better than a single storage or writing into the raw partition is better in terms of performance than a swap file.
I'm done with my findings, the device still have 60mb free and never lags, I'm sold.
Sent from my GT-I9000 using XDA App
I'm curious about the memory swap implementation present in some kernels.
Did anyone know the wareout of the flash memory? From my knowledge there's a limited number of writes (about 100k ?) to a flash memory after that it can be damaged permanently.
IMO the best solution would be swapping on the external SD card that you can cheaply replace if damaged.
Then the question is which class of memory you need for good performance? If the read/write time is slow, all the benefit is lost.
Inviato dal mio Optimus 2X usando Tapatalk
Hi,
I am using modaco's gr5 (v20l) with Horsepower Rc11-R kernel. And I am using a feature available from that kernel called Compcache (compressed cache) which is regarded as swap.
For what I understand, the cache/swap file actually resides in the physical ram itself in a compressed form. Meaning, certain blocks/partition of the ram is being specifically reserved as compressed swap data so that more data can be stored in the physical ram. There are discussions about the fluidity and cpu usage thus affecting the battery life, but I have use it for a week and didn't notice much difference in battery consumption. So it has nothing to do with the internal flash memory.
As far as I know, there is no kernel supporting swap file on internal sd, only fps kernel dev planning on doing it because he does not like compcache, the idea of compressed swap file.
Personally, I prefer compcache on physical ram than swap on external sd because fetching files are faster that way and don't have to worry much about wear on the ram.
I hope someone else can correct me if I am mistaken! thanks!
Cheers!
Thank you for the detailed explanation.
Which is the level of compression achievable?
Wouldn't be more efficient to use a ramhack (like ironkernel) to get more memory?
Sorry for so many questions
Inviato dal mio Optimus 2X usando Tapatalk
I am not really quite sure about the amount of compression attainable as I do not know much of the nature of compcache. Sorry.
About the ramhack, do you mean the gain of more ram by removing ota function and others or the hack where you lessen the amount of gpu memory buffer and allocate it to main memory?
The gpu buffer ramhack was implemented in most kernels before, but most users do not like the sacrifices that they have to make just to gain an additional 64mb ram (that was the gain that time, I don't know about now on the kernel you mention). One of the problems is with stock gallery not displaying photo correctly and games not function properly.
Fyi, currently I have 750mb of ram by using compcache, 384mb on main, 384mb as compressed cache, all in physical memory. I do not know how they do it, but its there, and I do notice the difference whereby application on background not being terminated as fast as before.
Maybe someone else can give you a better understanding of compcache, how it resides on the ram etc.
Cheers.
my 2c about compcache (now "zram") and swap
Both compcache and swap are used to improve performance AND maximum number of open apps.
1)How they work:
swap is the classic way to "increase" ram on a system.
Swap is a space on a non volatile memory (="not ram") where unused ram data are parked instead of being deleted.
Swap wears(and kills) memories it is put on. It is an heavy access file. Sdcards don't like it. They are not full-featured SSD Disks. Think of your photographs
Compcache is the new way to "increase" ram on a system,
compcache :
-reserves a part of you ram (cache),
-then it looks for unused data sitting on remaining, "real", ram,
-compresses these unused data (with a very primitive,loseless, algorithm) and
- send them to its cache OR to swapfile.
Compcache's trick works well when you have lots of higly,easily, compressable data in your ram. Text is higly compressable, an executable is less compressable.
1a)
-if, after compression , data are still "big" (compressed data > original data /2), then compcache sends compressed data to swap, not to cache.
-and when compcache is full, unused compressed data are sent to swap.
2) because of compression involved, compcache uses more cpu cycles than classic swap.
3) settings of both depends on
-hardware specs of the system.
-use of the system
4) compcache+swap is better than swap alone if your ram is filled with EASILY compressable data.
4a)Remember point 1a : compcache has a simple compression algorithm, and ALWAYS first compresses data.
AFTER COMPRESSION it decides if keeping them in cache or sending them to swap. This means that
if compcache has always to work with not compressable data, it will compress them AND send to swap. this means double work: compression AND swap access.
4b) First practical conclusion :
compcache is useful for people using LOTS of text-intensive apps (forums, webpages, docs, facebook)
compcache may be useful in apps using SIMPLE still images (some games, driving assistant)
compcache is useless in multimedia activity (watching youtube, movies, photographs, listening to mp3s, playing some other games.)
5) The swap file.
As told at the beginning, swap, both improve performance(=speed) AND number of apps simultaneously open.
Lets' take a look to the PERFORMANCE thing.
5a)On "classical" (fragmented, not-SSD hard disk) systems, a swap file is always faster than retrieving datas from original disk locations. EVEN IF the swap file is on the same disk where original datas are.
This happens mainly because :
5a1)-data in swap file are less fragmented, needing less seek time.
5a2)-swap file is usually put in the external (=fast) zone of an hard disk,
5b)On SSD systems (phones included) 5a1 and 5a2 are not true, and a swapfile is USELESS IN IMPROVING PERFORMANCE EACH TIME THAT it is keeping data which are already present on its same phisycal memory.
Examples :
5b1)opera browser executable is on phone memory; but Opera-cached-webpages have been moved on sdcard via app2sd.
In this situation a swap file on sdcard is obviously useless to improve internet browsing with Opera.
5b2) i use apps (facebook, Whatsapp) which DON'T have a good caching of their own. Swap could be useful: it could avoid re-downloading data from the internet.
Now, the INCREASE MAXIMUM NUMBER OF OPEN APPS argument.
This is always true.
So:
5c)swapfile on SSD speeds up multitasking ONLY IF you use apps that
-badly manage (or don't have) a cache of their own.
-don't like force closing
Since this seems to happen very often to android apps, a swapfile is useful.
5c1)Swapfile could speed multitasking also IF an app's well-designed-cache is on a media WAY SLOWER than swapfile (but this is not LG O2x situation: it has a class10 internal memory).
So, my 2 cents about "increasing" RAM in LG O2X is :
-leave apps on phone memory, and put swap on a class10 sdcard.
-enable compcache only if you use lots of text-rich apps.
First: I think this doesn't really fit into the development section.
Then: I can't second the post you made.
mercxda said:
Both compcache and swap are used to improve performance AND maximum number of open apps.
(...)
As told at the beginning, swap, both improve performance(=speed) AND number of apps simultaneously open.
Click to expand...
Click to collapse
zRAM does NOT improve the speed of your device. Everything that's in the reserved zram storage will get compressed and decompressed, which takes some time (and cpu).
Swap is performing even worse. Instead of the fast RAM or the semi-fast compressed zRAM usage it's swapping onto the slow SD.
Sure, you can increase the maximum number of open apps, but the price is a lower performance.
So you're probably just meaning multitasking performance.
But still I can't agree to your conclusion:
mercxda said:
So, my 2 cents about "increasing" RAM in LG O2X is :
-leave apps on phone memory, and put swap on a class10 sdcard.
-enable compcache only if you use lots of text-rich apps.
Click to expand...
Click to collapse
As I wrote above zRAM is way faster than swap. So zRAM should be the first choice if you're running into low RAM situations.
If you still need more go and enable swap as well.
Last but not least:
Why are you talking about compache all the time? It's called zram nowadays, so call it that way.
tonyp said:
First: I think this doesn't really fit into the development section.
Click to expand...
Click to collapse
First : thanks for your interest in this post . I partially agree with you: this post is on the borderline beetwen Q&A and Development, because swap is not a development matter, it's standard unix's way of working.
On the other side zram's use,way of working, and even its inclusion (or not) itself in default installs, is still under development.
https://lists.ubuntu.com/archives/ubuntu-devel-discuss/2012-December/014122.html
Sure, x86/x64 is not ARM. And CM is not ubuntu.
Then: I can't second the post you made.
zRAM does NOT improve the speed of your device. Everything that's in the reserved zram storage will get compressed and decompressed, which takes some time (and cpu).
Swap is performing even worse. Instead of the fast RAM or the semi-fast compressed zRAM usage it's swapping onto the slow SD.
Sure, you can increase the maximum number of open apps, but the price is a lower performance.
So you're probably just meaning multitasking performance.
Click to expand...
Click to collapse
I, again , partially agree, i was fundamentally talking about multitasking performance. And sure, zram takes cpu cycles... I reserved a full, standalone point to say that.
But
i wouldn't be so sure about one being better than the other. My arguments are in the original post.
As I wrote above zRAM is way faster than swap. So zRAM should be the first choice if you're running into low RAM situations.
If you still need more go and enable swap as well.
Click to expand...
Click to collapse
As I wrote, and argumented, before, compcache/zram is way faster in a way limited range of situations.
Last but not least:
Why are you talking about compache all the time? It's called zram nowadays, so call it that way.
Click to expand...
Click to collapse
Because
1) I'm an old cat.
2) "Compcache" is a well chosen autodescriptive term.
3) It's been "compcache" for over 4/5 of it's life, and, well...
4) I'm an old cat. ;D
Have fun, and thanks for all your work in O2x developing.
EX-Kernel Manager and Kernel Adiutor both show default swappiness parameter in MIUI, as well as Sphynx and Siberia kernel as '100'. Since it always defaults to '60' in all linux distros, why force it to its maximum value of 100 and page everything to swap? Doesn't it slow our device by constantly writing on storage? Since we have 6 Gb of RAM available, wouldn't it be best to use our memory, lower the value and get a more responsive experience?
Or is it a requirement of Android's Doze functionality to keep all memory paged at all times to prepare for deep sleep?
najabi said:
EX-Kernel Manager and Kernel Adiutor both show default swappiness parameter in MIUI, as well as Sphynx and Siberia kernel as '100'. Since it always defaults to '60' in all linux distros, why force it to its maximum value of 100 and page everything to swap? Doesn't it slow our device by constantly writing on storage? Since we have 6 Gb of RAM available, wouldn't it be best to use our memory, lower the value and get a more responsive experience?
Or is it a requirement of Android's Doze functionality to keep all memory paged at all times to prepare for deep sleep?
Click to expand...
Click to collapse
Nope, I think it's more ART realted. Since Android swap from Dalvik to ART, app needs more I/O to memory and usage of it instead of using CPU.
That brings faster app openings and free space memory for RAM.
Of course, that's what I think. Some Android Custom OS (MIUI, One UI etc.) need more of it.
(deleted)