-
-
Notifications
You must be signed in to change notification settings - Fork 14k
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
linux kernel: prefer zstd where possible #302300
Conversation
Going to rebuild my infra on my Hydra and boot into that kernel to see if this has some unexpected side-effects. |
First breakage I found is that images from
Taking a look. EDIT: so the problem appears to be busybox not supporting zstd-compressed modules. Gonna check if there are usable patches out there, otherwise I'll see if I can get kmod into the image builder. |
Have a fix locally now, but I'm too tired now to push, will try to get to it tomorrow. |
Has the impact on the size been measured for the kernel modules? The "comparable" compression ratio of zstd (as compared to LZMA) can be quite a bit worse (double digit percentage) depending on the levels and specifics of the uncompressed data. (This concern should not apply to the other two points; zram changes from a worse compressor and for the firmware it's only adding support.) |
fwiw the stage1 modules-shrunk is 7.6M (xz) vs 9.4M (zstd) on my laptop. Currently preparing a patch that provides zstd compression of the firmware. Here we have 492.6M (zstd) vs 440.3M (xz) though I'm playing around with different levels here. Will probably document the exact impact in the commit message and perhaps also in the release notes. |
Pushed an improved version of the original patch that fixes the VM image builder. Pushed another commit which actually uses zstd to compress firmware. Will rebuild my infra once again with these two patches to see if I find more problems and how well it works out. There's a ~11% increase (440M -> 490M) in linux firmware now. Perhaps we want to make the behavior configurable here? Will write something to the release notes later. Also cc @fpletz. |
I'd personally be more worried about the modules, since some of them go into the initrd. If I understand correctly, this is where you observed the increase from 7.6MB to 9.4MB, which seems quite bad. |
You could try the |
zstd = { | ||
ext = "zst"; | ||
nativeBuildInputs = [ zstd ]; | ||
cmd = file: target: ''zstd -T1 -6 --check -f "${file}" -o "${target}"''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cmd = file: target: ''zstd -T1 -6 --check -f "${file}" -o "${target}"''; | |
cmd = file: target: ''zstd -T1 -19 --long --check -f "${file}" -o "${target}"''; |
You can go as high as level 19, and --long
should work too. This is consistent with what is configured for xz
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could reuse/expand the data from pkgs/build-support/kernel/initrd-compressor-meta.nix
?
("no, too much bikeshedding" is an acceptable answer)
Personally, I'ld love to see zstd support. But as others mentioned xz generally seems to have a better compression ratio than zstd. I hope the suggestions from @aviallon can make a difference. The hit on the firmware is IMHO pretty bad since most people running on hardware will need at least one binary blob from the standard linux nonfree firmware package. I was thinking about splitting it because some of the bigger blobs from unpopular vendors are used very rarely anyway:
For instance, we could split it loosely based on how Debian is currently doing it: https://packages.debian.org/search?suite=sid&searchon=names&keywords=firmware |
fwiw that works pretty well. I use a thinclient with 4GB emmc as bluetooth/pulse/librespot-connected speaker which is why I didn't want to install linux-firmware on it. Instead, I built a derivation that only copies the relevant bluetooth parts over and called it a day.
Agreed. |
Perhaps I misremembered something: I somehow had in mind that high compression levels also affect decompression performance in zstd which is why I stopped after The total difference between xz and zstd compressed firmware is now 440M vs 460M, i.e. a size increase of 4.5% (vs 11% before). |
So, with |
It's a pity there is no |
So, I need a bit of feedback on how to resume here: zram/zswapZRAM_MULTI_COMP was enabled in #303821 (comment), so we need Z3FOLD here and are done with it. firmwareI think we're good with 4.4% increase. If nobody disagrees, I think this can go to master (along woth the zram/zswap stuff). kernel modulesI think we all agree that the state I have pushed here isn't really acceptable (almost 30% increase of
I need a few more opinions from other people because I'm not sure what's the best option to proceed. Opinions? |
I don't think adding delta updates to Nix is realistic at least in the short term. I also think the size increase shouldn't be a huge deal. |
I agree it is better maintained than xz, but I have reservation about that general opinion. I'm not surprised by a company claiming they "forced to make data accessible by gov to satisfy a local law endorsement", though it's unlikely to do so in a compression format. |
The main issue with the really high compression levels isn't speed, but memory usage -- including for decompression -- as far as I understand the manpage. That aside, I like this! |
Closes NixOS#302291 Closes NixOS#301536 The following things have changed: * For 5.7+: ZSWAP compressor uses zstd now. * For 5.11+: ZRAM compressor uses zstd now. * For 5.13+: kernel modules are compressed with zstd instead of xz. * For 5.19+: support zstd-compressed firmware. The modules-closure functionality needed explicit support for copying over `.zst` files. Also, the VM image builder used busybox's `insmod` before which doesn't support zstd. Switched to `kmod` and added xz/zstd as dependencies for it, similar to how it's done for the actual stage1 in d33e52b. The use of `kmod` here doesn't seem to be such a big deal since it's only a build-time dependency.
Closes NixOS#267442 $ nix path-info -Sh /nix/store/qj1dm7wfw5m3mxf1gn3fdm0az9y1h5ny-linux-firmware-20240312-xz /nix/store/qj1dm7wfw5m3mxf1gn3fdm0az9y1h5ny-linux-firmware-20240312-xz 440.3M $ nix path-info -Sh /nix/store/c3szcjxb3g990dbiz7llwmkaf0bi98j2-linux-firmware-20240312-zstd /nix/store/c3szcjxb3g990dbiz7llwmkaf0bi98j2-linux-firmware-20240312-zstd 460.6M This is an increase of 4.4%, but OTOH zstd has a significantly higher decompression speed[1]. [1] https://gregoryszorc.com/blog/2017/03/07/better-compression-with-zstandard/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
running that since some days, no issues with it, lgtm
The change I merged too hastily in NixOS#302300 increases the size by ~30%. This could be improved upon, but in the meantime let's go back to xz while keeping zstd-compressed firmware (only 4.4% larger) and _support_ for zstd-compressed modules.
The change I merged too hastily in NixOS#302300 increases the size by ~30%. This could be improved upon, but in the meantime let's go back to xz while keeping zstd-compressed firmware (only 4.4% larger) and _support_ for zstd-compressed modules.
I didn't mean to merge the make-modules-30%-bigger change, reverting in #310110. The rest should be fine IMO, it's an improvement overall and leaves less open WIP. |
Could we reopen this since the change was reverted? |
done. |
The change I merged too hastily in NixOS#302300 increases the size by ~30%. This could be improved upon, but in the meantime let's go back to xz while keeping zstd-compressed firmware (only 4.4% larger) and _support_ for zstd-compressed modules. (cherry picked from commit 2f04c5f)
Since NixOS/nixpkgs#302300 is merged, hardware.firmware are now compressed with zstd. On my oneplus-enchilada, this is causing the WLAN interface disappearing. This PR fixes this by copying the changes of kernel config from NixOS/nixpkgs#302300
Since NixOS/nixpkgs#302300 is merged, hardware.firmware are now compressed with zstd. On my oneplus-enchilada, this is causing the WLAN interface disappearing. This PR fixes this by copying the changes of kernel config from NixOS/nixpkgs#302300
Since NixOS/nixpkgs#302300 is merged, hardware.firmware are now compressed with zstd. On my oneplus-enchilada, this is causing the WLAN interface disappearing. This PR fixes that by copying the changes of kernel config from NixOS/nixpkgs#302300
Description of changes
Closes #302291
Closes #301536
The following things have changed:
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.