-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it a good idea to compress rootfs in live-iso using zstd instead of gzip? #820
Comments
ha I was pondering the same on my morning run this morning after having
seen your other issue....
let me get the squashfs fixed first so that we can then consider this
one... I think it's a good idea just a matter of sequencing the two steps
(and checking the kernel configs just to be sure) to avoid things going
bang in the middle ;)
…On Wed, Dec 25, 2024 at 6:13 AM hksdpc255 ***@***.***> wrote:
*Is your feature request related to a problem? Please describe.*
There is a hard-coded gzip compression at line 95:
https://github.com/clearlinux/clr-installer/blob/ffb386f47443f95f0e4c2f03891474ad4212e573/isoutils/isoutils.go#L88-L106
Lots of benchmarks shows that zstd decompresion speed is much faster than
gzip even using compression level 22:
https://gist.github.com/baryluk/70a99b5f26df4671378dd05afef97fce
*Describe the solution you'd like*
Zstd with compression level 22 will make the rootfs.img smaller but it
will consume more memory when the kernel decompress it.
args := []string{
"mksquashfs",
tmpPaths[clrRootfs],
tmpPaths[clrCdroot] + "/images/rootfs.img",
"-b",
"131072",
"-comp",
"zstd",
"-Xcompression-level",
"22",
"-e",
"boot/",
"-e",
"proc/",
"-e",
"sys/",
"-e",
"dev/",
"-e",
"run/",
}
*Describe alternatives you've considered*
Zstd with compression level 19 will make the rootfs.img small and fast,
consuming resonable memory.
args := []string{
"mksquashfs",
tmpPaths[clrRootfs],
tmpPaths[clrCdroot] + "/images/rootfs.img",
"-b",
"131072",
"-comp",
"zstd",
"-Xcompression-level",
"19",
"-e",
"boot/",
"-e",
"proc/",
"-e",
"sys/",
"-e",
"dev/",
"-e",
"run/",
}
*Additional context*
Currently, zstd support for mksquashfs in ClearLinux seems broken.
clearlinux/distribution#3235
<clearlinux/distribution#3235>
But I still believe compress rootfs using zstd is good for both
performance and disk usage.
—
Reply to this email directly, view it on GitHub
<#820>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJ54FOVISXXL5D3RZWZKQD2HK4RXAVCNFSM6AAAAABUGAZ6I6VHI2DSMVQWIX3LMV43ASLTON2WKOZSG42TQOBTGAYTSOI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
I successfully interposed a custom shell script wrapper for /bin/mksquashfs to modify the compression parameters to zstd. The generated Live-ISO boot sequence completed successfully without any observable issues. |
I noticed that the initrd located in Live-ISO is gzip-compressed. |
Zstd-compressed initrd and squashfs tested with this post-install script: #!/bin/sh -ex
[ -f /bin/xorriso.bak ] || mv /bin/xorriso{,.bak}
cat << 'EOF' > /bin/xorriso
#!/bin/sh -ex
for arg in "$@" ; do
[ -f "$arg/EFI/BOOT/initrd.gz" ] && [ -f "$arg/EFI/efiboot.img" ] && [ -f "$arg/loader/entries/iso-checksum.conf" ] && [ -f "$arg/loader/entries/Clear-"*".conf" ] && [ -f "$arg/isolinux/isolinux.cfg" ] || continue
gzip -d < "$arg/EFI/BOOT/initrd.gz" | zstd -19 > "$arg/EFI/BOOT/initrd.zst"
rm "$arg/EFI/BOOT/initrd.gz"
mcopy -spmi "$arg/EFI/efiboot.img" :: "$arg/EFI/efiboot.dir"
rm "$arg/EFI/efiboot.img" "$arg/EFI/efiboot.dir/EFI/BOOT/initrd.gz"
cp "$arg/EFI/BOOT/initrd.zst" "$arg/EFI/efiboot.dir/EFI/BOOT/initrd.zst"
sed -i 's@ /EFI/BOOT/initrd.gz@ /EFI/BOOT/initrd.zst@g' "$arg/EFI/efiboot.dir/loader/entries/"*.conf "$arg/loader/entries/"*.conf "$arg/isolinux/isolinux.cfg"
fallocate -l "$(du -d 0 -B 4K "$arg/EFI/efiboot.dir" | awk '{print int(($1+255)/256)+1;exit}')M" "$arg/EFI/efiboot.img"
mkfs.fat -n CLEAR_EFI "$arg/EFI/efiboot.img"
mcopy -spmi "$arg/EFI/efiboot.img" "$arg/EFI/efiboot.dir/"* ::
rm -r "$arg/EFI/efiboot.dir"
done
xorriso.bak -md5 all "$@" -J -R -iso-level 3
EOF
chmod +x /bin/xorriso
[ -f /bin/mksquashfs.bak ] || mv /bin/mksquashfs{,.bak}
cat << 'EOF' > /bin/mksquashfs
#!/bin/sh -ex
for i in $(seq $#) ; do
case "$1" in
-Xhc|-noI|-noId|-noD|-noF|-noX|-no-compression) shift ;;
-X*) shift 2 && set -- -Xhc "$@" ;;
-comp) shift 2 && set -- -Xhc "$@" -comp zstd -Xcompression-level 19 -b 1048576 ;;
-b) shift 2 && set -- -Xhc "$@" ;;
*) set -- "$@" "$1" && shift ;;
esac
done
mksquashfs.bak "$@"
EOF
chmod +x /bin/mksquashfs Boot sequence completed successfully. Remember to run |
Is your feature request related to a problem? Please describe.
There is a hard-coded gzip compression at line 95:
clr-installer/isoutils/isoutils.go
Lines 88 to 106 in ffb386f
Lots of benchmarks shows that zstd decompresion speed is much faster than gzip even using compression level 22:
https://gist.github.com/baryluk/70a99b5f26df4671378dd05afef97fce
Describe the solution you'd like
Zstd with compression level 22 will make the rootfs.img smaller but it will consume more memory when the kernel decompress it.
Describe alternatives you've considered
Zstd with compression level 19 will make the rootfs.img small and fast, consuming resonable memory.
Additional context
Currently, zstd support for mksquashfs in ClearLinux seems broken. clearlinux/distribution#3235
But I still believe compress rootfs using zstd is good for both performance and disk usage.
The text was updated successfully, but these errors were encountered: