Skip to content

Commit

Permalink
Optimize storage, use cache as secondary swap and reuse devlog as cache
Browse files Browse the repository at this point in the history
Change-Id: I15cf136cf180f0e6686cd37641cc4170867adecd
  • Loading branch information
eugenesan committed Sep 17, 2015
1 parent 32a3347 commit 665448a
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 53 deletions.
2 changes: 1 addition & 1 deletion overlay/frameworks/base/core/res/res/xml/storage_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
android:allowMassStorage="false"
android:maxFileSize="4096" />
<!-- external USB OTG storage -->
<storage android:mountPoint="/storage/usbdisk"
<storage android:mountPoint="/storage/usb-otg"
android:storageDescription="@string/storage_usb"
android:removable="true" />
</StorageList>
4 changes: 2 additions & 2 deletions recovery/root/etc/twrp.fstab
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
/recovery emmc /dev/block/mmcblk0p21
/system ext4 /dev/block/mmcblk0p22
/data f2fs /dev/block/mmcblk0p23 length=-16384
/cache f2fs /dev/block/mmcblk0p24
/cache f2fs /dev/block/mmcblk0p28
/misc emmc /dev/block/mmcblk0p31
/sdcard1 vfat /dev/block/mmcblk1p1 /dev/block/mmcblk1 flags=display="sdcard1";andsec;storage;wipeingui;removable
/data1 f2fs /dev/block/mmcblk1p2 /dev/block/mmcblk1 flags=display="data1";wipeingui;removable
/usbdisk vfat /dev/block/sda1 /dev/block/sda flags=display="usbdisk";storage;wipeingui;removable
/usb-otg vfat /dev/block/sda1 /dev/block/sda flags=display="usb-otg";storage;wipeingui;removable
10 changes: 6 additions & 4 deletions rootdir/etc/fstab.pyramid
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
/dev/block/platform/msm_sdcc.1/by-name/boot /boot emmc defaults defaults
/dev/block/platform/msm_sdcc.1/by-name/recovery /recovery emmc defaults defaults
/dev/block/platform/msm_sdcc.1/by-name/misc /misc emmc defaults defaults
/dev/block/platform/msm_sdcc.1/by-name/devlog /devlog ext4 noatime,nosuid,nodev,barrier=0 wait
/dev/block/platform/msm_sdcc.1/by-name/devlog /cache ext4 noatime,nosuid,nodev,barrier=1,data=ordered,nomblk_io_submit,noauto_da_alloc,errors=panic wait,check
/dev/block/platform/msm_sdcc.1/by-name/devlog /cache f2fs rw,discard,nosuid,nodev,noatime,nodiratime,inline_xattr wait,check
/dev/block/platform/msm_sdcc.1/by-name/system /system ext4 ro,noatime,barrier=1 wait
/dev/block/platform/msm_sdcc.1/by-name/cache /cache ext4 noatime,nosuid,nodev,barrier=1,data=ordered,nomblk_io_submit,noauto_da_alloc,errors=panic wait,check
/dev/block/platform/msm_sdcc.1/by-name/cache /cache f2fs rw,discard,nosuid,nodev,noatime,nodiratime,inline_xattr wait,check
/dev/block/platform/msm_sdcc.1/by-name/userdata /data ext4 noatime,nosuid,nodev,barrier=1,data=ordered,nomblk_io_submit,noauto_da_alloc,errors=panic wait,check,encryptable=footer,length=-16384
/dev/block/platform/msm_sdcc.1/by-name/userdata /data f2fs noatime,nodiratime,nosuid,nodev,inline_xattr,discard,rw wait,check,encryptable=footer,length=-16384
/dev/block/platform/msm_sdcc.3/by-num/p2 /data1 ext4 noatime,nosuid,nodev,barrier=1,data=ordered,nomblk_io_submit,noauto_da_alloc,errors=panic wait,check
Expand All @@ -23,4 +22,7 @@
d* auto auto defaults voldmanaged=usbdisk:auto,noemulatedsd

# ZRAM
/dev/block/zram0 none swap defaults zramsize=268435456
/dev/block/zram0 none swap defaults zramsize=134217728

# Cache as secondary swap
/dev/block/platform/msm_sdcc.1/by-name/cache none swap defaults defaults
46 changes: 27 additions & 19 deletions rootdir/etc/init.pyramid.rc
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import init.pyramid.usb.rc

on early-init
write /sys/devices/system/cpu/cpu1/online 1
write /sys/block/mmcblk0/bdi/read_ahead_kb 512
write /sys/block/mmcblk0/queue/scheduler noop
write /sys/devices/system/cpu/cpu1/online 1
write /sys/block/mmcblk0/bdi/read_ahead_kb 512
write /sys/block/mmcblk0/queue/scheduler noop
write /sys/block/mmcblk1/bdi/read_ahead_kb 512
write /sys/block/mmcblk1/queue/scheduler noop

# ZRAM
write /sys/block/zram0/comp_algorithm lz4
write /sys/block/zram0/max_comp_streams 2
# ZRAM
write /sys/block/zram0/comp_algorithm lz4
write /sys/block/zram0/max_comp_streams 2

# UKMS
write /sys/kernel/mm/uksm/run 1
write /sys/kernel/mm/uksm/cpu_governor medium
write /sys/kernel/mm/uksm/sleep_millisecs 500

on init
mkdir /devlog 0700 root root
Expand Down Expand Up @@ -46,7 +53,10 @@ on fs
mkdir /firmware_q6 0771 system system
# mount all mmc partitions
mount_all /fstab.pyramid
# init and enable swap partitions (zram and cache)
mkswap /dev/block/platform/msm_sdcc.1/by-name/cache
swapon_all /fstab.pyramid
write /proc/sys/vm/swappiness 60

mkdir /data/tombstones 0771 system system
symlink /data/tombstones /tombstones
Expand Down Expand Up @@ -259,21 +269,20 @@ service dhcpcd_wlan0 /system/bin/dhcpcd -ABKL
oneshot

service dhcpcd_p2p /system/bin/dhcpcd -aABKL
disabled
oneshot
disabled
oneshot

service dhcpcd_bt-pan /system/bin/dhcpcd -ABKL
disabled
oneshot
disabled
oneshot

service iprenew_bt-pan /system/bin/dhcpcd -n
disabled
oneshot
disabled
oneshot

service iprenew_wlan0 /system/bin/dhcpcd -n
disabled
oneshot
# wifi--
disabled
oneshot

# external sdcard daemon running as media_rw (1023)
service fuse_sdcard1 /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/sdcard1 /storage/sdcard1
Expand All @@ -286,6 +295,9 @@ service sdcard /system/bin/sdcard -u 1023 -g 1023 -l /data/media /mnt/shell/emul

on property:init.svc.bootanim=stopped
start qcom-post-boot
# config storage access
write /sys/block/mmcblk0/queue/scheduler fiops
write /sys/block/mmcblk1/queue/scheduler row

on property:ro.hdmi.enable=true
start hdmid
Expand Down Expand Up @@ -336,9 +348,5 @@ on property:sys.boot_completed=1
# Wake on volume
write /sys/keyboard/vol_wakeup 1

on property:init.svc.bootanim=stopped
write /sys/block/mmcblk0/queue/scheduler fiops

on property:sys.radio.shutdown=true
exec /system/bin/sh /system/etc/init.qcom.efs.sync.sh

46 changes: 28 additions & 18 deletions rootdir/etc/init.pyramid.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
#!/system/bin/sh

export PATH=${PATH}:/system/bin/:/system/xbin/
LOG="/cache/${0}.log"

log -p i -t userinit "[${0}][Start]"

# Log related mounts and mount points before
log -p i -t userinit "[${0}] Before"
echo "[${0}] Before" >> /cache/${0}.log
mount >> /cache/${0}.log
ls -la /data/ >> /cache/${0}.log
ls -la /data1/ >> /cache/${0}.log
echo "[Start]" >> ${LOG}
mount >> ${LOG}
echo "[/]" >> ${LOG}
ls -la / >> ${LOG}
echo "[/data]" >> ${LOG}
ls -la /data/ >> ${LOG}
echo "[/data1]" >> ${LOG}
ls -la /data1/ >> ${LOG}
du -sch /data1/* >> ${LOG}

# Attempt to link data content to secondary data (optional)
# Attempt to link data components to secondary data (optional)
# If we fail those locations will be used as usual
# Ensure permissions are set correctly
test -d /data1/app && chmod 0771 /data1/app && chown system:system /data1/app && rm -Rf /data/app && ln -s /data1/app /data/app && log -p i -t userinit "[${0}] Linked /data1/app" && echo "[${0}] Linked /data1/app" >> /cache/${0}.log
#test -d /data1/app-asec && chmod 0700 /data1/app-asec && chown root:root /data1/app-asec && rm -Rf /data/app-asec && ln -s /data1/app-asec /data/app-asec && log -p i -t userinit "[${0}] Linked /data1/app-asec" && echo "[${0}] Linked /data1/app-asec" >> /cache/${0}.log
#test -d /data1/app-lib && chmod 0771 /data1/app-lib && chown system:system /data1/app-lib && rm -Rf /data/app-lib && ln -s /data1/app-lib /data/app-lib && log -p i -t userinit "[${0}] Linked /data1/app-lib" && echo "[${0}] Linked /data1/app-lib" >> /cache/${0}.log
#test -d /data1/app-private && chmod 0771 /data1/app-private && chown system:system /data1/app-private && rm -Rf /data/app-private && ln -s /data1/app-private /data/app-private && log -p i -t userinit "[${0}] Linked /data1/app-private" && echo "[${0}] Linked /data1/app-private" >> /cache/${0}.log
test -d /data1/dalvik-cache && chmod 0771 /data1/dalvik-cache && chown root:root /data1/dalvik-cache && rm -Rf /data/dalvik-cache && ln -s /data1/dalvik-cache /data/dalvik-cache && log -p i -t userinit "[${0}] Linked /data1/dalvik-cache" && echo "[${0}] Linked /data1/dalvik-cache" >> /cache/${0}.log
test -d /data1/data && chmod 0771 /data1/data && chown system:system /data1/data && rm -Rf /data/data && ln -s /data1/data /data/data && log -p i -t userinit "[${0}] Linked /data1/data" && echo "[${0}] Linked /data1/data" >> /cache/${0}.log
test -d /data1/media && chmod 0770 /data1/media && chown media_rw:media_rw /data1/media && rm -Rf /data/media && ln -s /data1/media /data/media && log -p i -t userinit "[${0}] Linked /data1/media" && echo "[${0}] Linked /data1/media" >> /cache/${0}.log
test -d /data1/dalvik-cache && chmod 0771 /data1/dalvik-cache && chown root:root /data1/dalvik-cache && rm -Rf /data/dalvik-cache && ln -s /data1/dalvik-cache /data/dalvik-cache && log -p i -t userinit "[${0}] Linked /data1/dalvik-cache" && echo "[${0}] Linked /data1/dalvik-cache" >> ${LOG}
test -d /data1/app && chmod 0771 /data1/app && chown system:system /data1/app && rm -Rf /data/app && ln -s /data1/app /data/app && log -p i -t userinit "[${0}] Linked /data1/app" && echo "[${0}] Linked /data1/app" >> ${LOG}
test -d /data1/data && chmod 0771 /data1/data && chown system:system /data1/data && rm -Rf /data/data && ln -s /data1/data /data/data && log -p i -t userinit "[${0}] Linked /data1/data" && echo "[${0}] Linked /data1/data" >> ${LOG}
test -d /data1/media && chmod 0770 /data1/media && chown media_rw:media_rw /data1/media && rm -Rf /data/media && ln -s /data1/media /data/media && log -p i -t userinit "[${0}] Linked /data1/media" && echo "[${0}] Linked /data1/media" >> ${LOG}

# Log related mounts and mount points after
log -p i -t userinit "[${0}] After"
echo "[${0}] After" >> /cache/${0}.log
mount >> /cache/${0}.log
ls -la /data/ >> /cache/${0}.log
ls -la /data1/ >> /cache/${0}.log
echo "[Stop]" >> ${LOG}
mount >> ${LOG}
echo "[/]" >> ${LOG}
ls -la / >> ${LOG}
echo "[/data]" >> ${LOG}
ls -la /data/ >> ${LOG}
echo "[/data1]" >> ${LOG}
ls -la /data1/ >> ${LOG}
du -sch /data1/* >> ${LOG}

log -p i -t userinit "[${0}][Stop]"
17 changes: 8 additions & 9 deletions system_prop.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,26 @@
PRODUCT_PROPERTY_OVERRIDES += \
ro.sf.lcd_density=240

# radio
# Radio
PRODUCT_PROPERTY_OVERRIDES += \
mobiledata.interfaces=rmnet0 \
rild.libpath=/system/lib/libhtc_ril.so \
ro.telephony.ril_class=HtcMsm8660RIL

# wifi
# WiFi
PRODUCT_PROPERTY_OVERRIDES += \
wifi.interface=wlan0
wifi.interface=wlan0

# UMS
PRODUCT_PROPERTY_OVERRIDES += \
persist.sys.usb.config=mtp,adb \
ro.vold.umsdirtyratio=20

# tweaks
# Tweaks
PRODUCT_PROPERTY_OVERRIDES += \
dalvik.vm.dexopt-data-only=1 \
dalvik.vm.dexopt-flags=m=y \
windowsmgr.max_events_per_sec=300 \
pm.sleep_mode=1
dalvik.vm.dexopt-data-only=1 \
dalvik.vm.dexopt-flags=m=y \
windowsmgr.max_events_per_sec=300 \
pm.sleep_mode=1

# Display
PRODUCT_PROPERTY_OVERRIDES += \
Expand Down

0 comments on commit 665448a

Please sign in to comment.