[Galaxy S Advance I9070 Android Development] fbs:
If anyone's interested, here are the two main "scripts" my tweak uses. Anyone could read it inside the .zip or /system/etc/init.d folder, but I know some are lazy then I'll copy/paste here :P

#!/system/bin/sh

#hbbtweaksv27

echo z1hbbkern START

#activate KSM, but less pages in a bunch to prevent lagging

echo 51 > /sys/kernel/mm/ksm/sleep_millisecs;

echo 29 > /sys/kernel/mm/ksm/pages_to_scan;

echo 1 > /sys/kernel/mm/ksm/run;

#and activate uksm if it has it

echo 1 > /sys/kernel/mm/uksm/run;

echo medium > /sys/kernel/mm/uksm/cpu_governor;

echo 439 > /sys/kernel/mm/uksm/sleep_millisecs;

#I read somewhere 5ms should be the maximum for a dual-core, our default was 10ms

echo "3999971" > /proc/sys/kernel/sched_latency_ns;

echo "1000003" > /proc/sys/kernel/sched_shares_window;

#higher avg time, maybe lessen the overhead

echo "2003" > /proc/sys/kernel/sched_time_avg;

#1.5ms was the minimum time a thread could be on cpu.

#I think it's too much time, lowered to 0,1ms. Same for threads that are waking up

echo "100003" > /proc/sys/kernel/sched_wakeup_granularity_ns;

echo "100003" > /proc/sys/kernel/sched_min_granularity_ns;

echo "150000" > /proc/sys/kernel/sched_migration_cost;

#a forked thread should run right after

echo 1 > /proc/sys/kernel/sched_child_runs_first;

echo 0 > /proc/sys/kernel/sched_tunable_scaling;

#won't enforce a time for real-time tasks.. maybe lessen the overhead?

echo -1 > /proc/sys/kernel/sched_rt_runtime_us;

echo 2000000 > /proc/sys/kernel/sched_rt_period_us;

#updated file-data that's cached in ram will stay on it 63s before being written

echo "6317" > /proc/sys/vm/dirty_writeback_centisecs;

echo "6317" > /proc/sys/vm/dirty_expire_centisecs;

#but if we have dynamic writebacks, it will stay only 3s when display is active and 123s when not

echo "317" > /proc/sys/vm/dirty_writeback_active_centisecs;

echo "12301" > /proc/sys/vm/dirty_writeback_suspend_centisecs;

#let's almost deactivate swapping, our "disc" is ultra-super-slow!

echo "1" > /proc/sys/vm/swappiness;

#let's fix the amount of memory that could be dirty before it start writing to mmc

echo "8000000" > /proc/sys/vm/dirty_background_bytes;

#let's fix the maximum amount of memory an app can defile before it get blocked

echo "14000000" > /proc/sys/vm/dirty_bytes;

#4mb really "free", not even used for caching

echo 4096 > /proc/sys/vm/min_free_kbytes;

#1=same amount for every zone.. (?)

echo 1 > /proc/sys/vm/min_free_order_shift;

#3s frequency for stats. idk if there's any drawbacks

echo 3 > /proc/sys/vm/stat_interval;

echo 0 > /proc/sys/vm/highmem_is_dirtyable;

echo "30" > /proc/sys/kernel/panic;

echo "0" > /proc/sys/kernel/panic_on_oops;

echo "0" > /proc/sys/vm/oom_kill_allocating_task;

#swap as little as possible in a bunch

echo "1" > /proc/sys/vm/page-cluster;

#less wait time, less complexity.. less memory, less packet size

echo 5 > /proc/sys/net/ipv4/tcp_fin_timeout;

echo 1 > /proc/sys/net/ipv4/tcp_timestamps;

echo 5 > /proc/sys/net/ipv4/tcp_challenge_ack_limit;

echo 1 > /proc/sys/net/ipv4/tcp_sack;

echo 0 > /proc/sys/net/ipv4/tcp_dsack;

echo 64 > /proc/sys/net/ipv4/tcp_base_mss;

echo 0 > /proc/sys/net/ipv4/tcp_retrans_collapse;

echo 0 > /proc/sys/net/ipv4/tcp_abc;

echo 0 > /proc/sys/net/ipv4/tcp_mtu_probing;

echo 0 > /proc/sys/net/ipv4/tcp_ecn;

echo 21 > /proc/sys/net/ipv4/tcp_reordering;

echo 262144 > /proc/sys/net/core/wmem_default;

echo 262144 > /proc/sys/net/core/rmem_default;

echo 1 > /proc/sys/net/ipv4/tcp_no_metrics_save;

echo 512 1024 4096 > /proc/sys/net/ipv4/tcp_mem;

echo illinois > /proc/sys/net/ipv4/tcp_congestion_control;

#max of 4mb for net reads and writes, should be enough

echo 4194304 > /proc/sys/net/core/rmem_max;

echo 4194304 > /proc/sys/net/core/wmem_max;

#abb-codec audio: higher gains and low power mode activated

echo on > /sys/kernel/abb-codec/anagain3;

echo gain=0 > /sys/kernel/abb-codec/anagain3;

echo on > /sys/kernel/abb-codec/hsldiggain;

echo gain=0 > /sys/kernel/abb-codec/hsldiggain;

echo on > /sys/kernel/abb-codec/hsrdiggain;

echo gain=0 > /sys/kernel/abb-codec/hsrdiggain;

echo on > /sys/kernel/abb-codec/hslowpow;

echo mode=1 > /sys/kernel/abb-codec/hslowpow;

echo on > /sys/kernel/abb-codec/hsdaclowpow;

echo mode=1 > /sys/kernel/abb-codec/hsdaclowpow;

echo on > /sys/kernel/abb-codec/hshpen;

echo mode=1 > /sys/kernel/abb-codec/hshpen;

echo on > /sys/kernel/abb-codec/classdhpg;

echo gain=10 > /sys/kernel/abb-codec/classdhpg;

echo on > /sys/kernel/abb-codec/classdwg;

echo gain=10 > /sys/kernel/abb-codec/classdwg;

echo on > /sys/kernel/abb-codec/addiggain2;

echo gain=4 > /sys/kernel/abb-codec/addiggain2;

echo on > /sys/kernel/abb-codec/eardiggain;

echo gain=0 > /sys/kernel/abb-codec/eardiggain;

echo 1 > /sys/kernel/abb-codec/chargepump;

#ramp to 800mhz when you touch the screen

echo on > /sys/kernel/mxt224e/touchboost;

echo 800000 > /sys/kernel/mxt224e/touchboost_freq;

#no fsync.

echo 1 > /sys/kernel/fsync/mode;

#mali (gpu) stuff

echo 0 > /sys/module/mali/parameters/mali_debug_level;

echo 6 > /sys/module/mali/parameters/mali_oskmem_allocorder;

#439ms instead of 1s to verify mali(gpu)'s usage

echo 439 > /sys/module/mali/parameters/mali_utilization_sampling_rate;

echo 439 > /sys/module/mali/parameters/mali_pm_sampling_rate;

echo 50331648 > /sys/module/mali/parameters/pre_allocated_memory_size_max;

echo 48 > /sys/module/mali/parameters/mali_l2_max_reads;

echo 0 > /sys/module/mali/parameters/mali_pp_scheduler_balance_jobs;

#our cpu's own powersaving is buggy and we have pegasusq :P

echo 0 > /sys/devices/system/cpu/sched_mc_power_savings;

echo 0 > /sys/module/dhd/parameters/dhdpm_fast;

echo 4 > /d/cpuidle/deepest_state;

#don't try to squeeze too much or too frequently (?) lessen overhead (?)

echo 64 > /sys/module/lowmemorykiller/parameters/cost;

#order of death! starting from right to left in number of pages

#first it will kill empty apps when we have less than 30720x4096 (120MB) of free ram

minfree=16384,18432,20480,24576,26624,30720;

lmk=/sys/module/lowmemorykiller/parameters/minfree;

minboot=`cat $lmk`;

while sleep 10; do

if [ `cat $lmk` != $minboot ]; then

[ `cat $lmk` != $minfree ] && echo $minfree > $lmk || exit;

fi;

done&

#I really don't know if these will help to lessen overhead or lessen lags, but....

sysctl -w vm.extfrag_threshold=800;

sysctl -w kernel.randomize_va_space=0;

echo 128 > /proc/sys/kernel/random/read_wakeup_threshold;

echo 256 > /proc/sys/kernel/random/write_wakeup_threshold;

#let's use pegasusq as governor as it's multi-core AWARE and it shut downs our second cpu

echo pegasusq > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor;

governor=reset;

while true; do

current=`cut -d\[ -f2 /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor | cut -d\] -f1`;

if [ $governor != $current ]; then

governor=$current;

if [ $governor == "pegasusq" ]; then

echo 40000 > /sys/devices/system/cpu/cpufreq/pegasusq/sampling_rate;

echo 400000 > /sys/devices/system/cpu/cpufreq/pegasusq/freq_for_responsiveness;

echo 70 > /sys/devices/system/cpu/cpufreq/pegasusq/up_threshold_at_min_freq;

echo 99 > /sys/devices/system/cpu/cpufreq/pegasusq/up_threshold;

echo 20 > /sys/devices/system/cpu/cpufreq/pegasusq/down_differential;

echo 20 > /sys/devices/system/cpu/cpufreq/pegasusq/freq_step;

echo 800000 > /sys/devices/system/cpu/cpufreq/pegasusq/hotplug_freq_1_1;

echo 400000 > /sys/devices/system/cpu/cpufreq/pegasusq/hotplug_freq_2_0;

echo 300 > /sys/devices/system/cpu/cpufreq/pegasusq/hotplug_rq_1_1;

echo 110 > /sys/devices/system/cpu/cpufreq/pegasusq/hotplug_rq_2_0;

echo 3 > /sys/devices/system/cpu/cpufreq/pegasusq/cpu_up_rate;

echo 2 > /sys/devices/system/cpu/cpufreq/pegasusq/cpu_down_rate;

echo 2 > /sys/devices/system/cpu/cpufreq/pegasusq/sampling_down_factor;

fi;

if [ $governor == "lulzactiveq" ]; then

echo 3 > /sys/devices/system/cpu/cpufreq/lulzactiveq/screen_off_min_step;

echo 90 > /sys/devices/system/cpu/cpufreq/lulzactiveq/inc_cpu_load;

echo 40 > /sys/devices/system/cpu/cpufreq/lulzactiveq/dec_cpu_load;

echo 80000 > /sys/devices/system/cpu/cpufreq/lulzactiveq/up_sample_time;

echo 80000 > /sys/devices/system/cpu/cpufreq/lulzactiveq/down_sample_time;

echo 120000 > /sys/devices/system/cpu/cpufreq/lulzactiveq/hotplug_sampling_rate;

echo 2 > /sys/devices/system/cpu/cpufreq/lulzactiveq/cpu_up_rate;

echo 2 > /sys/devices/system/cpu/cpufreq/lulzactiveq/cpu_down_rate;

echo 1 > /sys/devices/system/cpu/cpufreq/lulzactiveq/pump_up_step;

echo 1 > /sys/devices/system/cpu/cpufreq/lulzactiveq/pump_down_step;

echo 800000 > /sys/devices/system/cpu/cpufreq/lulzactiveq/hotplug_freq_1_1;

echo 400000 > /sys/devices/system/cpu/cpufreq/lulzactiveq/hotplug_freq_2_0;

echo 300 > /sys/devices/system/cpu/cpufreq/lulzactiveq/hotplug_rq_1_1;

echo 110 > /sys/devices/system/cpu/cpufreq/lulzactiveq/hotplug_rq_2_0;

fi;

fi;

sleep 809;

done&

#no sleepers seems to help. others are experimental

mount -t debugfs none /sys/kernel/debug;

echo "ARCH_POWER" > /sys/kernel/debug/sched_features;

echo "NO_GENTLE_FAIR_SLEEPERS" > /sys/kernel/debug/sched_features;

echo "NO_NORMALIZED_SLEEPERS" > /sys/kernel/debug/sched_features;

echo "NO_NEW_FAIR_SLEEPERS" > /sys/kernel/debug/sched_features;

echo "NO_START_DEBIT" > /sys/kernel/debug/sched_features;

echo "NO_NEXT_BUDDY" > /sys/kernel/debug/sched_features;

echo "NONTASK_POWER" > /sys/kernel/debug/sched_features;

echo "AFFINE_WAKEUPS" > /sys/kernel/debug/sched_features;

#let's force the system user interface to have higher priority

while sleep 1; do

if [ `pidof com.android.systemui` ]; then

systemui=`pidof com.android.systemui`;

busybox renice -18 $systemui;

echo -17 > /proc/$systemui/oom_adj;

chmod 100 /proc/$systemui/oom_adj;

exit;

fi;

done&

#and some launchers too

list="com.android.launcher org.adw.launcher org.adwfreak.launcher com.anddoes.launcher com.android.lmt com.chrislacy.actionlauncher.pro com.cyanogenmod.trebuchet com.gau.go.launcherex com.mobint.hololauncher com.mobint.hololauncher.hd com.teslacoilsw.launcher com.tsf.shell org.zeam";

while sleep 60; do

for class in $list; do

if [ `pgrep $class` ]; then

launcher=`pgrep $class`;

echo -17 > /proc/$launcher/oom_adj;

chmod 100 /proc/$launcher/oom_adj;

busybox renice -18 $launcher;

fi;

done;

exit;

done&

echo hbbkern: adjusting frequencies and voltages/undervolt

########################## OVERCLOCK & UNDERVOLT. The alternate versions changes these!

#and you can change it too. higher VARM = higher voltage. in hexadecimal

#This is ULTRA-STABLE on my phone but yours are not like mine..

#################

#overclock gpu if needed

echo 1 > /sys/kernel/mali/mali_auto_boost;

#720mhz while "boosted" (idx 22)

echo idx=22 > /sys/kernel/mali/mali_boost_high;

#300mhz while not (idx 2)

echo idx=2 > /sys/kernel/mali/mali_boost_low;

#let's scale from 200mhz to 1050mhz

echo 200000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq;

echo 1050000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq;

#200mhz

echo varm=0x10 > /sys/kernel/liveopp/arm_step0;

echo set_volt=1 > /sys/kernel/liveopp/arm_step0;

#400mhz

echo varm=0x10 > /sys/kernel/liveopp/arm_step1;

echo set_volt=1 > /sys/kernel/liveopp/arm_step1;

#600mhz

echo varm=0x19 > /sys/kernel/liveopp/arm_step2;

echo set_volt=1 > /sys/kernel/liveopp/arm_step2;

#800mhz

echo varm=0x22 > /sys/kernel/liveopp/arm_step3;

echo set_volt=1 > /sys/kernel/liveopp/arm_step3;

#1000mhz

echo varm=0x2C > /sys/kernel/liveopp/arm_step4;

echo set_volt=1 > /sys/kernel/liveopp/arm_step4;

#1050mhz

echo varm=0x2E > /sys/kernel/liveopp/arm_step5;

echo set_volt=1 > /sys/kernel/liveopp/arm_step5;

echo z1hbbkern END

#!/system/bin/sh

#hbbtweaksv27

echo z2hbbmounts START

tune2fs -o journal_data_writeback /dev/block/mmcblk0p4

tune2fs -o journal_data_writeback /dev/block/mmcblk0p5

tune2fs -O ^has_journal /dev/block/mmcblk0p4

tune2fs -O ^has_journal /dev/block/mmcblk0p5

sleep 31;

#let's not update access time for each file/folder accessed (noatime, nodiratime)

#let's write only after 61 secs instead of 5

#"writeback" is the fastest metadata writing mode and "discard" will clean erased zones providing better writting performance after

busybox mount -o remount,noatime,nodiratime,rw,barrier=1,noauto_da_alloc,discard,delalloc,nobh,nodev,nosuid,commit=61 /data /data;

busybox mount -o remount,noatime,nodiratime,rw,barrier=0,noauto_da_alloc,discard,delalloc,nobh,nodev,nosuid,commit=67 /cache /cache;

#quem sabe tenha writeback?

busybox mount -o remount,noatime,nodiratime,data=writeback,rw,barrier=0,noauto_da_alloc,discard,delalloc,nobh,nodev,nosuid,commit=61 /cache /cache;

busybox mount -o remount,noatime,nodiratime,data=writeback,rw,barrier=1,noauto_da_alloc,discard,delalloc,nobh,nodev,nosuid,commit=67 /data /data;

for k in $(busybox mount | grep relatime | cut -d " " -f3); do busybox mount -o remount,noatime,nodiratime $k $k; done;

echo 15 > /proc/sys/fs/lease-break-time;

sleep 31;

#let's cache 2000 writes/reads requests

#no merging and no scheduler if not writing to a real mmc (less overhead?)

#NO read_ahead seems controversial.. but we shouldn't waste our time trying to read

# and fillin our ram with unrequested data

for i in $(busybox find /sys/devices -name queue);

do

echo 2000 > $i/nr_requests;

echo 2 > $i/rq_affinity;

echo 2 > $i/nomerges;

echo 0 > $i/rotational;

echo 0 > $i/add_random;

echo 0 > $i/iostats;

echo noop > $i/scheduler;

echo 0 > $i/read_ahead_kb;

done;

#for mmcs it will merge and try to use sioplus as scheduler..

for i in $(busybox find /sys/devices -name queue |grep mmc);

do

echo 0 > $i/nomerges;

echo row > $i/scheduler;

echo sio > $i/scheduler;

echo sioplus > $i/scheduler;

echo 0 > $i/read_ahead_kb;

done;

#in doubt about it for the external one

echo "128" > /sys/devices/virtual/bdi/179:96/read_ahead_kb;

CI() {

echo $1 > /sys/block/mmcblk0/queue/iosched/$2

echo $1 > /sys/block/mmcblk1/queue/iosched/$2

}

#scheduler tweaks

scheduler=reset;

while sleep 461; do

current=`cut -d\[ -f2 /sys/block/mmcblk0/queue/scheduler | cut -d\] -f1`;

if [ $scheduler != $current ]; then

scheduler=$current;

if [ $scheduler == "deadline" ]; then

CI 200 read_expire;

CI 500 write_expire;

CI 4 writes_starved;

CI 0 front_merges;

CI 8 fifo_batch;

elif [ $scheduler == "row" ]; then

CI 100 hp_read_quantum;

CI 75 rp_read_quantum;

CI 3 lp_read_quantum;

CI 6 hp_swrite_quantum;

CI 5 rp_swrite_quantum;

CI 4 rp_write_quantum;

CI 12 lp_swrite_quantum;

CI 10 read_idle;

CI 15 read_idle_freq;

elif [ $scheduler == "cfq" ]; then

CI 4 quantum;

CI 80 fifo_expire_sync;

CI 330 fifo_expire_async;

CI 12582912 back_seek_max;

CI 1 back_seek_penalty;

CI 60 slice_sync;

CI 50 slice_async;

CI 2 slice_async_rq;

CI 0 slice_idle;

CI 0 group_idle;

CI 1 low_latency;

fi;

fi;

done&

#nada de gastar memoria com internet, nossas conexoes sao ultra-lentas

setprop net.tcp.buffersize.evdo ""

setprop net.tcp.buffersize.evdo_b ""

setprop net.tcp.buffersize.gprs ""

setprop net.tcp.buffersize.hsdpa ""

setprop net.tcp.buffersize.hspa ""

setprop net.tcp.buffersize.hspap ""

setprop net.tcp.buffersize.hsupa ""

setprop net.tcp.buffersize.edge ""

setprop net.tcp.buffersize.umts ""

setprop net.tcp.buffersize.dchspap ""

setprop net.tcp.buffersize.lte ""

setprop net.tcp.buffersize.default 1024,32768,1048576,1024,4096,65536

setprop net.tcp.buffersize.wifi 4096,524288,1048576,4096,1048576,4194304

echo z2hbbmounts END

sleep 2;

#DROP all cached stuff till now. We won't need again all stuff that have been read while booting

sync;

sysctl -w vm.drop_caches=3;