franciscofranco / FK-Kernel-Manager-IssuesAndFeatureRequest

Just to make it easier for other developers who want specific features/paths added
https://play.google.com/store/apps/details?id=com.franco.kernel
15 stars 12 forks source link

Kernel backup compression #1

Open kdrag0n opened 5 years ago

kdrag0n commented 5 years ago

Currently, a kernel backup is uncompressed. Each backup takes as much space as the boot partition, though usually only up to ~30 MB of the partition is used. When one takes kernel backups often, this accumulates to a rather significant size.

Compressing backups would be desirable to conserve space and potentially even reduce backup time as there is less I/O necessary. Zstandard (or Zstd for short) is a modern compression algorithm that is fast and compresses fairly well, not too far from deflate in terms of compression ratio while being much faster. The official file extension suffix for Zstd-compressed files is .zst. I would recommend using this library: https://github.com/luben/zstd-jni

Another thing related to backup file extensions: you should name the files with .img as they are raw boot images, rather than not including any file extension. For example, after compression is added, the name of a backup could be StockFeb2019.img.zst on disk and StockFeb2019 in the UI.

In testing, the size of the boot image dropped by 60% after being compressed with the default settings of Zstd, from 64 MB down to 25.84 MB and only took 20 ms longer on average.

franciscofranco commented 5 years ago

I'm not going to bundle anything that requires JNI to operate. I'll investigate simple compression for version 4.1.

kdrag0n commented 5 years ago

@franciscofranco There are pure Java implementations of Zstd available.

franciscofranco commented 5 years ago

Then I will investigate 👍