compcache swappiness - G1 Q&A, Help & Troubleshooting

I am running sparks mod 1.6.4 compcache 32% hack.
I want to change the swappiness to 60.
How would I go about doing this?

Don't do it, it's much too high. I would suggest something around 10-20, i.e. type in terminal:
su
echo 10 > /proc/sys/vm/swappiness
Sent from my Gingerbread on Sapphire using XDA App

Why so low? Just seeking some wisdom.
Thanks.\
Also is this a permanent change or do i have to do this every boot?

This is not a permanent change, you have to apply this every time you reboot your phone. If you want it permanent, you should include it into the /system/bin/compcache script.
Swappiness defines, when data will be put into the swapfile. 100 means, all inactive data can be put into the swap, 0 means, that cached data will be removed first before using the swap. Disadvantage when too much data is within swap: the system speed goes down ... so you have to find a good compromize.

AndDiSa said:
This is not a permanent change, you have to apply this every time you reboot your phone. If you want it permanent, you should include it into the /system/bin/compcache script.
Swappiness defines, when data will be put into the swapfile. 100 means, all inactive data can be put into the swap, 0 means, that cached data will be removed first before using the swap. Disadvantage when too much data is within swap: the system speed goes down ... so you have to find a good compromize.
Click to expand...
Click to collapse
ok so i edited the file and pushed it.
now compcache is not starting and when i type it in the terminal it says permission denied.
Any help?
should i try inputting the command you first gave me into compcache?

After the modification, the compcache file should look something like
...
start)
echo 3 > /proc/sys/vm/drop_caches
modprobe $MODULE
rzscontrol $DEV --disksize_kb=32576 --init
swapon $DEV
echo 10 > /proc/sys/vm/swappiness
;;
...

this is what i have
#!/system/bin/sh
#
# Compcache manager
# [email protected] (cyanogen)
#
DEV=/dev/block/ramzswap0
MODULE=ramzswap
MODULES_DIR=/system/modules/lib/modules/`uname -r`
case "$1" in
start)
echo 3 > /proc/sys/vm/drop_caches
echo 30 > /proc/sys/vm/swappiness
modprobe $MODULE
rzscontrol $DEV --disksize_kb=$2 --init
swapon $DEV
;;
stop)
swapoff $DEV >/dev/null 2>&1
rmmod $MODULE >/dev/null 2>&1
;;
stats)
rzscontrol $DEV --stats
;;
*)
echo "Usage: $0 {start <size>|stop|stats}"
exit 1
esac
exit 0
I cant seem to get it to work.
this is the original too.
it just keeps saying permission denied

You are running the script as root, i.e
> su
# /system/bin/compcache start
to start the script manually?
Before modifing the script, you have to remount /system to set it read-write, otherwise it's read only!

try to fix the permission

Related

Problem with compcache

Im running a userinit file for the cyanogen 3.91 rom and if tried to run it with now success. it just shows 000 on the swap when i run free. and when i try to run cat /proc/ramzswap it says that no such directory exists,
this is the userinit.sh
#!/system/bin/sh
# $Id: userinit.sh,v 1.2 2009/07/17 01:11:25 noah Exp $
# Do not change the #! above and expect that shell to invoke this script at
# boot, because a2sd forcibly calls this with /system/bin/sh.
PATH=/system/xbin/bb:$PATH
# Currently our busybox build uses the "small" modprobe and insmod,
# which don't support parameter arguments. (The usage string lies.)
uname_r=`uname -r`
moddir=`find /system/modules -type d -name $uname_r`
insmod=/system/bin/insmod
if $insmod $moddir/compcache/xvmalloc.ko &&
$insmod $moddir/compcache/ramzswap.ko disksize_kb=32768
then
sysctl -w vm.swappiness=40
mknod /dev/ramzswap0 b 253 0
swapon /dev/ramzswap0
fi
exit;
# eof
yeah dude im getting the same problem. Ive asked everywhere and no one can help. the only difference i notice are the two lines (exit; # eof) at the end of yours.
EDIT:
DUDE, just got it to work, this is what to do:
go here: http://forum.xda-developers.com/showthread.php?t=537236
download the text file.
open the text file delete everything and paste this in:
Code:
#!/system/bin/sh
# $Id: userinit.sh,v 1.2 2009/07/17 01:11:25 noah Exp $
# Do not change the #! above and expect that shell to invoke this script at
# boot, because a2sd forcibly calls this with /system/bin/sh.
PATH=/system/xbin/bb:$PATH
# Currently our busybox build uses the "small" modprobe and insmod,
# which don't support parameter arguments. (The usage string lies.)
uname_r=`uname -r`
moddir=`find /system/modules -type d -name $uname_r`
insmod=/system/bin/insmod
if $insmod $moddir/compcache/xvmalloc.ko &&
$insmod $moddir/compcache/ramzswap.ko disksize_kb=32768
then
sysctl -w vm.swappiness=40
mknod /dev/ramzswap0 b 253 0
swapon /dev/ramzswap0
fi
save it and close it
rename it userinit.sh and type this in adb:
Code:
adb push userinit.sh /system/sd
adb shell chmod 755 /system/sd/userinit.sh (not sure if needed being safe)
adb shell reboot
hope that helps
did you get it to work on 3.91?
ive tried everything and still swap is 0 0 0 0
I'm not an expert in the whole compcache thing I haven't followed it but doesn't "free" in terminal show swap, not compcache? I believe "cat /proc/ramzswap" shows compcache compression..
alritewhadeva said:
I'm not an expert in the whole compcache thing I haven't followed it but doesn't "free" in terminal show swap, not compcache? I believe "cat /proc/ramzswap" shows compcache compression..
Click to expand...
Click to collapse
"free" shows the swap file total, used and free. ramzswap goes more indepth
ubernicholi said:
"free" shows the swap file total, used and free. ramzswap goes more indepth
Click to expand...
Click to collapse
ah ok. Thanks for the clarification.
i tried the cat /proc/ramzswap and it said the file or directory could not be found
Compache DOES NOT WORK ON 3.9.1

help please: set up swap w/o a2sd [pretty stumped at this point]

im trying to set up a linux_swap partition, but i dont want to use apps2sd, nor do i want to use cache2sd.
can someone point me in the right direction?
kchau said:
im trying to set up a linux_swap partition, but i dont want to use apps2sd, nor do i want to use cache2sd.
can someone point me in the right direction?
Click to expand...
Click to collapse
Just create the linux-swap partition and not the ext partition.
will i have to wipe?
and what is the recommended size?
supremeteam256 said:
Just create the linux-swap partition and not the ext partition.
Click to expand...
Click to collapse
Does that work now? I know it depends on how you are doing it, but assuming a build with auto apps2sd, the script just looks at partition number and will screw up if you do that. I think cyanogen has made adjustments in his experimental line.
im running cyanogen 4.0.4. will it work?
kchau said:
im running cyanogen 4.0.4. will it work?
Click to expand...
Click to collapse
if the script does that couldnt you create a 1mb ext2/3/4?
You also need to edit the user.conf file.
linux_swap_en=1 # enable(1) or disable(0) linux swap
linux_swap_partition=/dev/block/mmcblk0p2 # swap partition device
The usual setting is mmcblk0p3 but you need to set it to mmcblk0p2 because your linus swap part is going to be 2 instead of 3
This is for swap only with no compcache
#compcache related parameters
compcache{
compcache_en=0 # enable(1) or disable(0) compcache
cc_disksize=32 # Ram swap disksize - any number between 1 to 95 should work
cc_memlimit=18 # Limite the memory usage when backing swap is used
cc_backingswap_en=0 # enable or disable backing swap
cc_backingswap=/dev/block/mmcblk0p2 # pointing to the backingswap partition device
cc_swappiness=60 # default 60
}
#Linux swap parameters
#
# linux swap can only be enabled if cc_backingswap_en is set to "0"
#
linux_swap{
linux_swap_en=1 # enable(1) or disable(0) linux swap
linux_swap_partition=/dev/block/mmcblk0p2 # swap partition device
swappiness=60 # default 60
}
will compcache improve speed while running background applications?
so do i have to create an ext3 partition to put the userconf in there?
wait, where do i put the user.conf file then?
i read around and i think im supposed to put the user.conf file into /system/sd
i also enabled compcache. let me know if that is not advised.
with a 64mb swap
#compcache related parameters
compcache{
compcache_en=1 # enable(1) or disable(0) compcache
cc_disksize=70 # Ram swap disksize - any number between 1 to 95 should work
cc_memlimit=18 # Limite the memory usage when backing swap is used
cc_backingswap_en=0 # enable or disable backing swap
cc_backingswap=/dev/block/mmcblk0p2 # pointing to the backingswap partition device
cc_swappiness=60 # default 60
}
#Linux swap parameters
#
# linux swap can only be enabled if cc_backingswap_en is set to "0"
#
linux_swap{
linux_swap_en=1 # enable(1) or disable(0) linux swap
linux_swap_partition=/dev/block/mmcblk0p2 # swap partition device
swappiness=60 # default 60
}
i have an issue with a boot loop at th eandroid screen now
ok, so, if i dont boot with the sd card inserted, it boots, but then i get to the home screen and it says none of my apps are installed.
so i go to recovery, remove the user.conf file. and same thing
so i restore, and boot with the sd card in. same thing, bootloop.
and now im restoring, but not booting with sd card.
what happened? was i not supposed to enable compcache? or keep the cc_disksize at 32?
so, ive been following this thread
http://forum.xda-developers.com/showthread.php?p=4379172
with this a2sd, it doesnt boot:
Code:
#!/system/bin/sh
#
# Apps2SD using symlinks and bind mounts
# [email protected] (cyanogen)
#
echo "--- Welcome to Android/CyanogenMod!";
sysctl -p
# execute any postinstall script then kill it
if [ -e /data/firstboot.sh ];
then
echo "--- Executing firstboot.sh";
/system/bin/sh /data/firstboot.sh;
rm -f /data/firstboot.sh;
fi;
if [ -e /dev/block/mmcblk0p2 ];
then
echo "--- Checking ext filesystems";
# fsck the sdcard filesystem first
e2fsck -y /dev/block/mmcblk0p4;
# set property with exit code in case an error occurs
setprop cm.e2fsck.errors $?;
# mount and set perms
busybox mount -o noatime,nodiratime -t auto /dev/block/mmcblk0p4 /system/sd;
busybox chown 1000:1000 /system/sd;
busybox chmod 771 /system/sd;
# clean up any old symlinks, create data directories
for i in dalvik-cache data;
do
if [ -h /data/$i ];
then
rm /data/$i;
fi;
if [ ! -d /data/$i ];
then
mkdir /data/$i;
busybox chown 1000:1000 /data/$i;
busybox chmod 771 /data/$i;
fi;
done;
# don't allow /data/data on sd because of upgrade issues - move it if possible
if [ -d /system/sd/data ];
then
busybox cp -a /system/sd/data/* /data/data/;
busybox rm -rf /system/sd/data;
fi;
# move apps and dalvik cache from internal memory to sdcard
for i in app app-private dalvik-cache;
do
if [ ! -d /system/sd/$i ];
then
mkdir /system/sd/$i;
fi
busybox chown 1000:1000 /system/sd/$i;
busybox chmod 771 /system/sd/$i
if [ -d /data/$i ] && [ ! -h /data/$i ];
then
busybox cp -a /data/$i/* /system/sd/$i/;
busybox rm -f /data/$i/*;
fi;
done;
# symlink app dirs - they must be on the same filesystem
for i in app app-private;
do
if [ -d /data/$i ] && [ ! -h /data/$i ];
then
busybox rm -rf /data/$i;
busybox ln -s /system/sd/$i /data/$i;
fi;
done;
# bind mount dalvik-cache so we can still boot without the sdcard
busybox mount -o bind /system/sd/dalvik-cache /data/dalvik-cache;
busybox chown 1000:1000 /data/dalvik-cache;
busybox chmod 771 /data/dalvik-cache;
# clean up old whiteouts
for i in local misc property system tombstones data;
do
if [ -h /system/sd/$i ]; then rm -f /system/sd/$i; fi
done;
# please don't put odex files in the app directory people!
# it causes dexopt to crash when switching builds!
busybox rm -f /system/sd/app/*.odex
# call a userinit.sh script if it's present on the sdcard
# otherwise just enable compcache with no backing swap
if [ -e /system/sd/userinit.sh ];
then
echo "--- Executing userinit.sh"
busybox chmod +x /system/sd/userinit.sh
/system/bin/sh /system/sd/userinit.sh;
else
modprobe ramzswap;
/system/bin/rzscontrol /dev/block/ramzswap0 --init
swapon /dev/block/ramzswap0
fi
setprop cm.a2sd.active 1;
echo "+++ Apps-to-SD successfully enabled";
else
# replace symlinks with directories so we can boot without sd
for i in app app-private;
do
if [ -h /data/$i ];
then
rm -f /data/$i;
mkdir /data/$i;
busybox chown 1000:1000 /data/$i;
busybox chmod 771 /data/$i;
fi;
done;
modprobe ramzswap;
/system/bin/rzscontrol /dev/block/ramzswap0 --init
swapon /dev/block/ramzswap0
setprop cm.a2sd.active 0;
fi;
sync;
setprop cm.filesystem.ready 1;
with this a2sd, no swap shows up when i go adb shell free:
Code:
#!/system/bin/sh
#
# Apps2SD using symlinks and bind mounts
# [email protected] (cyanogen)
#
echo "--- Welcome to Android/CyanogenMod!";
sysctl -p
# execute any postinstall script then kill it
if [ -e /data/firstboot.sh ];
then
echo "--- Executing firstboot.sh";
/system/bin/sh /data/firstboot.sh;
rm -f /data/firstboot.sh;
fi;
if [ -e /dev/block/mmcblk0p2 ];
then
echo "--- Checking ext filesystems";
# fsck the sdcard filesystem first
e2fsck -y /dev/block/mmcblk0p2;
# set property with exit code in case an error occurs
setprop cm.e2fsck.errors $?;
# mount and set perms
busybox mount -o noatime,nodiratime -t auto /dev/block/mmcblk0p2 /system/sd;
busybox chown 1000:1000 /system/sd;
busybox chmod 771 /system/sd;
fi;
sync;
setprop cm.filesystem.ready 1;
and with the default a2sd, no boot.
and this is my user.conf
Code:
# General parameters
general{
apps2sd=0 # this is useless here, require a modified a2sd script
media2sd=0 # moves the medias to sd if /system/sd/media exists
}
#compcache related parameters
compcache{
compcache_en=1 # enable(1) or disable(0) compcache
cc_disksize=70 # Ram swap disksize - any number between 1 to 95 should work
cc_memlimit=18 # Limit the memory usage for backing swap (cc .5x known issue-defaults to 15% of total RAM)
cc_backingswap_en=0 # enable(1) or disable(0) backing swap
cc_backingswap=/dev/block/mmcblk0p2 # pointing to the backingswap partition device
cc_swappiness=60 # default 60
}
#Linux swap parameters
#
# linux swap can only be enabled if cc_backingswap_en is set to "0"
#
linux_swap{
linux_swap_en=1 # enable(1) or disable(0) linux swap
linux_swap_partition=/dev/block/mmcblk0p2 # swap partition device
swappiness=60 # default 60
}
partition 1 is my fat32 which is whatever 8 gigs minus 64
partition 2 is 64 megs of linux_swap
WOW,
You have completely over complicated this. remove the user.conf file from every location you put it in, remove all partitions and leave it with none, boot in recovery and wipe, then reflash cyan 4.0.4. reboot. everything should be normal with no swap and it should ask you if you want to format the sd card. when you get it working normal post back here.
my whole point is not to wipe, and i dont want a2sd.
wiping and doing what you said above will enable a2sd.
what part of my previous post would enable apps2sd?
if you don't want to wipe, then at least do everything else i posted
ok, i removed all the user.conf and repartitioned my sdcard
now what?
reflash cyan 4.0.4 and boot so it will format the card
what is the make, size, and class of your sdcard?
why no apps2sd?

[MOD](MIROSLAV_MM WE NEED YOU) Swap on data.

I found an interesting script for Galaxy I5500, which does allow users to create swap file in data/system partition. I tested it on I5500 because i own one right now and the script does indeed work, i also noticed improvement in the swap performance. Right now i'm trying to do this on GT540 but i found some difficulties and i need your help. If we'll make it working i will create script for GT540.
First of all, this is how it's done:
1. Open up your terminal.
2. Get superuser permission using su command.
3. Type this( make sure you have 64 mb of free memory on data partition ):
Code:
dd if=/dev/zero of=/data/swapfile1 bs=1024 count=65536
mkswap /data/swapfile1
swapon /data/swapfile1
It does work fine until swapon command usage which does give some retarded error "Invalid argument" Anyone have idea how to make this work?
You can delete swapfile1 using:
Code:
rm /data/swapfile1
This is not good idea, there is chance to broke nand.
Erm how much swap can we squeeze in there :/
I don't think it would do much difference, phone is accessing nand very often anyway when loading apps and system components which are stored there. I just want to try it out because it gives noticeable performance improvement on Galaxy I5500. I can test for bad blocks as well after some time of use.
@UP
It depends how much free memory do you have on your data partition, altough i don't advice to use swap bigger than 64 MB. Android won't use that much even with swappiness set to 100, so using large swap partition or file is just waste of memory. Not mentioning the fact that it will decrease performance.
bataya said:
This is not good idea, there is chance to broke nand.
Click to expand...
Click to collapse
Yeah, but probably in a few years, when you would probably use another, newer phone.
Do you have any idea what to do with this invalid argument error? If now i'll try to pm miroslav and ask him for help.
shadovraven said:
I don't think it would do much difference, phone is accessing nand very often anyway when loading apps and system components which are stored there. I just want to try it out because it gives noticeable performance improvement on Galaxy I5500. I can test for bad blocks as well after some time of use.
@UP
It depends how much free memory do you have on your data partition, altough i don't advice to use swap bigger than 64 MB. Android won't use that much even with swappiness set to 100, so using large swap partition or file is just waste of memory. Not mentioning the fact that it will decrease performance.
Click to expand...
Click to collapse
you can create many swap files/partitions at the same time. the OS will choose which swap to use depend on its priority. if 2 swap files/partitions have the same priority, it will be used in a round-robin fashion
by default many swap apps create only 32MB swap file because it's sufficient enough for the system. I've seen many people create a swap partition as large as 512MB-1GB. It won't give them any increase in speed because the system will only use a very small amount of them. My SD card have a 54MB swap partition and android use only about 8-16MB swap with swappiness set to 10. If I set it to 60 as default, the swap usage will be about 40-50MB
SWAP on Data (30mb)
Code:
#!/system/bin/sh
if [ -e /data/.swap.img ];
then
losetup /dev/block/loop7 /data/.swap.img;
mkswap /dev/block/loop7;
swapon /dev/block/loop7;
echo "swap on data"
else
dd if=/dev/zero of=/data/.swap.img bs=1024 count=30000;
losetup /dev/block/loop7 /data/.swap.img;
mkswap /dev/block/loop7;
swapon /dev/block/loop7;
echo "swap create & on data"
fi;
put file in init.d
miroslav_mm said:
SWAP on Data (30mb)
Code:
#!/system/bin/sh
if [ -e /data/.swap.img ];
then
losetup /dev/block/loop7 /data/.swap.img;
mkswap /dev/block/loop7;
swapon /dev/block/loop7;
echo "swap on data"
else
dd if=/dev/zero of=/data/.swap.img bs=1024 count=30000;
losetup /dev/block/loop7 /data/.swap.img;
mkswap /dev/block/loop7;
swapon /dev/block/loop7;
echo "swap create & on data"
fi;
put file in init.d
Click to expand...
Click to collapse
Thank you miroslav, gonna put this into start post.
EDIT: I tried that and it doesn't seem to work, i've put that into init.d but free command returns that swap size is 0. What permission i should set? I will try to do this manually.
EDIT2: I tried it manually, swapon /dev/block/loop7 returns invalid argument. I attached screenshot so you can see for yourself.
Bump for miroslav to see, I hope this will work.
/dev/block/loop7 for 2.6.29 for Android 2.1 for example
open RE
/proc/ open file partitions
find you Data part by side
look like mtdblock6 on SDSL 3.0
That is all.
I tried it on SDSL v3 and swapon /dev/block/mtdblock6; also does return invalid argument error.
Not recommended, it makes phone lag

[script] clean up SWAP partition bash script

Hello there,
this is a simple script how to clean up the swap partition without restart or typing commands in the terminal.
Tested on:
- CM9 (Milestone A853)
Requirements:
- rooted device
- swap partition (/dev/block/mmcblk0p3)
- GScript Application (thanks to rogro82) http://forum.xda-developers.com/showthread.php?t=486486
Make sure GScript has root access and the script in the application has su rights.
Here comes the script:
Code:
if [ -e "/sdcard/swapre/" ];then
echo "folder exists, we are good to go"
else
mkdir /sdcard/swapre/
touch /sdcard/swapre/log.txt
fi
swapoff /dev/block/mmcblk0p3
echo "swap is off, please wait"
echo "swap is off" > /sdcard/swapre/log.txt
swapon /dev/block/mmcblk0p3
echo "swap is on, hold a second to finish"
echo "swap is on" >> /sdcard/swapre/log.txt
echo "swap was restarted at:" >> /sdcard/swapre/log.txt
date -u >> /sdcard/swapre/log.txt
7z version -> https://dl.dropbox.com/u/2969199/swp.7z
the script will crate a folder on the sd card, with a log file within. Just in case you want to see what happened
I recommend to create a shortcut on the desktop, after you installed GScript and the script, for easier access.
You should be fine with your device and it should work
well, have fun.

[WIP] Swap in CM 11/12

We have started this discussion in Mentor.37's [RECOVERY]Safestrap 3.75 for unused partitions thread and I decided to create a new thread for it.
Why swap?
Since D4 is low on RAM, especially for Lollipop (CM12), idea of having the system swap out some data instead of closing all apps but the one I currently use seems appealing to me, even for the trade-out of slowing the system down a bit when loading. More comprehensive (dated, but still valid) information on whether to use swap can be gathered from this article: Why Android Swap Doesn’t Make Sense. While even its name suggests you shouldn't swap in Android, the conclusion works in favor of trying swap in my installation of Lollipop where system and background apps eat up over 75% of RAM straight after boot:
Jeffrey Blattman said:
And here’s a few counter arguments that I can imagine,
1. The native Android memory management scheme is there for apps, but not for other processes. That is, having swap allows the many processes that run to support the Linux operating system to be moved out of physical memory.
Click to expand...
Click to collapse
Also in comments there are some persuasive arguments in favor of swapping, such as not having to reload content of apps (especially browsers) after they get killed off by Android. In my use, this is crucial when I'm without Internet connection for some time.
Current status: swapping works, but I have mixed feelings on whether it helps or not. It needs more tinkering with swappiness to find the right value, CM12's default of 60 is way too high.
Script for automated install and init with swappiness parameter in post #2
@Milp's original post:
Milp said:
I placed 550mb swap files in both /webtop and /preinstall (mounted under storage), also smaller ones in cache, system and data. Swapped on all of them, it's like a brand new phone now, speed wise.
Using 40 swappiness. cm11.
I created the swap files in an app called swapper and moved them to the locations. If anyone is interested in the swapon script for smanager, i can post it here.
somehow using dd with if=/dev/null did not work and filling those files with /dev/urandom didn't let me swap on them.
I don't know if its a good test for how fast things got, but i'm now able to watch a 720p video in the desktop site of youtube in firefox with 3 addons. It plays fluently.
Hope this is the right place for it, not sure whether it deserves it's own thread.
Click to expand...
Click to collapse
My next post, summing up how I got there. I've been running the system like this for over a day, with mixed feelings about result.
Milp said:
I placed 550mb swap files in both /webtop and /preinstall (mounted under storage), also smaller ones in cache, system and data. Swapped on all of them, it's like a brand new phone now, speed wise.
Click to expand...
Click to collapse
Great idea, inspired me to this little adventure (CM12 in system slot):
Putting swap file to cache partition (as it's 1 GB and using under 30 MB) and making preinstall swap:
Code:
/ # tar -cv /cache | gzip > /sdcard/cache.tar.gz
/ # dd if=/dev/zero of=/cache/swap bs=1024 count=819200
/ # mkswap /cache/swap
/ # swapon /cache/swap
/ # mkswap /dev/block/preinstall
/ # swapon /dev/block/preinstall
Now we need to make this mapping persistent - let's use /data/local/userinit.sh (don't forget to chmod 755 userinit.sh after you create it):
Code:
#!/system/bin/sh
swapon /cache/swap
swapon /dev/block/preinstall
This should run on startup (invoked by /system/etc/init.d/90userinit). It doesn't and I don't know why (yet), so I use SManager instead.
Results:
Not much tested, but it looks like it works. I ran CG Transit (offline timetables for Czech public transport) and then Hill Climb Racing (only resource-heavy game I have installed), which would usually kill off everything else, making the timetables forget its state. This didn't happen and switching out of the game felt a bit snappier, woohoo We'll see after some time though, this may be just me REALLY wanting this to help.
Code:
/ # free
free
total used free shared buffers
Mem: 859572 845284 14288 0 3336
-/+ buffers: 841948 17624
Swap: 1441784 66716 1375068
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
@Milp what script do you use? How exactly did you create your swap files?
To revert preinstall back to ext3 if you don't want to use it as swap anymore (it's been formatted as swap by mkswap):
Code:
/ # mke2fs /dev/block/preinstall
/ # tune2fs -j /dev/block/preinstall
(following is not finished)
Using webtop as dalvik-cache (and backup in case something goes wrong after restart):
Code:
/data # mv dalvik-cache/ dalvik-cache-old
/data # mkdir dalvik-cache
/data # mount -t ext4 /dev/block/webtop /data/dalvik-cache
/data # rm -rf dalvik-cache/*
/data # cp -r dalvik-cache-old/* dalvik-cache/
/data # rm -rf dalvik-cache-old/
/data # tar -cv dalvik-cache/ | gzip > /sdcard/dalvik-cache.tar.gz
Then it's needed to be mounted when startup. My initial attempt utilizing /data/local/userinit.sh failed, will need to edit ramdisk for this to work :/ Not today.
Random info about my system for understanding why did I also move dalvik cache elsewhere:
Tip: I use SSHDroid to easily ssh to device. adb shell doesn't suit me, especially for its lack of completing paths. And to have it nice and colorful, this is my first command: su -c bash
Code:
/ # cat /proc/partitions
major minor #blocks name alias
7 0 27160 loop0
7 1 25068 loop1
7 2 22980 loop2
7 5 35516 loop5
7 6 43872 loop6
7 7 4096 loop7
179 0 15552512 mmcblk1
179 1 128 mmcblk1p1
179 2 512 mmcblk1p2
179 3 512 mmcblk1p3
179 4 1 mmcblk1p4
179 5 512 mmcblk1p5
179 6 512 mmcblk1p6
179 7 4096 mmcblk1p7 pds
179 8 512 mmcblk1p8 utags
179 9 1024 mmcblk1p9
179 10 2048 mmcblk1p10
179 11 512 mmcblk1p11
179 12 512 mmcblk1p12
179 13 4096 mmcblk1p13
179 14 8192 mmcblk1p14 boot
179 15 9216 mmcblk1p15 recovery
179 16 217088 mmcblk1p16 cdrom
179 17 512 mmcblk1p17 misc
179 18 512 mmcblk1p18 cid
179 19 4096 mmcblk1p19 kpanic
179 20 655360 mmcblk1p20 system
179 21 1048576 mmcblk1p21 cache
179 22 622592 mmcblk1p22 preinstall
179 23 1364992 mmcblk1p23 webtop
179 24 3203072 mmcblk1p24 userdata
179 25 8401792 mmcblk1p25 emstorage
179 26 128 mmcblk1p26
179 32 62367744 mmcblk0
179 33 62366720 mmcblk0p1
254 0 27160 dm-0
254 1 25068 dm-1
254 2 22980 dm-2
254 5 35516 dm-5
254 6 43872 dm-6
7 8 21936 loop8
254 7 21936 dm-7
7 9 22980 loop9
254 8 22980 dm-8
7 10 28204 loop10
254 9 28204 dm-9
7 11 40736 loop11
254 10 40736 dm-10
7 12 5224 loop12
254 11 5224 dm-11
7 13 11492 loop13
254 12 11492 dm-12
7 14 10448 loop14
254 13 10448 dm-13
7 16 42824 loop16
254 15 42824 dm-15
Code:
/data # du -sh *
4.0K adb
6.6M anr
703.4M app
4.0K app-asec
4.0K app-lib
4.0K app-private
4.0K ash_history
116.0K backup
12.0K battd
0 bugreports
0 chargeonlymode
1.0G dalvik-cache
441.6M data
288.0K dontpanic
8.0K download
20.0K drm
4.0K emt
32.0K kernelpanics
32.0K local
4.0K location
84.0K logger
20.0K lost+found
12.0K media
20.0K mediadrm
1.6M misc
8.0K panicreports
4.0M pdsdata.img
44.0K property
4.0K resource-cache
4.0K security
24.0K ssh
4.3M system
16.0K tmp
5.1M tombstones
16.0K tpapi
4.0K user
Code:
/ # df
Filesystem Size Used Free Blksize
/dev 419.7M 60.0K 419.7M 4096
/sys/fs/cgroup 419.7M 12.0K 419.7M 4096
/mnt/asec 419.7M 0.0K 419.7M 4096
/mnt/obb 419.7M 0.0K 419.7M 4096
/system 636.7M 604.2M 32.5M 1024
/data 3.0G 2.2G 798.2M 4096
/cache 1007.9M 33.4M 974.5M 4096
/pds 3.9M 1.1M 2.8M 1024
/storage/sdcard0 8.0G 2.9G 5.1G 8192
/mnt/media_rw/sdcard0 8.0G 2.9G 5.1G 8192
/mnt/secure/asec 59.5G 58.0G 1.5G 32768
/mnt/media_rw/sdcard1 59.5G 58.0G 1.5G 32768
/mnt/secure/asec 59.5G 58.0G 1.5G 32768
/mnt/media_rw/sdcard0/.android_secure 59.5G 58.0G 1.5G 32768
/storage/sdcard1 59.5G 58.0G 1.5G 32768
[asec stripped]
Milp's response showing how did he approach the swapping problem, including setting swappiness to 15:
Milp said:
Hi there, I'm using the following code. I'm using some random app to create swapfiles since dd doesn't work for me with if=/dev/null, it creates 0byte files. And swapping on a file filled with /dev/urandom doesn't seem to work. No idea how else i could go about that.
Code:
#!/system/bin/sh
echo start > /storage/sdcard0/swap.log 2>&1
echo mountstuff > /storage/sdcard0/swap.log 2>&1
umount /preinstall >> /storage/sdcard0/swap.log 2>&1
mount -o rw,remount / >> /storage/sdcard0/swap.log 2>&1
rm -r preinstall >> /storage/sdcard0/swap.log 2>&1
mkdir /storage/preinstall >> /storage/sdcard0/swap.log 2>&1
mkdir /storage/webtop >> /storage/sdcard0/swap.log 2>&1
mount -o ro,remount / >> /storage/sdcard0/swap.log 2>&1
mount -t ext3 /dev/block/preinstall /storage/preinstall >> /storage/sdcard0/swap.log 2>&1
mount -t ext4 /dev/block/webtop /storage/webtop >> /storage/sdcard0/swap.log 2>&1
chmod 777 /storage/preinstall >> /storage/sdcard0/swap.log 2>&1
chmod 777 /storage/webtop >> /storage/sdcard0/swap.log 2>&1
echo swappiness...15 >> /storage/sdcard0/swap.log 2>&1
echo 15 1> /proc/sys/vm/swappiness 2>> /storage/sdcard0/swap.log
echo cping... >> /storage/sdcard0/swap.log >> /storage/sdcard0/swap.log 2>&1
cp /storage/sdcard0/Swapper/swap.swp /storage/preinstall/swap.swp >> /storage/sdcard0/swap.log 2>&1
chmod 666 /storage/preinstall/swap.swp >> /storage/sdcard0/swap.log 2>&1
cp /storage/sdcard0/Swapper/swap.swp /cache/swap.swp >> /storage/sdcard0/swap.log 2>&1
chmod 666 /cache/swap.swp >> /storage/sdcard0/swap.log 2>&1
swapon /storage/preinstall/swap.swp >> /storage/sdcard0/swap.log 2>&1
mount -o remount,rw /dev/block/system /system >> /storage/sdcard0/swap.log 2>&1
swapon /system/swap.swp >> /storage/sdcard0/swap.log 2>&1
echo swappingon... >> /storage/sdcard0/swap.log 2>&1
swapon /storage/sdcard0/Swapper/swap.swp >> /storage/sdcard0/swap.log 2>&1
swapon /storage/webtop/swap.swp >> /storage/sdcard0/swap.log 2>&1
swapon /data/swap.swp >> /storage/sdcard0/swap.log 2>&1
swapon /cache/swap.swp >> /storage/sdcard0/swap.log 2>&1[/HIDE]
This might not be too good of a batch script, but i've never before in my life made linux batch scripts, I'm happy it works. I use smanager to execute it on boot.
There is a pre-created 100mb swapfile in /storage/sdcard0/Swapper/swap.swp that gets copied to /cache/ and /storage/preinstall/, since the files there seem to get wiped regularily.
Of course swapping on sdcard0 does not work since sdcard0 does not support permissions (fat?), i was just too lazy to remove it. A logfile is generated in sdcard0 called swap.log.
Been messing around with the swappiness a lot. 30-40 swappiness really enhances multitasking but the phone seems to get slow after some time because it has to do a lot of swap io i guess. Trying 15 now.
Click to expand...
Click to collapse
In the next post I'll elaborate on the scripts and hopefully upload nice automatic scripts here You still need to use SManager to run them though.
Script for creating and running swap in /cache attached.
Whole script init.sh:
Code:
#!/system/bin/sh
date >> /data/swap/swap-init.log 2>&1
echo "Initializing swap." >> /data/swap/swap-init.log 2>&1
if [ ! -f /cache/swap ]; then # when /cache/swap is not present
echo "Swap file not found, creating it." >> /data/swap/swap-init.log 2>&1
date >> /data/swap/swap-setup.log 2>&1
echo "Creating swap file as it was not present." >> /data/swap/swap-setup.log 2>&1
echo "Space in /cache:" >> /data/swap/swap-setup.log 2>&1
df /cache >> /data/swap/swap-setup.log 2>&1
freeCache=$(busybox df -k /cache | tail -1 | awk '{ print $4 }')
let swapSize=freeCache*80/100 # count 80% of free space in /cache
echo "Creating ${swapSize} KB swap file." >> /data/swap/swap-setup.log 2>&1
dd if=/dev/zero of=/cache/swap bs=1024 count=$swapSize >> /data/swap/swap-setup.log 2>&1 # create swap file called swap in /cache that takes up 80% of its free space.
mkswap /cache/swap >> /data/swap/swap-setup.log 2>&1 # format the previously created 'swap' file for swap, just as you'd do with a partition
echo "Creation of the swap file completed." >> /data/swap/swap-setup.log 2>&1
date >> /data/swap/swap-setup.log 2>&1
fi
if [ ! -f /data/swap/swappines.txt ]; then
echo 15 1> /proc/sys/vm/swappiness 2>> /data/swap/swap-init.log # set swappiness 15
else
cat /data/swap/swappiness.txt 1> /proc/sys/vm/swappiness 2>> /data/swap/swap-init.log # set swappiness as in swappiness.txt - PUT THERE ONLY NUMS 1-99!
fi
swapon /cache/swap >> /data/swap/swap-init.log 2>&1 # use the swap file created in the installation script for swap
echo "Swap initialization done." >> /data/swap/swap-init.log 2>&1
date >> /data/swap/swap-init.log 2>&1
Usage:
Extract init.sh (and optionally swappiness.txt as well) to /data/swap/
Setup SManager to run it on boot: View attachment 3397902 (don't forget to hit the top-right SAVE button after you select Su and Boot)
Run it manually for first-time init (if you don't, the next boot will be pretty slow)
It will create the swap file on the first run, utilizing 80% of free space in the /cache partition. It's better to do step 3 - run it manually first, so it doesn't compete for system resources with other stuff starting on boot. It took me over five minutes to create the swap file on boot, compared to about two minutes when the system was already running. While creating, it eats up system resources and blocks other apps -> wait 5+ mins for it to finish. You have been warned If it fails for whatever reason, just delete the /cache/swap file and run it again. It writes a huge file (about 750M) while everything else competes for the flash memory read and write which is why it's so slow at boot.
My setup log:
Code:
Thu Jul 9 23:46:53 CEST 2015
Creating swap file as it was not present.
Space in /cache:
Filesystem Size Used Free Blksize
/cache 1007.9M 33.3M 974.6M 4096
Creating 756409 KB swap file.
756409+0 records in
756409+0 records out
774562816 bytes transferred in 301.058 secs (2572802 bytes/sec)
Creation of the swap file completed.
Thu Jul 9 23:51:59 CEST 2015
The script logs inits to /data/swap/swap-init.log and the setup (creation of the swap file) to /data/swap/swap-setup.log. It sets swappiness to 15 or whatever you have in /data/swap/swappiness.txt (if it's missing, it defaults to 15).
If you want to see whether it's done creating the swap file yet, either watch the /cache/swap file grow (i.e. over SCP) or watch the setup log grow (tail -f /data/swap/swap-setup.log in shell, wait for the "Creation of the swap file completed." text to appear and then exit tail by Ctrl+C).
If you have set your SELinux to permissive state, you can save init.sh as /data/local/userinit.sh and don't need SManager at all - it will be run by CM itself. Make sure to create the /data/swap folder though so the logs can be saved, otherwise it may exit on error.
Milp said:
Hi there, I'm using the following code. I'm using some random app to create swapfiles since dd doesn't work for me with if=/dev/null, it creates 0byte files.
Click to expand...
Click to collapse
Works with if=/dev/zero
Milp said:
And swapping on a file filled with /dev/urandom doesn't seem to work. No idea how else i could go about that.
Click to expand...
Click to collapse
Well, did you format the file for swap using mkswap?
Milp said:
Code:
#!/system/bin/sh
echo start > /storage/sdcard0/swap.log 2>&1
echo mountstuff > /storage/sdcard0/swap.log 2>&1
umount /preinstall >> /storage/sdcard0/swap.log 2>&1
mount -o rw,remount / >> /storage/sdcard0/swap.log 2>&1
rm -r preinstall >> /storage/sdcard0/swap.log 2>&1
mkdir /storage/preinstall >> /storage/sdcard0/swap.log 2>&1
mkdir /storage/webtop >> /storage/sdcard0/swap.log 2>&1
mount -o ro,remount / >> /storage/sdcard0/swap.log 2>&1
mount -t ext3 /dev/block/preinstall /storage/preinstall >> /storage/sdcard0/swap.log 2>&1
mount -t ext4 /dev/block/webtop /storage/webtop >> /storage/sdcard0/swap.log 2>&1
chmod 777 /storage/preinstall >> /storage/sdcard0/swap.log 2>&1
chmod 777 /storage/webtop >> /storage/sdcard0/swap.log 2>&1
echo swappiness...15 >> /storage/sdcard0/swap.log 2>&1
echo 15 1> /proc/sys/vm/swappiness 2>> /storage/sdcard0/swap.log
echo cping... >> /storage/sdcard0/swap.log >> /storage/sdcard0/swap.log 2>&1
cp /storage/sdcard0/Swapper/swap.swp /storage/preinstall/swap.swp >> /storage/sdcard0/swap.log 2>&1
chmod 666 /storage/preinstall/swap.swp >> /storage/sdcard0/swap.log 2>&1
cp /storage/sdcard0/Swapper/swap.swp /cache/swap.swp >> /storage/sdcard0/swap.log 2>&1
chmod 666 /cache/swap.swp >> /storage/sdcard0/swap.log 2>&1
swapon /storage/preinstall/swap.swp >> /storage/sdcard0/swap.log 2>&1
mount -o remount,rw /dev/block/system /system >> /storage/sdcard0/swap.log 2>&1
swapon /system/swap.swp >> /storage/sdcard0/swap.log 2>&1
echo swappingon... >> /storage/sdcard0/swap.log 2>&1
swapon /storage/sdcard0/Swapper/swap.swp >> /storage/sdcard0/swap.log 2>&1
swapon /storage/webtop/swap.swp >> /storage/sdcard0/swap.log 2>&1
swapon /data/swap.swp >> /storage/sdcard0/swap.log 2>&1
swapon /cache/swap.swp >> /storage/sdcard0/swap.log 2>&1[/HIDE]
This might not be too good of a batch script, but i've never before in my life made linux batch scripts, I'm happy it works. I use smanager to execute it on boot.
There is a pre-created 100mb swapfile in /storage/sdcard0/Swapper/swap.swp that gets copied to /cache/ and /storage/preinstall/, since the files there seem to get wiped regularily.
Click to expand...
Click to collapse
I'm not advanced in batch scripting either, but this looks fine to me for your purpose. Holy Mother of Logging though However, the first "start" won't be in the log and log gets overwritten each run - you use > (save to file) instead of >> (append to file) in first two lines.
Milp said:
Of course swapping on sdcard0 does not work since sdcard0 does not support permissions (fat?), i was just too lazy to remove it. A logfile is generated in sdcard0 called swap.log.
Click to expand...
Click to collapse
All this is quite heavy approach, may I suggest mine?
To put it into shell script format:
One-time installation:
Code:
#!/system/bin/sh
dd if=/dev/zero of=/cache/swap bs=1024 count=819200 # create 800 MB swap file called swap in /cache (this is for systems running in stock slot where there's 1GB partition for cache that's almost not used - adjust size (count=<size in KB>) for your system). I didn't experience any deletion of this. If you do like Milp did, just re-run this script.
mkswap /cache/swap # format the previously created 'swap' file for swap, just as you'd do with a partition
swapon /cache/swap # use this file as swap
umount /preinstall # not needed in CM12, it's not mounted (the folder is there though). Let's do it for legacy compatibility though :)
mkswap /dev/block/preinstall # format the whole /preinstall partition as swap so we don't have to deal with stupid deletions or mounts or whatever later
swapon /dev/block/preinstall # use preinstall as swap (this is kinda like mount for swap partition/device)
I didn't use any logging as I run these over ssh or from adb shell so I can see stdout and stderr. If you wish to, you can add Milp's >> /storage/sdcard0/swap.log 2>&1 at the end of each line before my comments:
Code:
#!/system/bin/sh
date >> /storage/sdcard0/swap-setup.log 2>&1
echo "Swap files installation started." >> /storage/sdcard0/swap-setup.log 2>&1
dd if=/dev/zero of=/cache/swap bs=1024 count=819200 >> /storage/sdcard0/swap-setup.log 2>&1 # create 800 MB swap file called swap in /cache (this is for systems running in stock slot where there's 1GB partition for cache that's almost not used - adjust size (count=<size in KB>) for your system). I didn't experience any deletion of this. If you do like Milp did, just re-run this script.
mkswap /cache/swap >> /storage/sdcard0/swap-setup.log 2>&1 # format the previously created 'swap' file for swap, just as you'd do with a partition
swapon /cache/swap >> /storage/sdcard0/swap-setup.log 2>&1 # use this file as swap
umount /preinstall >> /storage/sdcard0/swap-setup.log 2>&1 # not needed in CM12, it's not mounted (the folder is there though). Let's do it for legacy compatibility though :)
mkswap /dev/block/preinstall >> /storage/sdcard0/swap-setup.log 2>&1 # format the whole /preinstall partition as swap so we don't have to deal with stupid deletions or mounts or whatever later
swapon /dev/block/preinstall >> /storage/sdcard0/swap-setup.log 2>&1 # use preinstall as swap (this is kinda like mount for swap partition/device)
echo "Swap files installation finished." >> /storage/sdcard0/swap-setup.log 2>&1
date >> /storage/sdcard0/swap-setup.log 2>&1
Then you need this script running on boot, I use smanager as well:
Code:
#!/system/bin/sh
swapon /cache/swap # use the swap file created in the installation script for swap
swapon /dev/block/preinstall # use preinstall as swap
echo 15 > /proc/sys/vm/swappiness # set swappiness 15
Version with logs:
Code:
#!/system/bin/sh
date >> /storage/sdcard0/swap-init.log 2>&1
echo "Initializing swap." >> /storage/sdcard0/swap-init.log 2>&1
swapon /cache/swap >> /storage/sdcard0/swap-init.log 2>&1 # use the swap file created in the installation script for swap
swapon /dev/block/preinstall >> /storage/sdcard0/swap-init.log 2>&1 # use preinstall as swap
echo 15 1> /proc/sys/vm/swappiness 2>> /storage/sdcard0/swap-init.log # set swappiness 15
echo "Swap initialization done." >> /storage/sdcard0/swap-init.log 2>&1
date >> /storage/sdcard0/swap-init.log 2>&1
Milp said:
Been messing around with the swappiness a lot. 30-40 swappiness really enhances multitasking but the phone seems to get slow after some time because it has to do a lot of swap io i guess. Trying 15 now.
Click to expand...
Click to collapse
CM12's default is 60, which is way too much - after day of use I have sometimes been unable even to unlock the phone as seemingly the lock screen has been swapped away and it took several wakings of the phone before it allowed me to swipe the lockscreen up (I don't use any lock protection, just plain swipable lockscreen). It even worsened with Poweramp's custom lockscreen.
Will toy around with it for a bit in upcoming days.
I don't think I have ever gotten much over 300 MB swapped, making my current combined of almost 1,5 GB swap huge overkill. Will see after some time, but the /cache/swap file should be very sufficient and there's no need to mess up preinstall
I'm testing swap on stock 4.1.2 and I'm using app called Roehsoft Ram-Expander (I bougth this when I was xperia user). Seems to work but I'm wondering if the app is necessary.
Borchuck said:
I'm testing swap on stock 4.1.2 and I'm using app called Roehsoft Ram-Expander (I bougth this when I was xperia user). Seems to work but I'm wondering if the app is necessary.
Click to expand...
Click to collapse
Just added my scripts to post #2. It still needs a third-party app (SManager) to be run automatically though.
It seems the app you mentioned puts the swap file on the sd card, while my script puts it to internal memory to the /cache partition. If internal storage is faster than SD (haven't tested, but it probably is), then the swap file created by my script should be faster as well. On the other hand, the app is easily controllable through its UI, while my script is just a script and you need to run it by a third-party app anyways. So whatever you like more, use it
Uploaded automated script for creation and initialization of swap in /cache (to be run on startup). Please let me know if you stumble upon any error
If there's a problem with swap file creation, make sure you have busybox installed with support for df - the built-in df in my shell doesn't recognize the -k flag so it's not good for free space counting.
LuH said:
Just added my scripts to post #2. It still needs a third-party app (SManager) to be run automatically though.
It seems the app you mentioned puts the swap file on the sd card, while my script puts it to internal memory to the /cache partition. If internal storage is faster than SD (haven't tested, but it probably is), then the swap file created by my script should be faster as well. On the other hand, the app is easily controllable through its UI, while my script is just a script and you need to run it by a third-party app anyways. So whatever you like more, use it
Click to expand...
Click to collapse
Thanks for answer!
In this app you can choose swap file path and I've chose /preinstall (512 mb).
Scripts can be ran by placing them into init.d folder, am I right?
Borchuck said:
Thanks for answer!
In this app you can choose swap file path and I've chose /preinstall (512 mb).
Scripts can be ran by placing them into init.d folder, am I right?
Click to expand...
Click to collapse
In theory yes, but SELinux somehow blocks it in CM12 - that's why you need to run it using SManager instead. I have no idea what stock system does on boot.
Borchuck said:
Scripts can be ran by placing them into init.d folder, am I right?
Click to expand...
Click to collapse
Unless something has changed, init.d is disabled by default in CM11/12. I haven't checked Cm11 in a long time, nor in 12.1, though. There's an app that emulates it, as well as at least one app that tries to enable it, in the play store. The former works as it should in both KK and LP as long as you accept its limitations (scripts get run when the app autostarts, after boot), but I have no idea if the latter does.
Using /cache is a neat idea, when you're installed into the stock partitions. It's there and almost completely unused in CM12/.1, and it's not like we can usefully reallocate it or anything 'cause Motorola. Getting the webtop/preinstall stuff going is an extra step, and that space might be put to better use anyway. Though, preinstall is just about the perfect size for a swap...
The problems I see with swapping on any internal partition are 1: you're going to wear the eMMC out a lot faster writing to it all the time (though how much faster is anyone's guess), and 2: the eMMC in our phone isn't especially fast. It's not slow, but it's slower than a modern high-end SD card, and definitely slower than RAM.
I'm a little curious about how fast our device can read/write to external SD cards. A good one, with both fast read/write and good small-block performance, would be "safer" to use for swapping. If it happens to wear out, pop in a new one, good to go.
@LuH
Maybe you should use zRAM? I use it on my phone ...
Fervi
Septfox said:
The problems I see with swapping on any internal partition are 1: you're going to wear the eMMC out a lot faster writing to it all the time (though how much faster is anyone's guess),
Click to expand...
Click to collapse
Well, I've had my device for three years now so if it decides to retire, it's worked enough to earn it However, I have yet to see a phone dead because of worn out memory - it always was some radio chip in my previous ones. So 'm taking my chances I have considered the risk, just don't think it will affect me.
Septfox said:
and 2: the eMMC in our phone isn't especially fast. It's not slow, but it's slower than a modern high-end SD card, and definitely slower than RAM. I'm a little curious about how fast our device can read/write to external SD cards. A good one, with both fast read/write and good small-block performance, would be "safer" to use for swapping. If it happens to wear out, pop in a new one, good to go.
Click to expand...
Click to collapse
eMMC is of course slower than RAM, but my SD doesn't seem to outperform it - at least in big file read and writes it's about the same. I haven't found a working benchmark app for random I/O testing, but I think the onboard eMMC and my SanDisk 64GB SDXC U1 are on par in D4. Then again, I've had my SD longer than I've had my D4, originally bought it for my previous Windows Mobile 6.5 Sony Ericsson Xperia X2
Attached benchmark (usually ~600 MB write and read): SD card (SanDisk 64 GB U1) R13.56/W9,57, SD card (eMMC storage partition) R15.82/W5.31, Internal memory (eMMC /data partition) R8.90/W4.23, Custom location (eMMC /cache partition) R13.82/W4.17.
I don't get why three partitions of same eMMC flash memory chip get so different results, either it's differently managed by the system (but why give preference to media storage?), or the parts of chips are worn out differently, or the benchmarking app sucks
ferviverus said:
@LuH
Maybe you should use zRAM? I use it on my phone ...
Click to expand...
Click to collapse
I'll probably try as well, but thought I'll give swapping a try first... I heard more problems than advantages about using zRAM on D4, what's your experience?
LuH said:
Attached benchmark (usually ~600 MB write and read): SD card (SanDisk 64 GB U1) R13.56/W9,57, SD card (eMMC storage partition) R15.82/W5.31, Internal memory (eMMC /data partition) R8.90/W4.23, Custom location (eMMC /cache partition) R13.82/W4.17.
I don't get why three partitions of same eMMC flash memory chip get so different results, either it's differently managed by the system (but why give preference to media storage?), or the parts of chips are worn out differently, or the benchmarking app sucks
Click to expand...
Click to collapse
Double the write speed isn't "outperforming"? :v
Big file transfers are mostly irrelevant, small-block performance is where you need speed. You can mount both SD and internal storage in Safestrap, test there using CrystalDiskMark (which gives not only bulk transfer speeds, but 512k and 4k as well).
My results, using three passes and a 500mb test file
Internal storage
Sequential Read : 19.844 MB/s
Sequential Write : 13.899 MB/s
Random Read 512KB : 18.571 MB/s
Random Write 512KB : 10.263 MB/s
Random Read 4KB (QD=1) : 3.917 MB/s [ 956.3 IOPS]
Random Write 4KB (QD=1) : 1.770 MB/s [ 432.2 IOPS]
Random Read 4KB (QD=32) : 4.964 MB/s [ 1212.0 IOPS]
Random Write 4KB (QD=32) : 1.947 MB/s [ 475.4 IOPS]
External storage/SD card (Sandisk 16gb Class 10/UC1)
Sequential Read : 14.311 MB/s
Sequential Write : 4.907 MB/s (!)
Random Read 512KB : 13.667 MB/s
Random Write 512KB : 1.468 MB/s
Random Read 4KB (QD=1) : 2.267 MB/s [ 553.5 IOPS]
Random Write 4KB (QD=1) : 0.985 MB/s [ 240.5 IOPS]
Random Read 4KB (QD=32) : 2.512 MB/s [ 613.4 IOPS]
Random Write 4KB (QD=32) : 1.251 MB/s [ 305.5 IOPS]
The choice is clear here, but my card is pretty old...yours may fare better. Sandisk cards are generally known for balanced performance.
As for the different results...I dunno. The eMMC partitions should be all the same, it's all on the same flash after all. The only thing I can think of is filesystem differences, but the internal partitions are all ext3, right?
As sad as it makes me to say it, zRAM...isn't very good at the moment. It seems to slow the phone a bit while enabled, for an effectively minimal amount of extra memory. You'd probably be better off increasing minfree thresholds to keep things killed when they're no longer needed, rather than stressing the memory management even more just to keep a couple more apps "loaded".
@LuH
Well, i don't use CM (it doesn't support lapdock), but I use on stock zRam - I saved ~4.5MB (6.9MB compressed to 2.5MB) ... but I read on internet, that zRam is faster than Swap
Fervi
Failed to send the attachment before, giving now. Anyways, probably will try your suggestion to do it from computer later.
Septfox said:
Double the write speed isn't "outperforming"? :v
Click to expand...
Click to collapse
Well, I'm not really concerned by swapping out - that usually takes place when the phone is at rest. I specifically want it to wake up fast -> read speed is the bottleneck and there it's not as big a difference.
Septfox said:
As for the different results...I dunno. The eMMC partitions should be all the same, it's all on the same flash after all. The only thing I can think of is filesystem differences, but the internal partitions are all ext3, right?
Click to expand...
Click to collapse
Well, it looks as though the smaller the partition, the worse the performance is. No idea why. The biggest (and fastest), "Internal SD card" or Media storage or whatever it's called at different system, the one mounted as /sdcard, is exFAT, others are mostly ext3 (preinstall, cache, system and data) and webtop is ext4.
Septfox said:
As sad as it makes me to say it, zRAM...isn't very good at the moment. It seems to slow the phone a bit while enabled, for an effectively minimal amount of extra memory. You'd probably be better off increasing minfree thresholds to keep things killed when they're no longer needed, rather than stressing the memory management even more just to keep a couple more apps "loaded".
Click to expand...
Click to collapse
Exactly, I need hundreds of MBs, not single megabytes, to outweigh the performance loss.
LuH said:
Well, I'm not really concerned by swapping out - that usually takes place when the phone is at rest. I specifically want it to wake up fast -> read speed is the bottleneck and there it's not as big a difference.
Click to expand...
Click to collapse
Swapping should be happening every time the phone starts running out of memory. So, uh, pretty much every other second.
Run an app > OOM > store "oldest" objects in RAM to pagefile/swap partition > load latest app into RAM > user does something in-app requiring a service provider or some other additional data being loaded > OOM > vicious cycle continues
LuH said:
Well, it looks as though the smaller the partition, the worse the performance is. No idea why. The biggest (and fastest), "Internal SD card" or Media storage or whatever it's called at different system, the one mounted as /sdcard, is exFAT, others are mostly ext3 (preinstall, cache, system and data) and webtop is ext4.
Click to expand...
Click to collapse
Oh right, I guess the internal "SD" would be exFAT or some other FAT variant, since it's treated as a removable card.
Write speed being lower on smaller flash partitions makes sense, if they already have data in them, kind of.
If a write is attempted on a page within a flash block which already has data in it, you have to go through the whole read-erase-modify-write process, dragging overall speed down...
Unless our flash supports TRIM, which would pre-emptively erase blocks while the filesystem is idle; I'm pretty sure it unfortunately doesn't. So it's rare that an app writing files is going to happen upon a nice, big contiguous area of already-cleared blocks that can be simply written to.
But then, /cache is almost certainly empty (or minimally filled), so it makes no sense for writes on it to be slow.
*shrugs* I guess you could try formatting it and see if the write speed improves.
LuH said:
Exactly, I need hundreds of MBs, not single megabytes, to outweigh the performance loss.
Click to expand...
Click to collapse
zRAM is 256mb at default, and you can probably count it being effectively double that at least, once things are compressed into it.
It just...doesn't seem to work very quickly. YMMV though. It's enabled by default on the last few CM12 nightlies, so if you've updated recently (well, and are using 12), it's already on.
If you want it to be bigger/smaller, the value isn't baked in; utilities such as Kernel Aduitor can resize it. I tried increasing it to 500mb just to see if I could break something, and the phone...seemed to run slightly better for some reason. So that was a thing.
And reiteration: it's worthwhile to modify minfree settings. At least in Lollipop, if you keep free memory floating above 200mb, it runs much better. Apps will need to relaunch more, but relaunching is usually a lot faster than letting free memory sink to the 160-170mb range that stock values allow, and waiting while the memory manager chokes.
Empty App: 200 and Hidden App: 160 is adequate.
And speaking of the memory manager, joojoobee's kernel has a bunch of patches merged in that aren't in the nightlies yet, which improve memory handling somewhat (phone still starts choking under 200mb, but it's usable).
On the performance side:
Have any of you had any positive long term experiences with swap enabled? While swap gave me the ability to run several huge tasks all at once, in the long run it made my system very unstable. Things would crash out of random, the phone would take ages to wake up from sleep sometimes etc.
I have now upgraded to cm12.1 and disabled my script again.

Categories

Resources