Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- init tweaks
- S01sysctl
- #!/system/bin/sh
- sysctl -p
- S70zipalign
- #!/system/bin/sh
- # Automatic ZipAlign by Wes Garner
- # ZipAlign files in /data that have not been previously ZipAligned (using md5sum)
- # Thanks to oknowton for the changes
- # Changelog:
- # 1.1 (12/1/09) Switched to zipalign -c 4 to check the apk instead of MD5 (oknowton)
- # 1.0 (11/30/09) Original
- LOG_FILE=/data/zipalign.log
- if [ -e $LOG_FILE ]; then
- rm $LOG_FILE;
- fi;
- echo "Starting Automatic ZipAlign $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;
- for apk in /data/app/*.apk ; do
- zipalign -c 4 $apk;
- ZIPCHECK=$?;
- if [ $ZIPCHECK -eq 1 ]; then
- echo ZipAligning $(basename $apk) | tee -a $LOG_FILE;
- zipalign -f 4 $apk /cache/$(basename $apk);
- if [ -e /cache/$(basename $apk) ]; then
- cp -f -p /cache/$(basename $apk) $apk | tee -a $LOG_FILE;
- rm /cache/$(basename $apk);
- else
- echo ZipAligning $(basename $apk) Failed | tee -a $LOG_FILE;
- fi;
- else
- echo ZipAlign already completed on $apk | tee -a $LOG_FILE;
- fi;
- done;
- for apk in /system/app/*.apk ; do
- zipalign -c 4 $apk;
- ZIPCHECK=$?;
- if [ $ZIPCHECK -eq 1 ]; then
- echo ZipAligning $(basename $apk) | tee -a $LOG_FILE;
- zipalign -f 4 $apk /cache/$(basename $apk);
- if [ -e /cache/$(basename $apk) ]; then
- cp -f -p /cache/$(basename $apk) $apk | tee -a $LOG_FILE;
- rm /cache/$(basename $apk);
- else
- echo ZipAligning $(basename $apk) Failed | tee -a $LOG_FILE;
- fi;
- else
- echo ZipAlign already completed on $apk | tee -a $LOG_FILE;
- fi;
- done;
- echo "Automatic ZipAlign finished at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;
- S97SD
- #!/system/bin/sh
- if [ -e /sys/devices/virtual/bdi/179:0/read_ahead_kb ]
- then
- /system/xbin/echo "2048" > /sys/devices/virtual/bdi/179:0/read_ahead_kb;
- fi;
- S98screenstate_scaling
- #!/system/bin/sh
- #
- # mod version V49
- # screenstate_scaling - switch CPU frequency governor on screen state change
- # [email protected] (FloHimself)
- # modifications by zacharias.maladroit and 'well.heeled.man'
- # modifications & ideas taken from: ckMod SSSwitch by voku1987 and "battery tweak" (collin_ph@xda)
- # for Changelog and experimental settings: see bottom part of this file
- # =========
- # Memory tweaks for non-screenstate-scaling usage
- # =========
- # (currently none)
- # =========
- # =========
- # Description, howto:
- # =========
- # for uncommenting settings remove the preceding diamond/rhomb-sign (#) at the beginning of the line
- # and remember to comment the other settings otherwise they will fight with each other and you might
- # see inconsistent results
- # ==============================================================
- # ==============================================================
- # Description of the governors:
- # ==============================================================
- # ==============================================================
- # =========
- # (1) battery-saving
- # =========
- # [might be laggy and slow- problems during wake-up/phone-answering or when screen is unlocked - due to powersave governor]
- # =========
- # choose conservative or ondemand governor with aggressive powersaving settings - while screen is ON
- # choose powersave governor - while is OFF
- # =========
- # =========
- # (2) interactive #
- # =========
- # [phone gets warm faster and experience is not overall consistent,
- # interactive governor tweaked for power savings but still consuming more battery
- # staying longer at higher frequencies]
- # =========
- # combine with conservative governor while screen is off ! [recommended]
- # =========
- # =========
- # (3) smartass #
- # =========
- # [best compromise between super-smooth operation and battery savings while screen is off
- # when idle while screen is on the battery consumption might be a tad bit high]
- # =========
- # combine with conservative governor while screen is off ! [recommended]
- #
- # can also be used while screen is ON and screen is OFF [AWAKE and SLEEP governor] - might result
- # in higher battery consumption but smoother overall experience (fast wakeup when unlocking
- # and answering the phone - might have some stability-issues though and "hang" at high
- # frequencies for some time)
- # =========
- # =========
- # (4) interactiveX #
- # =========
- # [phone gets warm faster and experience is not overall consistent,
- # the phone might be consuming more battery
- # staying longer at higher frequencies - this governor is suited as "one governor for all"
- # to be used when screen is ON and when screen is OFF - AWAKE & SLEEP governor]
- # =========
- # =========
- # (5) conservative #
- # =========
- # [multi-purpose governor - very battery-saving with default settings
- # can be tweaked to jump to high frequencies fast while leaving out mid-frequencies
- # when tweaked to be *very* aggressive & resulting in higher
- # quadrant scores than with ondemand & acceptable experience still with
- # power-efficiency in mind - in my opinion more consistent experience
- # less micro-lags & thought-time than with ondemand governor]
- # =========
- # combine with conservative governor while screen is off ! [recommended]
- # =========
- # =========
- # (6) ondemand #
- # =========
- # [kernel default and multi-purpose governor
- # can be tweaked to be fast & power efficient
- # it quickly jumps from lowest to highest frequency and meanwhile
- # also uses mid-frequencies when applicable
- # gets more attention from the upstream kernel devs and is continually optimised
- # its "flaw" from my experience: it's not really smooth enough in demanding GUIs
- # such as MIUI, TouchWiz, even ADWLauncher might show "micro lags"]
- # =========
- # combine with conservative governor while screen is off ! [recommended]
- # =========
- # ==============================================================
- # ==============================================================
- # step [1] choose AWAKE governor while screen is ON
- # ==============================================================
- # ==============================================================
- # selection of AWAKE Governors:
- # =========
- # only keep ONE governor uncommented at a time !!!!:
- # =========
- #AWAKE_GOVERNOR="conservative"
- AWAKE_GOVERNOR="ondemand" # [no additional settings required, tweaking done in kernel-source]
- #AWAKE_GOVERNOR="ondemandX"
- #AWAKE_GOVERNOR="interactive"
- #AWAKE_GOVERNOR="interactiveX"
- #AWAKE_GOVERNOR="smartass"
- # ==============================================================
- # ==============================================================
- # step [2] choose SLEEP governor while screen is OFF
- # ==============================================================
- # ==============================================================
- # selection of SLEEP Governors:
- # =========
- # only keep ONE governor uncommented at a time !!!!:
- # =========
- SLEEP_GOVERNOR="conservative"
- #SLEEP_GOVERNOR="ondemand" # [no additional settings required, tweaking done in kernel-source]
- #SLEEP_GOVERNOR="interactive" # NOT recommended
- #SLEEP_GOVERNOR="interactiveX"
- #SLEEP_GOVERNOR="smartass"
- #SLEEP_GOVERNOR="powersave" # [no additional settings required, powersave only stays at 100 MHz]
- # ==============================================================
- # ==============================================================
- # beginning of the screenstate-scaling loop
- # ==============================================================
- # ==============================================================
- (while [ 1 ]
- do
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # settings for while the screen is on / usage
- # ==============================================================
- # ==============================================================
- # ==============================================================
- AWAKE=`cat /sys/power/wait_for_fb_wake`
- if [ $AWAKE = "awake" ]; then
- sleep 2 && echo $AWAKE_GOVERNOR > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
- # ==============================================================
- # ==============================================================
- # step [3] tweaks to the governor while screen is ON (phone in use)
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # limiting the max/min frequencies [not used by default]
- # ==============================================================
- # =========
- # set maximum & minimum frequency to 100 & 1000 MHz (1 GHz)
- # =========
- #echo "1000000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
- #echo "100000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
- # =========
- # (3) smartass #
- # =========
- # Smartass settings (slightly more battery friendly than Glitch Kernel defaults - peformance penalty unclear)
- # =========
- # echo "50" > /sys/devices/system/cpu/cpu0/cpufreq/smartass/max_cpu_load # 76 # 47
- # echo "35" > /sys/devices/system/cpu/cpu0/cpufreq/smartass/min_cpu_load # 30 # 39
- # echo "800000" > /sys/devices/system/cpu/cpu0/cpufreq/smartass/up_min_freq
- # echo "400000" > /sys/devices/system/cpu/cpu0/cpufreq/smartass/sleep_max_freq
- # =========
- # (5) conservative aka "One governor to rule them all"
- # =========
- # =========
- # Conservative settings [SavagedZen governor-like] (recommended)
- # =========
- # echo "50" > /sys/devices/system/cpu/cpufreq/conservative/up_threshold # 50 # 76 # 76
- # echo "35" > /sys/devices/system/cpu/cpufreq/conservative/down_threshold # 35 # 12 # 30 (higher will lead to noticable lags) # 35
- # echo "50" > /sys/devices/system/cpu/cpufreq/conservative/freq_step # more aggressive ramping up (50)
- ###### echo "280000" > /sys/devices/system/cpu/cpu0/cpufreq/conservative/sampling_rate # 375000 # 500000
- # =========
- # (1) max battery # [with ondemand & powersave while phone in "sleep" [screen off] mode]
- # =========
- # [might have lags during wake-up/phone-answering or when screen is unlocked]
- # =========
- #SLEEP_GOVERNOR="powersave" # [no additional settings required, powersave only stays at 100 MHz]
- # =========
- # (1) max battery # [with conservative & powersave while phone in "sleep" [screen off] mode]
- # =========
- # Conservative settings [all frequencies using, noticably laggy when used while screen is on - needs time to ramp up] (compromise between speed/lags)
- # =========
- # echo "70" > /sys/devices/system/cpu/cpufreq/conservative/up_threshold # 50 # 76 # 76
- # echo "30" > /sys/devices/system/cpu/cpufreq/conservative/down_threshold # 35 # 12 # 30 (higher will lead to noticable lags)
- # echo "10" > /sys/devices/system/cpu/cpufreq/conservative/freq_step # more aggressive ramping up (50)
- #SLEEP_GOVERNOR="conservative"
- #AWAKE_GOVERNOR="smartass"
- #SLEEP_GOVERNOR="conservative"
- # =========
- # (4) ondemand #
- # =========
- # [default governor but tweaked in preparation for BFS usage, should be smooth
- # scales through all frequencies and might consume equally or even less
- # than conservative governor
- # while screen is off - conservative governor]
- # =========
- #AWAKE_GOVERNOR="ondemand"
- #SLEEP_GOVERNOR="conservative"
- # =========
- # (5) One governor to rule them all aka all the way conservative [good trade-off between responsiveness and power-saving features]
- # =========
- #AWAKE_GOVERNOR="conservative"
- #SLEEP_GOVERNOR="conservative"
- # =========
- # dirty_ratio & vfs_cache_pressure: too high (dirty_ratio) and too low values (vfs_cache_pressure) might fill up the RAM too much and end up triggering the OOM killer
- # =========
- # =========
- # stuff moved to the system_tweak script
- # =========
- # log -p i -t screenstate_scaling "*** awake ***: switching CPU frequency governor to -> $AWAKE_GOVERNOR"
- AWAKE=
- fi
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # settings for while the screen is off
- # ==============================================================
- # ==============================================================
- # ==============================================================
- SLEEPING=`cat /sys/power/wait_for_fb_sleep`
- if [ $SLEEPING = "sleeping" ]; then
- sleep 2 && echo $SLEEP_GOVERNOR > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
- # ==============================================================
- # ==============================================================
- # step [4] tweaks to the governor while screen is OFF (phone in idle or doing its thing on its on)
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # limiting the max/min frequencies [not used by default]
- # ==============================================================
- # =========
- # set maximum & minimum frequency to 100 & 400 MHz - that should hopefully be enough for DSP effects & prevent buggy apps from draining the battery too much
- # =========
- #echo "400000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
- #echo "100000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
- # =========
- # (2) interactive, (3) smartass, (4) ondemand, (5) conservative #
- # =========
- # =========
- # Conservative settings [SavagedZen governor-like] (recommended when screen on, might consume more battery when screen off since it does not scale through all frequencies)
- # settings for screen off (can be more aggressive)
- # =========
- echo "50" > /sys/devices/system/cpu/cpufreq/conservative/up_threshold # 50 # 76 # 76 # screen off: # 90 (probably too high) # 76 (sound stuttering with EQ and some apps) ## 50
- echo "35" > /sys/devices/system/cpu/cpufreq/conservative/down_threshold # 35 # 12 # 30 (higher will lead to noticable lags) # 35 # screen off: # 50 ## 35
- echo "5" > /sys/devices/system/cpu/cpufreq/conservative/freq_step # more aggressive ramping up (50) # screen off: # 10
- # =========
- # dirty_ratio & vfs_cache_pressure: too high (dirty_ratio) and too low values (vfs_cache_pressure) might fill up the RAM too much and end up triggering the OOM killer
- # =========
- # =========
- # stuff moved to the system_tweak script
- # =========
- # log -p i -t screenstate_scaling "*** sleeping ***: switching CPU frequency governor to -> $SLEEP_GOVERNOR"
- SLEEPING=
- fi
- done &)
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # Changelog
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # CFS stuff commented out and moved to 89system_tweak; tweaks to conservative governor
- # conservative governor with different values; tweaked conservative governor some more
- # more conservative tweaks
- # conservative for more power savings; behavior similar to SavagedZen governor
- # more tweaking & testing
- # One governor to rule them all; state-dependent memory tweaks (V22); disabled log; ramping at 10
- #
- # switch to ondemand governor (experience from users & me has shown that this one should be the optimal
- # governor for fast frequency-switching and battery savings in usage)
- #
- # switched to smartass governor as default governor while screen is on - when 600 MHz is undervolted by -225 mV (where possible)
- # idle comes at the same cost like 400 MHz so is acceptable
- #
- # tweak the conservative governor (while screen is off) a little to make it less aggressive with ramping up but higher threshold values
- # V28: add min & max frequencies and tweak the conservative governor
- # V29: remove the raised sampling rate for conservative governor (screen off) - since that potentially lead to lags
- # while screen is on (less often polling - no sampling rate set - so the same like it was with screen off). Higher wasn't better in this case
- # V30: tweaked conservative governor some more
- # V31: switch to SavagedZen for default governor (while screen is on)
- # V32: switched back to smartass for default
- # V33: tweaks to smartass governor, added aggressive conservative powersaving options [uncommented - might lead to stuttering in sound playback]
- # V34: tweak smartass governor previous tweaks were too conservative - non-smooth GUI
- # V35: some minor tweaks to screen-off conservative governor
- # V36: config for forked & optimized Talon Kernel
- # V37: even more tweaks to memory settings & governors
- # V38: reduce the waiting time to apply the governor to 2 seconds (from 5)
- # V39: do some more tweaks to the page-cache & dirty_ratio [thanks to Juwe11 for some ideas on how to tweak it properly !]
- # V40: working around the issue that PowerAmp and other players consume too much cpu power & sound lags (less min-max like behavior)
- # V41: conservative governor (screen on) back to old (smoother) behavior
- # V42: switched to ondemand governor (screen on)
- # V43: moved stuff around and added some tags to make things more clear
- # V44: added some more settings
- # V45: some more descriptions
- # V46: added explanation to powersave governor
- # V47: Documentation part rewrite (not finished yet)
- # V48: moved stuff to the system_tweak script
- # V49: pre-set governors: awake_governor ondemand, sleep_governor conservative
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # test settings for while screen is on
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # =========
- # Ondemand settings [more aggressive power savings]
- # =========
- # echo "98" > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
- #### echo "300000" > /sys/devices/system/cpu/cpu0/cpufreq/conservative/sampling_rate
- # =========
- # Ondemand settings [experimental] (max frequency at 800 MHz,
- # more aggressive up- and down-sampling while staying longer at higher frequencies during load)
- # =========
- # echo "100" > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
- # echo "200" > /sys/devices/system/cpu/cpufreq/ondemand/powersave_bias
- # echo "100000" > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate
- # VM parameters;
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # test settings for while screen is off
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # =========
- # Conservative settings [very conservative](conservative SLEEP_GOVERNOR)
- # =========
- # echo "90" > /sys/devices/system/cpu/cpufreq/conservative/up_threshold
- # echo "50" > /sys/devices/system/cpu/cpufreq/conservative/down_threshold
- # echo "10" > /sys/devices/system/cpu/cpufreq/conservative/freq_step
- # echo "500000" > /sys/devices/system/cpu/cpu0/cpufreq/conservative/sampling_rate
- # tweaking up- and down_threshold for power efficiency (only up_threshold exists with ondemand !)
- # echo "98" > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
- # echo "76" > /sys/devices/system/cpu/cpufreq/conservative/up_threshold # 76
- # echo "30" > /sys/devices/system/cpu/cpufreq/conservative/down_threshold # 30
- # echo "20" > /sys/devices/system/cpu/cpufreq/conservative/freq_step
- # VM parameters;
- # =========
- # Conservative settings [SavagedZen governor-like] (recommended when screen on, might consume more battery when screen off since it does not scale through all frequencies)
- # settings for screen off (can be more aggressive)
- # =========
- # echo "50" > /sys/devices/system/cpu/cpufreq/conservative/up_threshold # 50 # 76 # 76 # screen off: # 90 (probably too high) # 76 ## 50
- # echo "35" > /sys/devices/system/cpu/cpufreq/conservative/down_threshold # 35 # 12 # 30 (higher will lead to noticable lags) # 35 # screen off: # 50 ## 35
- # echo "50" > /sys/devices/system/cpu/cpufreq/conservative/freq_step # more aggressive ramping up (50) # screen off: # 10
- ###### echo "400000" > /sys/devices/system/cpu/cpu0/cpufreq/conservative/sampling_rate # 375000 # 500000 # 80000 # screen off: # 400000 (test)
- S98system_tweak
- #!/system/bin/sh
- #
- # 89system_tweak V54
- # by zacharias.maladroit
- # modifications and ideas taken from: ckMod SSSwitch by voku1987 and "battery tweak" (collin_ph@xda)
- # OOM/LMK settings by Juwe11
- # network security settings inspired by various security, server guides on the web
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # One-time tweaks to apply on every boot
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # =========
- STL=`ls -d /sys/block/stl*`;
- BML=`ls -d /sys/block/bml*`;
- MMC=`ls -d /sys/block/mmc*`;
- # set the cfq scheduler as default i/o scheduler (Samsung ROMs)
- #for i in $STL $BML $MMC;
- #do
- # echo "noop" > $i/queue/scheduler;
- #done;
- # Optimize non-rotating storage;
- for i in $STL $BML $MMC;
- do
- echo 0 > $i/queue/rotational;
- echo 1 > $i/queue/iosched/back_seek_penalty;
- echo 1 > $i/queue/iosched/low_latency;
- echo 3 > $i/queue/iosched/slice_idle; # previous: 1
- echo 1 > $i/queue/iosched/fifo_batch; # deadline scheduler specific
- echo 16 > $i/queue/iosched/quantum;
- echo 1024 > $i/queue/iosched/nr_requests; # for starters: keep it sane
- done;
- #disable iostats to reduce overhead
- for k in $STL $BML $MMC;
- do
- echo "0" > $k/queue/iostats
- done
- # Optimize for read- & write-throughput;
- for i in $STL $BML $MMC;
- do
- # echo "2048" > $i/queue/read_ahead_kb # yes - I know - this is evil ^^, might help with battery runtime still (in certain workloads)
- echo "1" > $i/queue/rq_affinity
- done;
- ## /bin/echo "0" > $i/queue/nomerges
- # echo "128" > $i/queue/max_sectors_kb
- # =========
- # TWEAKS: raising read_ahead_kb cache-value for sd card to 2048 [not needed with above tweak but just in case it doesn't get applied]
- # =========
- #echo "2048" > /sys/devices/virtual/bdi/179:0/read_ahead_kb
- # improved approach of the readahead-tweak:
- if [ -e /sys/devices/virtual/bdi/179:0/read_ahead_kb ]
- then
- /system/xbin/echo "1024" > /sys/devices/virtual/bdi/179:0/read_ahead_kb;
- fi;
- if [ -e /sys/devices/virtual/bdi/179:8/read_ahead_kb ]
- then
- /system/xbin/echo "1024" > /sys/devices/virtual/bdi/179:8/read_ahead_kb;
- fi;
- if [ -e /sys/devices/virtual/bdi/default/read_ahead_kb ]
- then
- /system/xbin/echo "128" > /sys/devices/virtual/bdi/default/read_ahead_kb;
- fi;
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # VFS, VM settings
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # =========
- # TWEAKS: MEMORY SETTINGS for general operation + zcache/zram usage
- # =========
- # optimizing the system for zcache & zram usage [Samsung ROMs only (for now)]
- #echo 0 > /proc/sys/vm/swappiness # 70 for zram, Talon # 0 for CM7 / MIUI (no zram yet)
- #echo 3 > /proc/sys/vm/page-cluster # when swapping then hesitate to swap out pages & pull them in again in a fast manner
- #echo 20 > /proc/sys/vm/vfs_cache_pressure; # 100 while screen off # 200 # 50
- #echo 50 > /proc/sys/vm/vfs_cache_pressure; # same value for both: screen on & off - needs some testing due to RAM filling and OOM killer triggering # 20 (on talon)
- # make sure we don't use laptop-mode
- echo 0 > /proc/sys/vm/laptop_mode
- # echo 60 > /proc/sys/vm/swappiness; # 20 # 70
- # echo 10 > /proc/sys/vm/page-cluster; # 12
- echo 0 > /proc/sys/vm/laptop_mode; # do not omit syncing
- echo 700 > /proc/sys/vm/dirty_expire_centisecs; # 2000 # 700 is long enough [stability testing]
- echo 500 > /proc/sys/vm/dirty_writeback_centisecs; # 1000 # 500 is long enough [stability testing]
- echo 10 > /proc/sys/vm/dirty_background_ratio; # 15 # 10 # 50
- echo 80 > /proc/sys/vm/dirty_ratio; # 40 # 90
- echo 20 > /proc/sys/vm/vfs_cache_pressure; # 100 while screen off # 200 # 50 # 20 [less reclaim]
- # =========
- # TWEAKS: adding zram swap in RAM
- # =========
- #insmod /system/modules/zram.ko num_devices=1
- #echo $((96*1024*1024)) > /sys/block/zram0/disksize
- #mknod /dev/zram0 b 253 0
- #mkswap /dev/zram0
- #swapon /dev/zram0
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # network speed and throughput
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # =========
- # TWEAKS: for TCP read/write
- # =========
- echo 0 > /proc/sys/net/ipv4/tcp_timestamps;
- echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse;
- echo 1 > /proc/sys/net/ipv4/tcp_sack;
- echo 1 > /proc/sys/net/ipv4/tcp_dsack;
- echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle;
- echo 1 > /proc/sys/net/ipv4/tcp_window_scaling;
- echo 5 > /proc/sys/net/ipv4/tcp_keepalive_probes;
- echo 30 > /proc/sys/net/ipv4/tcp_keepalive_intvl;
- echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout;
- echo 524288 > proc/sys/net/core/wmem_max;
- echo 524288 > proc/sys/net/core/rmem_max;
- # increase Linux auto tuning TCP buffer limits
- # min, default, and max number of bytes to use
- # set max to at least 4MB, or higher if you use very high BDP paths
- #echo "524280" > /proc/sys/net/core/rmem_default # default:
- #echo "524280" > /proc/sys/net/core/wmem_default # default:
- # Increase the maximum total TCP buffer-space allocatable
- sysctl -w net.ipv4.tcp_mem="57344 57344 65536"
- echo 1 > /proc/sys/net/ipv4/tcp_moderate_rcvbuf # enabled by default
- # removes an odd behavior in the 2.6 kernels, whereby the kernel stores the slow start threshold for a client between TCP sessions. This can cause undesired results, as a single period of congestion can affect many subsequent connections.
- echo 256960 > /proc/sys/net/core/rmem_default;
- echo 256960 > /proc/sys/net/core/wmem_default;
- echo 4096 16384 404480 > /proc/sys/net/ipv4/tcp_wmem;
- echo 4096 87380 404480 > /proc/sys/net/ipv4/tcp_rmem;
- setprop net.tcp.buffersize.default 4096,87380,256960,4096,16384,256960;
- setprop net.tcp.buffersize.wifi 4095,87380,256960,4096,16384,256960;
- setprop net.tcp.buffersize.umts 4094,87380,256960,4096,16384,256960;
- # Increase the tcp-time-wait buckets pool size
- #sysctl -w net.ipv4.tcp_max_tw_buckets="1440000"
- # default: 180000
- # Increase the maximum amount of option memory buffers
- #sysctl -w net.core.optmem_max="57344"
- # default: 20480
- # disable ECN
- # enable it - since it's needed for SFB to work properly/optimally
- # echo "0" > /proc/sys/net/ipv4/tcp_ecn # default at 2
- # explicitly disable it since there's still buggy routers and other stations involved that break networking
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # network security related settings
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # disables IP source routing (for ipv4)
- #for i in /proc/sys/net/ipv4/conf/*; do
- # /bin/echo "0" > $i/accept_source_route
- #done # does not get applied - FIXME
- ## echo "1" > /proc/sys/net/ipv4/conf/all/accept_source_route ## fix wifi, networking issues # leave at default
- #for i in /proc/sys/net/ipv6/conf/*; do
- # /bin/echo "0" > $i/accept_source_route
- #done # does not get applied - FIXME
- ## echo "1" > /proc/sys/net/ipv6/conf/all/accept_source_route ## fix wifi, networking issues # leave at default
- # These commands configure the server to ignore redirects from machines that are listed as
- # gateways. Redirect can be used to perform attacks, so we only want to allow them from
- # trusted sources:
- #for i in /proc/sys/net/ipv4/conf/*; do
- # /bin/echo "1" > $i/secure_redirects
- #done
- ## echo "0" > /proc/sys/net/ipv4/conf/all/secure_redirects ## fix wifi, networking issues # leave at default
- #for i in /proc/sys/net/ipv6/conf/*; do
- # /bin/echo "1" > $i/secure_redirects
- #done
- # disables IP redirects (for ipv4)
- #for i in /proc/sys/net/ipv4/conf/*; do
- # /bin/echo "0" > $i/accept_redirects
- #done # does not get applied - FIXME
- # echo "1" > /proc/sys/net/ipv4/conf/all/accept_redirects ## fix wifi, networking issues # leave at default
- #for i in /proc/sys/net/ipv6/conf/*; do
- # /bin/echo "0" > $i/accept_redirects
- #done # does not get applied - FIXME
- # echo "1" > /proc/sys/net/ipv6/conf/all/accept_redirects ## fix wifi, networking issues # leave at default
- # If this server does not act as a router, it does not have to send redirects, so they can be
- # disabled:
- #for i in /proc/sys/net/ipv4/conf/*; do
- # /bin/echo "0" > $i/send_redirects
- #done # does not get applied - FIXME
- # echo "1" > /proc/sys/net/ipv4/conf/all/send_redirects ## fix wifi, networking issues # # leave at default
- # Configure the server to ignore broadcast pings and smurf attacks:
- # (smurf-attacks)
- echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts # default
- echo "1" > /proc/sys/net/ipv6/icmp_echo_ignore_broadcasts # default
- # Ignore all kinds of icmp packets or pings:
- echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all # default: 0
- echo "1" > /proc/sys/net/ipv6/icmp_echo_ignore_all # default: 0
- # Some routers send invalid responses to broadcast frames, and each one generates a
- # warning that is logged by the kernel. These responses can be ignored:
- echo "1" > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
- echo "1" > /proc/sys/net/ipv6/icmp_ignore_bogus_error_responses
- # When the server is heavily loaded or has many clients with bad connections with high
- # latency, it can result in an increase in half-open connections. This is common for Web
- # servers, especially when there are a lot of dial-up users. These half-open connections are
- # stored in the backlog connections queue. You should set this value to at least 4096. (The
- # default is 1024.)
- # Setting this value is useful even if your server does not receive this kind of connection,
- # because it can still be protected from a DoS (syn-flood) attack.
- echo 4096 > /proc/sys/net/ipv4/tcp_max_syn_backlog # default: 128
- echo 2 > /proc/sys/net/ipv4/tcp_synack_retries # default: 5
- # Increase the number of outstanding syn requests allowed.
- # Note: some people (including myself) have used tcp_syncookies to handle the problem of too many legitimate outstanding SYNs.
- echo "2500" > /proc/sys/net/core/netdev_max_backlog # default: 1000
- echo "1" > /proc/sys/net/ipv4/tcp_window_scaling # default
- # While TCP SYN cookies are helpful in protecting the server from syn-flood attacks, both
- # denial-of-service (DoS) or distributed denial-of-service (DDoS), they could have an
- # adverse effect on performance. We suggest enabling TCP SYN cookies only when there is
- # a clear need for them.
- # enabling syncookies
- echo "1" > /proc/sys/net/ipv4/tcp_syncookies # default
- #echo "0" > /proc/sys/net/ipv6/tcp_syncookies
- # We have also learned that window scaling can be an option to enlarge the transfer
- # window. However, benchmarks have shown that window scaling is not suited for systems
- # experiencing very high network load. Additionally, some network devices do not follow the
- # RFC guidelines and could cause window scaling to malfunction. We suggest disabling
- # window scaling and manually setting the window sizes.
- # sysctl -w net.ipv4.tcp_window_scaling=1
- echo "1" > /proc/sys/net/ipv4/tcp_window_scaling # default
- # log and drop "martian" packets
- #for i in /proc/sys/net/ipv4/conf/*; do
- # /bin/echo "1" > $i/log_martians
- #done # does not get applied - FIXME
- # echo "1" > /proc/sys/net/ipv4/conf/all/log_martians
- # enable reverse path-filtering [prevents IP-Spoofing]
- #for i in /proc/sys/net/ipv4/conf/*; do
- # /bin/echo "1" > $i/rp_filter
- #done # does not get applied - FIXME
- #echo "1" > /proc/sys/net/ipv4/conf/all/rp_filter # not enabled by default # uncomment for enhanced security & NOT using VPN (breaks VPN functionality)
- # disable IP dynaddr
- echo "0" > /proc/sys/net/ipv4/ip_dynaddr # default
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # general phone/RIL-related settings
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # =========
- # TWEAKS: optimized for 3G/Edge speed
- # =========
- setprop ro.ril.hsxpa 2; # disabling HSPA does not work so make full use of it
- setprop ro.ril.gprsclass 12;
- setprop ro.ril.hep 1;
- #setprop ro.ril.enable.dtm 1; # potential fix for disappearing data connection on GSM phones
- setprop ro.ril.hsdpa.category 8;
- setprop ro.ril.enable.a53 1;
- setprop ro.ril.enable.3g.prefix 1;
- setprop ro.ril.htcmaskw1.bitmask 4294967295;
- setprop ro.ril.htcmaskw1 14449;
- setprop ro.ril.hsupa.category 7;
- # =========
- # TWEAKS: optimized for 2G security [not sure if it works]
- # =========
- ro.ril.enable.gea3=1
- # =========
- # TWEAKS: agps [network assisted gps] stuff optimizations
- # =========
- setprop ro.ril.def.agps.feature=1 # also default ?
- setprop ro.ril.def.agps.mode=2 # default value
- # For HSDPA low throughput
- # setprop ro.ril.disable.power.collapse = 1
- # =========
- # TWEAKS: overall
- # =========
- setprop ro.telephony.call_ring.delay 100; # let's minimize the time Android waits until it rings on a call
- setprop ro.ril.disable.power.collapse 0;
- #setprop pm.sleep_mode 0;
- #setprop dalvik.vm.startheapsize 8m;
- #setprop dalvik.vm.heapsize 64m; # leave that setting to cyanogenmod settings or uncomment it if needed
- setprop wifi.supplicant_scan_interval 60; # higher is not recommended, scans while not connected anyway so shouldn't affect while connected
- setprop windowsmgr.max_events_per_sec 60; # smoother GUI
- #echo 64000 > /proc/sys/kernel/msgmni;
- echo 500 512000 64 2048 > /proc/sys/kernel/sem; # allow more semaphores
- #echo 5000 > /proc/sys/kernel/threads-max;
- echo 0 > /proc/sys/kernel/hung_task_timeout_secs;
- #media.stagefright.enable-player=true
- #media.stagefright.enable-meta=true
- #media.stagefright.enable-scan=true
- #media.stagefright.enable-http=true
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # Optimize SQlite databases of apps
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # =========
- for i in \
- `find /data -iname "*.db"`;
- do \
- sqlite3 $i 'VACUUM;';
- done;
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # TWEAKS: improve handling & reactivity of the CFS cpu scheduler
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # =========
- if [ -e /proc/sys/kernel/rr_interval ];
- then
- # BFS;
- echo 6 > /proc/sys/kernel/rr_interval;
- echo 100 > /proc/sys/kernel/iso_cpu;
- else
- # CFS
- # following 2 settings are to be handled with care - could lead to bootlooping phone or other issues if too low !
- echo 100000 > /proc/sys/kernel/sched_latency_ns; # 1000000 # 18000000 # 1000000 # 100000 ## new
- echo 500000 > /proc/sys/kernel/sched_wakeup_granularity_ns ; # 500000 # 3000000 # 25000 # 0 (?)
- echo 750000 > /proc/sys/kernel/sched_min_granularity_ns; # 1000000 # 1500000 # 100000 # 1000000 ## 750000 (upstream)
- #echo -1 > /proc/sys/kernel/sched_rt_runtime_us;
- #echo 100000 > /proc/sys/kernel/sched_rt_period_us;
- #echo 95000 > /proc/sys/kernel/sched_rt_runtime_us; # default: 950000; very small values in sched_rt_runtime_us can result in an unstable system when the runtime is so small
- # the system has difficulty making forward progress (the migration thread and kstopmachine both are real-time processes)
- fi;
- # =========
- # TWEAKS: new scheduler performance settings (test)
- # =========
- #echo "now disabling GENTLE_FAIR_SLEEPERS"
- echo "NO_GENTLE_FAIR_SLEEPERS" > /sys/kernel/debug/sched_features
- #cat /sys/kernel/debug/sched_features
- #echo "done"
- #echo ""
- #echo "now disabling FAIR_SLEEPERS"
- echo "NO_NEW_FAIR_SLEEPERS" > /sys/kernel/debug/sched_features
- #cat /sys/kernel/debug/sched_features
- #echo "done"
- #echo "now disabling NORMALIZED_SLEEPERS"
- echo "NO_NORMALIZED_SLEEPER" > /sys/kernel/debug/sched_features
- #cat /sys/kernel/debug/sched_features
- #echo "done"
- echo "24319" > /proc/sys/kernel/sched_features
- # =========
- # TWEAKS: raise throughput & responsiveness [reboots & instability ?!]
- # =========
- #echo "now disabling FAIR_SLEEPERS"
- #echo "NO_NEW_FAIR_SLEEPERS" > /sys/kernel/debug/sched_features
- #cat /sys/kernel/debug/sched_features
- #echo "done"
- #echo ""
- #echo "now disabling START_DEBIT"
- #echo "NO_START_DEBIT" > /sys/kernel/debug/sched_features
- #cat /sys/kernel/debug/sched_features
- #echo "done"
- #echo ""
- #echo "now disabling LB_BIAS"
- #echo "NO_LB_BIAS" > /sys/kernel/debug/sched_features
- #cat /sys/kernel/debug/sched_features
- #echo "done"
- #echo ""
- #echo "now disabling NEXT_BUDDY"
- #echo "NO_NEXT_BUDDY" > /sys/kernel/debug/sched_features
- #cat /sys/kernel/debug/sched_features
- #echo "done"
- #echo ""
- #echo "now enabling sched_child_runs_first"
- #echo "1" > /proc/sys/kernel/sched_child_runs_first
- #cat /proc/sys/kernel/sched_child_runs_first
- #echo "done"
- #echo ""
- # =========
- # TWEAKS: low-latency features [issues with auto-rotation & stuff]
- # =========
- #echo "now enabling the low-latency functionality of CFS provided by"
- #echo "Mathieu Desnoyers & Peter Zijlstra, sponsored by Nokia"
- #for opt in DYN_MIN_VRUNTIME \
- # NO_FAIR_SLEEPERS FAIR_SLEEPERS_INTERACTIVE FAIR_SLEEPERS_TIMER \
- # INTERACTIVE TIMER \
- # INTERACTIVE_FORK_EXPEDITED TIMER_FORK_EXPEDITED;
- #do echo $opt > /sys/kernel/debug/sched_features;
- #done
- #echo "low-latency for CFS activated ..."
- #echo "done"
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # remove lag when answering phone calls
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # =========
- #MAX_PHONE()
- #{
- #pidphone=`pidof com.android.phone`;
- #if [ $pidphone ]; # Wait for com.android.phone to start;
- #then#
- # echo -17 > /proc/$pidphone/oom_adj; # exclude com.android.phone from oom-killer;
- # renice -20 $pidphone; # set highest nice level for com.android.phone;
- ## log -p i -t SSSwitch_v0.8 "*** MAX phone *** set oom_adj(-17) and nice(-20) for com.android.phone";
- # exit;
- #else
- # sleep 5;
- # MAX_PHONE;
- #fi;
- #}
- # =========
- # Background process to optimize dialer process
- # =========
- #(while [ 1 ];
- #do
- # sleep 10;
- # MAX_PHONE;
- #done &);
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # renicing kswapd (useful on non-swap phones)
- # ==============================================================
- # ==============================================================
- # ==============================================================
- # =========
- #KSWAPD_RENICE()
- #{
- #pidkswapd=`pidof kswapd0`;
- #if [ $pidkswapd ]; # Wait for kswapd to be available;
- #then
- # renice 19 $pidkswapd; # set kswapd lowest nice level possible;
- # exit;
- #else
- # sleep 5;
- # KSWAPD_RENICE;
- #fi;
- #}
- # =========
- # Background process to keep priority of kwapd low
- # =========
- #(while [ 1 ];
- #do
- # sleep 10;
- # KSWAPD_RENICE;
- #done &);
- # =========
- # Changelog
- # =========
- # sdcard reading fix by brainmaster
- # moved CFS cpu scheduler tweaks from 90screenstate_scaling to here; tweaks to read & write
- # trying out CFS scheduler with lower refresh rate for more throughput & performance [fine]
- # enable low-latency features and allow higher throughput
- # disable readhead for other partitions (overhead) but keep write improvements enabled
- # less tight scheduler timings
- # fix disappearing data connection on GSM phones
- # corrected paths for write tweak (thanks nexxx85 !)
- # V21: stricter scheduler timings to make the phone operation smoother [needs stability & function testing]
- # V22: fixed network security settings (some did not get applied)
- # V23: disabled the ICMP parts
- # V24: add notes for VPN users:
- # set 'echo "1" > /proc/sys/net/ipv4/conf/all/rp_filter'
- # to
- # 'echo "0" > /proc/sys/net/ipv4/conf/all/rp_filter'
- # V27: re-enable scheduler settings @ Quorra pre-11_test3; false reports about phone reboots
- # V28: set "deadline" as default i/o scheduler
- # V29: enable read_ahead_kb optimization globally (testing)
- # V30: keep stock scheduler settings
- # V31: re-enable ICMP security measures
- # V32: improved approach of the SD-card (readhaead) speed-fix; implementation by Darkyy (included in DarkyROM 10.1)
- # V33: switch to cfq for Samsung GB ROMs (due to latency and lack of writeback-improvements [can't be applied - leads to reboot / non-boot])
- # V34: fix some minor typos
- # V35: moved some tweaks from the screenstate_scaling script here (for Samsung ROMs)
- # V36: moved vfs_cache_pressure here
- # V37: added memory tweaks by Juwe11
- # V38: switch to deadline for CM7/MIUI base; swappiness at 0 (for now - no zram yet)
- # V39: do not log martians (no dmesg / printk so no use for it)
- # V40: add some scheduler tweaks from upstream
- # V41: tweak the deadline ioscheduler some more (fifo_batch)
- # V42: moved changelog to bottom to make things more clear
- # V43: add some background processes to make the phone more reliable and responsive (phone dialer & kswapd0) [testing]
- # V44: added some descriptions to make it hopefully more clear and easy to use
- # V45: disable kswapd and phone background processes
- # V46: set the wifi scanning interval back to 60 (180 was too much, if it doesn not scan often enough got to -> settings -> wireless & network -> wifi settings -> and it will scan immediately or use a wifi widget)
- # V47: just leave the trouble-causing network-settings commented out and thus at default, might work better that way
- # V48: made the script BFS & CFS cpu scheduler aware
- # V49: some more scheduler performance settings (test)
- # V50: disabling iostats to reduce overhead (thanks to kodos96 !)
- # V51: some readahead tweaks - thanks to corgar !
- # V52: inherited stuff from the screenstate_scaling script
- # V53: more tweaks in several areas
- # V54: some more tweaks & explanations
- s99acidext4tweak
- #!/system/bin/sh
- mount -o remount,nobh,noatime,barrier=0 /system /system
- mount -o remount,nobh,noatime,barrier=0 /cache /cache
- mount -o remount,nobh,noatime,barrier=0 /data /data
- S99complete
- #!/system/bin/sh
- sync;
- setprop cm.filesystem.ready 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement