forked from gokhanmoral/initramfs3
/
thunderbolt.sh
executable file
·154 lines (129 loc) · 3.67 KB
/
thunderbolt.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/sbin/busybox sh
# =========
# Optimize io scheduler
# =========
STL=`ls -d /sys/block/stl*`;
BML=`ls -d /sys/block/bml*`;
MMC=`ls -d /sys/block/mmc*`;
ZRM=`ls -d /sys/block/zram*`;
MTD=`ls -d /sys/block/mtd*`;
# Optimize non-rotating storage;
for i in $STL $BML $MMC $ZRM $MTD;
do
if [ -e $i/queue/rotational ];
then
echo "0" > $i/queue/rotational;
fi;
if [ -e $i/queue/iostats ];
then
echo "0" > $i/queue/iostats;
fi;
#if [ -e $i/queue/iosched/group_isolation ];
#then
# echo "0" > $i/queue/iosched/group_isolation;
#fi;
#if [ -e $i/queue/iosched/slice_idle ];
#then
# echo "0" > $i/queue/iosched/slice_idle;
#fi;
#if [ -e $i/queue/iosched/back_seek_penalty ];
#then
# echo "1" > $i/queue/iosched/back_seek_penalty;
#fi;
if [ -e $i/queue/iosched/low_latency ];
then
echo "1" > $i/queue/iosched/low_latency;
fi;
if [ -e $i/queue/iosched/fifo_batch ];
then
echo "1" > $i/queue/iosched/fifo_batch;
fi;
if [ -e $i/queue/iosched/writes_starved ];
then
echo "1" > $i/queue/iosched/writes_starved;
fi;
if [ -e $i/queue/iosched/rev_penalty ];
then
echo "1" > $i/queue/iosched/rev_penalty;
fi;
if [ -e $i/queue/rq_affinity ];
then
echo "1" > $i/queue/rq_affinity;
fi;
if [ -e $i/queue/iosched/slice_async_rq ];
then
echo "2" > $i/queue/iosched/slice_async_rq;
fi;
if [ -e $i/queue/iosched/quantum ];
then
echo "8" > $i/queue/iosched/quantum;
fi;
#if [ -e $i/queue/nr_requests ];
#then
# echo "1024" > $i/queue/nr_requests;
#fi;
#if [ -e $i/queue/iosched/back_seek_max ];
#then
# echo "1000000000" > $i/queue/iosched/back_seek_max;
#fi;
done;
# =========
# TWEAKS: raising read_ahead_kb cache-value for mounts that are sdcard-like to 1024
# =========
if [ -e /sys/devices/virtual/bdi/179:16/read_ahead_kb ];
then
echo "1024" > /sys/devices/virtual/bdi/179:16/read_ahead_kb;
fi;
if [ -e /sys/devices/virtual/bdi/179:24/read_ahead_kb ];
then
echo "1024" > /sys/devices/virtual/bdi/179:24/read_ahead_kb;
fi;
# =========
# Remount all partitions
# =========
for k in $(busybox mount | grep relatime | cut -d " " -f3);
do
sync;
busybox mount -o remount,noatime,nodiratime $k;
done;
for l in $(busybox mount | grep ext[3-4] | cut -d " " -f3);
do
sync;
busybox mount -o remount,noatime,nodiratime,delalloc,noauto_da_alloc,commit=15 $l;
done;
mount -o remount,rw,noatime,nodiratime,nodev,nobh,nouser_xattr,inode_readahead_blks=1,discard,barrier=0,commit=60,noauto_da_alloc,delalloc /cache /cache;
mount -o remount,rw,noatime,nodiratime,nodev,nobh,nouser_xattr,inode_readahead_blks=1,discard,barrier=0,commit=60,noauto_da_alloc,delalloc /data /data;
# =========
# TWEAKS
# =========
setprop ro.media.dec.jpeg.memcap 20000000;
setprop ro.media.enc.jpeg.quality 90,80,70;
# =========
# MEMORY-TWEAKS
# =========
#echo "50" > /proc/sys/vm/swappiness;
#echo "50" > /proc/sys/vm/vfs_cache_pressure;
#echo "0" > /sys/module/lowmemorykiller/parameters/debug_level;
# Define the memory thresholds at which the above process classes will
# be killed. These numbers are in pages (4k) -> (1 MB * 1024) / 4 = 256
FOREGROUND_APP_MEM=8192;
VISIBLE_APP_MEM=10240;
SECONDARY_SERVER_MEM=12288;
BACKUP_APP_MEM=12288;
HOME_APP_MEM=12288;
HIDDEN_APP_MEM=14336;
CONTENT_PROVIDER_MEM=16384;
EMPTY_APP_MEM=20480;
#echo "$FOREGROUND_APP_MEM,$VISIBLE_APP_MEM,$SECONDARY_SERVER_MEM,$HIDDEN_APP_MEM,$CONTENT_PROVIDER_MEM,$EMPTY_APP_MEM" > /sys/module/lowmemorykiller/parameters/minfree;
# =========
# Renice - kernel thread responsible for managing the memory
# =========
renice 19 `pidof kswapd0`;
# =========
# CleanUp
# =========
#drop caches to free some memory
sync;
/system/xbin/echo "3" > /proc/sys/vm/drop_caches;
sleep 1;
/system/xbin/echo "1" > /proc/sys/vm/drop_caches;