镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Document CPU cost of high HC compression levels - #141

Merged
yawkat merged 1 commit into
mainfrom
fix/issue-121
Sep 25, 2026
Merged

yawkat merged 1 commit into
mainfrom
fix/issue-121

Conversation

@yawkat

@yawkat yawkat commented Sep 25, 2026

Copy link
Copy Markdown
Owner

Fixes #121.

This adds a paragraph to the Javadoc of LZ4Factory.highCompressor(int):

  • In the safe and unsafe Java implementations, the maximum match-search effort per position doubles with each level (2^(level-1) attempts, up to 65536 at level 17).
  • The cost stays linear in input size, but on highly repetitive or crafted input, high levels can be orders of magnitude slower than on typical data.
  • When compressing untrusted input and CPU time matters, prefer the default level (9) or lower.

The text doesn't claim that 12 is safe and 13 is not. Measured on 1 MiB of random bytes drawn from {a,b}, level 9 took 0.9 s, level 12 took 5.5 s, and levels 13 to 17 took about 9.7 s, compared with about 35 ms on random data at any level. The doubling claim is limited to the Java implementations, because native lz4hc caps at level 12 and uses a different parser for levels 10 to 12.

🤖 Generated with Claude Code

Fixes #121

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yawkat yawkat added this to the 1.11.4 milestone Sep 25, 2026
@yawkat
yawkat enabled auto-merge (squash) September 25, 2026 15:47
@yawkat
yawkat merged commit df4ffed into main Sep 25, 2026
6 checks passed
@yawkat
yawkat deleted the fix/issue-121 branch September 25, 2026 16:27
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.

Javadoc: warn about the CPU cost of pure-Java HC compression at levels >= 13

1 participant