mirror of
https://github.com/google/brotli.git
synced 2026-07-08 17:56:58 +00:00
Brotli compression ratio depends on endianness of CPU #188
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @eustas on GitHub (Aug 2, 2017).
TL;DR: Just realized that "unaligned load + mask" technique used by some hashers will give endianness-inconsistent results.
This problem does not affect correctness, only what backward references selection and, consequently, compression ratio.
Lets say, hasher depends on
5bytes of input. Then, it does the following:hash = magic * (load64(src) & 0xFFFFFFFFFF). On little-endian CPU the first5bytes ofsrcwill affect the resulting hash. On big-endian CPU, the first3bytes will be ignored, and next5bytes will be taken into account. This way, on big-endian CPU, matches of length[5..7]are likely to be missed by hasher. On the other side there will be more8+matches.