8000 LZ4 HC match finder and parsers use direct offset values by Cyan4973 · Pull Request #1173 · lz4/lz4 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

LZ4 HC match finder and parsers use direct offset values #1173

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

Merged
merged 6 commits into from
Oct 1, 2022
Merged

Conversation

Cyan4973
Copy link
Member
@Cyan4973 Cyan4973 commented Sep 30, 2022

Direct offset values replace the former method of "virtual pointers", which could lead to UB in some complex scenarios involving a combination of HC compression, external dictionaries and low memory addresses.

As importantly, it also makes the code a bit easier to read.

The produced compressed data remains strictly bit-identical.
Performance is unchanged on M1+clang,
but it's unfortunately slightly slower on Skylake (both gcc & clang).

Even in latter case, the performance difference remains small (<5%), confined to fastest levels (3-5), and quickly unmeasurable at higher levels.

I'm tempted to favor correctness and readability over the small speed difference, given that these HC levels are not speed-sensitive (as long as performance differences remain within a few %).

Cyan4973 and others added 6 commits September 29, 2022 18:29
instead of a virtual past pointer.
instead of a virtual pointer
replaced by direct offset values.
replaced by direct offset value.
this virtual pointer was only used in rare _dstSize scenario.
this formalized better the coupling between match length and match offset
which were 2 separated variables before.
because ubsan complains even about intermediate pointer arithmetic results
(in a simple linear formula with 3 factors for example).

use parenthesis to make sure calculations go directly from one valid memory address to another valid memory address value.
@Cyan4973 Cyan4973 merged commit b9117c2 into dev Oct 1, 2022
@Cyan4973 Cyan4973 deleted the md_off branch December 29, 2022 03:08
@Cyan4973 Cyan4973 restored the md_off branch February 26, 2023 16:00
@Cyan4973 Cyan4973 deleted the md_off branch January 2, 2024 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0