LZMA decoder x86 CMOV patch
Languages and libraries
compression library optimization
SHOW HN2021
How HN took it
3 positive, 6 neutral or asking, 0 mixed, 1 critical, out of 10 comments about the project. Thread score +0.10.
Performance: 2 for, 0 againstExecution: 1 for, 0 againstIdea: 0 for, 1 against
The thread, comment by comment
Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.
positive neutral or mixed critical about another commenter or something else the maker
What HN said
What people liked
Decent measured speedup on a Ryzen workstation with xz
From 1 comment
Decent speedup on my 3970x. Including this patch reduced the number of instructions in lzma_decoder.s (using gcc 8.3.1) by about 8% (4417 lines of asm vs 4824). With perf stat,…
injinj on HN
Interesting low-level optimization result
From 1 comment
But this seems like a patch given to the LZMA project, with an interesting low-level result to boot.
dragontamer on HN
Objections
Compilers fail to reliably emit CMOV, so inline assembly is needed
From 2 comments
I find it sad that you need to use inline asm for this. Why isn't GCC providing a built-in to reliably use cmov? Every time I use ?: it's a lottery whether I get it or not. I've…
mgaunard on HNCool, but it doesn't generate SBB in real code, but instead gives me something like this: ``` xorl %r11d, %r11d cmpl %r12d, %eax seta %r11b ``` And if I do both of these, side by…
jpegqs on HN
CMOV is not always faster than branching
From 2 comments
https://www.agner.org/optimize/optimizing_assembly.pdf#page=70 TL;DR rule of thumb is that conditional jump is better than CMOV if the code is part of a dependency chain and the…
10000truths on HNCorrectly-predicted branching is better; but if the branch would have been mis-predicted, cmov is better. The compiler has no idea which will happen at runtime. Gcc will never…
ncmncm on HN
Requests
Test results on different x86 CPUs
From 1 comment
LZMA compression (used in 7-zip, XZ, LZMA2) is known as one of the best, but it has a noticeable drawback - it's slow. I tried to improve the decompression speed by removing…
jpegqs on HN
Compiler builtin for CMOV
From 2 comments
I find it sad that you need to use inline asm for this. Why isn't GCC providing a built-in to reliably use cmov? Every time I use ?: it's a lottery whether I get it or not. I've…
mgaunard on HNI think I’ve observed reliably-emitted CMOVs when using equivalent (but contrived) arithmetic branchless idioms, e.g. instead of (a ? b : c) write (-!!a & b | -!a & c) (yes, this…
mananaysiempre on HN
Questions
Would compiler intrinsics work across more architectures
From 1 comment
Would using compiler intrinsics instead of raw assembler have any benefits here, such as being applicable to more architectures?
CyberShadow on HN
Could the same be done for aarch64
From 1 comment
Hm, should the same be done for aarch64? Generally compilers (well, clang) seem to use CSEL all the time anyway, would be interesting to investigate this.
floatboth on HN
Alternatives named
Brotli
From 1 comment
If you're going for decoding speed wouldn't you be using brotli anyway? At a given compression ratio brotli is ~4x faster on decode path, and they are similar on the encode path.…
jeffbee on HN
Zstandard
From 1 comment
I think he mean is less popular (like zstandard and lz4) compared to zlib and LZMA and BZip2. this is unfortunate because Brotli and Zstandard compress much better than zLib and…
skyde on HN
LZ4 decoder with cmov
From 1 comment
Correctly-predicted branching is better; but if the branch would have been mis-predicted, cmov is better. The compiler has no idea which will happen at runtime. Gcc will never…
ncmncm on HN