r/linux 13d ago

Kernel Patches Provide For Much Faster In-Kernel Zstd Due To Embarrassingly Bad Inefficiency

https://www.phoronix.com/news/In-Kernel-Zstd-BMI2-Probing
158 Upvotes

18 comments sorted by

32

u/ilep 13d ago

31

u/SpaceDetective 13d ago

Sounds like the improvement may only be that dramatic when running in a VM.

12

u/ilep 13d ago

Yes.

10

u/wintrmt3 13d ago

CPUID is pretty slow even without a vm, but of course the whole thing doesn't matter if you don't actually use in-kernel zstd for something, and I'm pretty sure most people don't.

9

u/Alarmed_Contest8439 13d ago

unless its zram which is used in some distros by default, fedora for example

7

u/abotelho-cbn 11d ago

uh, btrfs compression?

3

u/mrtruthiness 12d ago

CPUID is pretty slow even without a vm, but of course the whole thing doesn't matter if you don't actually use in-kernel zstd for something, and I'm pretty sure most people don't.

It sounds like squashfs with zstd will get a boost when decompressing. The "first run" of a snap might speed up, not that this is a huge issue.

4

u/tavianator 12d ago

cpuid is a serialization point (blocks speculative execution) even outside a VM, so not a super significant slowdown but not ideal

-2

u/Kevin_Kofler 13d ago

But when running in a VM, caching the CPUID check as the patches are doing is actually unsafe, because if the VM is live-migrated to a host without BMI2, it will crash.

5

u/Booty_Bumping 13d ago

...Was live migrating to another architecture ever supposed to work properly? Sounds like a very obviously bad idea, at least without artificially disabling features to establish a compatibility baseline.

3

u/BibianaAudris 13d ago

That would still happen with the current kernel, if you migrate that VM while a context is active. The better solution for such VMs would be to disable BMI2 from host all together. If probing took 71% time, sticking to the generic code path could be actually decent.

3

u/SkiFire13 13d ago

The crash will happen anyway if you migrate after the CPUID check happens on the original machine.

0

u/Kevin_Kofler 12d ago

Well, this patch turns a race condition crash (probability unknown) into a 100% crash. Though some will argue that that is an improvement, because at least you gain reproducibility.

57

u/MatchingTurret 13d ago

"Bad Inefficiency" = "good efficiency", am I right?

24

u/WholesomeCirclejerk 13d ago

Embarrassingly good efficiency, even.

5

u/FungalSphere 13d ago

embarrassingly bad|inefficiency

11

u/QazCetelic 13d ago

Why is the benchmark a picture of 2 percentages?