Commit graph

5 commits

Author SHA1 Message Date
Chenyang Zhong
16ac982064
sdm710-common: rootdir: Switch to lz4 for zram
5.4 kernel defaults to lzo-rle for zram. lzo-rle added run-length
encoding for lzo, which is beneficial to the use case of zram that
often has long runs of zero bytes. However, according to my testing
results, lzo-rle still has lower decompression throughput and higher
access latency compared to lz4. lzo-rle beats lz4 in compression
ratio, but most Xiaomi SM8350 devices have either 8GB or 12GB of RAM
where memory pressure hardly happens. Therefore, lz4's higher throughput
and lower latency is more preferable.

Now that I added LZ4_FAST_DEC_LOOP to the kernel lz4 module from
upstream lz4 1.9.x release, the decompression speed has increased
by another 10%, which leads further ahead lzo-rle.

Test setup:
- Disable swap on zram if it is enabled
  $ swapoff /dev/block/zram0
- If you want to change the comp_algorithm after zram has been
  initialized, reset zram first.
  $ echo 1 > /sys/block/zram0/reset
- Set the comp_algorithm. For example, for lz4
  $ echo lz4 > /sys/block/zram0/comp_algorithm
- Set up zram size
  $ echo 4294967296 > /sys/block/zram0/disksize
- Make the swap
  $ mkswap /dev/block/zram0
- Pre-fill zram with 1GB of real-word zram data dumped previously under
  memory pressure. For example,
  $ dd if=/sdcard/zram.test of=/dev/block/zram0 bs=1m count=1000

Random 4k read:
$ fio --readonly --name=randread --direct=1 --rw=randread --ioengine=psync \
  --randrepeat=0 --numjobs=4 --iodepth=1 --group_reporting=1 \
  --filename=/dev/block/zram0 --bs=4K --size=1000M

lzo-rle: read: IOPS=1547k, BW=6042MiB/s (6336MB/s)(4000MiB/662msec)
lz4: read: IOPS=1646k, BW=6431MiB/s (6743MB/s)(4000MiB/622msec)
lz4 fast dec: read: IOPS=1775k, BW=6932MiB/s (7269MB/s)(4000MiB/577msec)

Sequencial 4k read:
$ fio --readonly --name=zram_seqread --direct=1 --rw=read --ioengine=psync \
  --numjobs=4 --iodepth=1 --group_reporting=1 --filename=/dev/block/zram0 \
  --bs=4K --size=1000M

lzo-rle: read: IOPS=1816k, BW=7092MiB/s (7437MB/s)(4000MiB/564msec)
lz4: read: IOPS=1907k, BW=7449MiB/s (7811MB/s)(4000MiB/537msec)
lz4 fast dec: read: IOPS=2004k, BW=7828MiB/s (8208MB/s)(4000MiB/511msec)

Compression ratio from /sys/block/zram0/mm_stat
lzo-rle: 1048576000 -> 81969152
lz4: 1048576000 -> 86200320

zstd was also considered. It offers really nice compression ratio,
1048576000 -> 59899904, but the throughput and latency are so much
worse than lz4 and lzo-rle. It is probably more suitable for traditional
desktop/server swap setup with less aggressive swappiness value. It can
also help alleviate high memory pressure situation by compressing the
RAM to smaller size.
2024-02-10 21:14:20 +02:00
Hridya Valsaraju
8803ff0740
sdm710-common: Set PRODUCT_SET_DEBUGFS_RESTRICTIONS
Starting with Android R launched devices, debugfs cannot be mounted in
production builds. In order to avoid accidental debugfs dependencies
from creeping in during development with userdebug/eng builds, the
build flag PRODUCT_SET_DEBUGFS_RESTRICTIONS can be set by vendors to
enforce additional debugfs restrictions for userdebug/eng builds. The
same flag will be used to enable sepolicy neveallow statements to
prevent new permissions added for debugfs access.

Test: build, boot
Bug: 184381659
Change-Id: I45e6f20c886d467a215c9466f3a09965ff897d7e
2023-11-25 20:35:07 +02:00
Edwin Moquete
90893a90f4 sdm710-common: rootdir: Kang runtime cpuset from crosshatch
Change-Id: Icb4c39fb1f316effde856e1e10e6c19e391fab7d
2023-06-25 23:53:54 +03:00
Arian
23ce77d849 sdm710-common: rootdir: Kang governor settings from crosshatch
Change-Id: Ie6534dcb14bec74105841b2289e29728ee50a3a5
2023-06-25 23:53:54 +03:00
Giammarco Senatore
08e188d663
kunlun2: Import stock init scripts 2021-07-12 02:23:52 +02:00