[G1 Android Development] farmatito:
Attached two scripts to be pushed to /etc/init.d/ to enable

ramzswap and/or swap and to tune the system. This settings

are what I use so they are mostly a matter of personal taste.

Enjoy and use at your own risk.

For swap and ramzswap:

#!/system/bin/sh
BB="busybox"
# Swap and compcache setup
USE_SWAP=1;
USE_COMPCACHE=1;
SWAPINESS=40;
VFS_CACHE_PRESSURE=50;
RAMZSWAP_DISKSIZE=32120;
DEV_RAMZSWAP=/dev/block/ramzswap0;
DEV_SWAP=/dev/block/mmcblk0p3;

echo $SWAPINESS > /proc/sys/vm/swappiness;
echo $VFS_CACHE_PRESSURE > /proc/sys/vm/vfs_cache_pressure

swapoff $DEV_RAMZSWAP 2> /dev/null;
rzscontrol $DEV_RAMZSWAP --reset 2> /dev/null;
swapoff $DEV_SWAP 2> /dev/null;
echo 3 > /proc/sys/vm/drop_caches

if [ "$1" = "off" ] ; then
echo "swap and ramzswap disabled";
exit 0
fi

if [ $USE_COMPCACHE -eq 1 ] ; then
# Compcache setup
RET=`lsmod | grep -c ramzswap`;
if [ "x$RET" = "x0" ] ; then
/system/bin/insmod /system/lib/modules/`uname -r`/kernel/drivers/staging/ramzswap/ramzswap.ko;
else
echo "ramzswap module already loaded";
fi;
if [ "x$?" = "x0" ] ; then
sleep 1;
MAJOR=`cat /proc/devices | grep ramzswap | cut -f1 -d ' '`;
if [ -z "$MAJOR" ] ; then
echo "Ramzswap not supported, disabling"
else
if [ ! -b $DEV_RAMZSWAP ] ; then
echo "Creating $DEV_RAMZSWAP";
mknod $DEV_RAMZSWAP b $MAJOR 0;
fi
if [ "x$?" = "x0" ] ; then
echo "Initialise $DEV_RAMZSWAP"
rzscontrol $DEV_RAMZSWAP --disksize_kb=$RAMZSWAP_DISKSIZE --init;
sleep 3;
echo "Enabling swap on $DEV_RAMZSWAP"
swapon $DEV_RAMZSWAP;
fi;
fi;
fi;
fi;
# ramzswap was created earlier ans will have higher priority
if [ $USE_SWAP -eq 1 ] ; then
if [ -b $DEV_SWAP ] ; then
echo "Enabling swap on $DEV_SWAP"
swapon $DEV_SWAP;
else
echo "Swap partition $DEV_SWAP not found";
fi
fi;

To finetune settings (I think this will conflict with Setcpu so don't use both):

#!/system/bin/sh
# 122880 160000 176000 245760 352000 480000 528000 537600 556800 576000 614400
SCALING_MIN=352000;
SCALING_MAX=576000;
POWERSAVE_BIAS=200; # default: 0
SAMPLING_RATE=2000000;
CPU_UP_THRESHOLD=45; # default 40, percent cpu usage before going up a speed step
IGNORE_NICE_LOAD=0;
PAGE_CLUSTER=0; # default: 3 Changes Page clustering from 8 to 2
LAPTOP_MODE=5; # default: 0 Helps keep SSD from getting worn
DIRTY_EXPIRE_CENTISECS=5000; # default: 3000
DIRTY_WRITEBACK_CENTISECS=800; # default: 500
DIRTY_BACKGROUND_RATIO=10; # default: 5
DIRTY_RATIO=16; # default: 10
# standard=0,aggressive=1, more aggressive=2
LOWMEMORY_KILLER_PROFILE=0;
SCHEDULER="noop";
# for deadline scheduler
DEADLINE_IO_SCHED_FIFO_BATCH=1;

echo $SCALING_MIN > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq;
echo $SCALING_MAX > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq;
echo $POWERSAVE_BIAS > /sys/devices/system/cpu/cpufreq/ondemand/powersave_bias;
echo $SAMPLING_RATE > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate;
echo $CPU_UP_THRESHOLD > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold;
echo $IGNORE_NICE_LOAD > /sys/devices/system/cpu/cpufreq/ondemand/ignore_nice_load;
echo $PAGE_CLUSTER > /proc/sys/vm/page-cluster;
echo $LAPTOP_MODE > /proc/sys/vm/laptop_mode;
echo $DIRTY_EXPIRE_CENTISECS > /proc/sys/vm/dirty_expire_centisecs;
echo $DIRTY_WRITEBACK_CENTISECS > /proc/sys/vm/dirty_writeback_centisecs;
echo $DIRTY_BACKGROUND_RATIO > /proc/sys/vm/dirty_background_ratio;
echo $DIRTY_RATIO > /proc/sys/vm/dirty_ratio;

# Configure the lowmemorykiller
if test "x$LOWMEMORY_KILLER_PROFILE" = "x1" ; then
# Configure the lowmemorykiller - aggressive
echo "1536,2048,4096,5120,15360,23040" > /sys/module/lowmemorykiller/parameters/minfree
elif test "x$LOWMEMORY_KILLER_PROFILE" = "x2" ; then
# Configure the lowmemorykiller - more aggressive
echo "1536,3072,4096,21000,23000,25000" > /sys/module/lowmemorykiller/parameters/minfree
fi;

# Set scheduler for mtdblocks and mmc
for i in `ls /sys/block/mtdblock*` /sys/block/mmcblk0;
do
echo $SCHEDULER > $i/queue/scheduler;
if [ "$SCHEDULER" = "deadline" ] ; then
echo $DEADLINE_IO_SCHED_FIFO_BATCH > $i/queue/iosched/fifo_batch
fi;
done;