Message ID | CAENjB=+5CtENBf7Q1po=OZn6tstAH7QzhcRGiPQPOsvnk_yg-Q@mail.gmail.com |
---|---|
State | Changes Requested |
Delegated to: | John Crispin |
Headers | show |
Actually lzo compresses better but they are both fast. lz4 is faster on embedded devices. zram-swap should use lz4 if available and the patch can be as it was.http://blog.jpountz.net/post/28092106032/wow-lz4-is-fast <mangix> lz4 has compression levels. in any case, speed > size on embedded devices. interestingly enough, higher lz4 compression yields faster decompression <hojuruku> http://www.ilsistemista.net/index.php/linux-a-unix/44-linux-compressors-comparison-on-centos-6-5-x86-64-lzo-vs-lz4-vs-gzip-vs-bzip2-vs-lzma.html?start=4 They are mostly the same. On average 2.8 compression ratio in lz4 vs 3.0 in lzo. Can't hurt to go with the fastest. On 3 July 2016 at 07:10, Luke McKee <hojuruku@gmail.com> wrote: > v2 of the patch. uses lz4 compression by default. lz4 is always > installed by openwrt Makefile Config.in if zram. > > lz4 is best for compressed filesystems as we all know (if you had to > choose between that and lzo). > zram-swap can keep using lzo for speed! > > I'll work in a compatibility patch for zram-swap script next to see if > zram0 is already being used and hot-add a new device.
--- a/initd/zram.c 2016-07-03 06:39:51.011999930 +0700 +++ b/initd/zram.c 2016-07-03 07:00:34.143492847 +0700 @@ -82,7 +82,7 @@ int mount_zram_on_tmp(void) { - char *mkfs[] = { "/usr/sbin/mkfs.ext4", "-b", "4096", "-F", "-L", "TEMP", "-m", "0", "/dev/zram0", NULL }; + char *mkfs[] = { "/sbin/mkfs.ext2", "-b", "4096", "-F", "-L", "TEMP", "-m", "0", "/dev/zram0", NULL }; FILE *fp; long zramsize; pid_t pid; @@ -94,6 +95,14 @@ } mkdev("*", 0600); + + fp = fopen("/sys/block/zram0/comp_algorithm", "r+"); + if (fp == NULL) { + ERROR("Can't open /sys/block/zram0/comp_algorithm: %s\n", strerror(errno)); + return errno; + } + fprintf(fp, "%s", "lz4" ); + fclose(fp); zramsize = proc_meminfo() / 2; fp = fopen("/sys/block/zram0/disksize", "r+"); @@ -107,10 +116,10 @@ pid = fork(); if (!pid) { execvp(mkfs[0], mkfs); - ERROR("Can't exec /sbin/mkfs.ext4\n"); + ERROR("Can't exec /sbin/mkfs.ext2\n"); exit(-1); } else if (pid <= 0) { - ERROR("Can't exec /sbin/mkfs.ext4\n"); + ERROR("Can't exec /sbin/mkfs.ext2\n"); return -1; } else { waitpid(pid, NULL, 0);