Skip to content

perf: tighten entropy and LZ77 hot paths#714

Open
hjanuschka wants to merge 2 commits into
libjxl:mainfrom
hjanuschka:perf/pr08-entropy-lz77-hotpath
Open

perf: tighten entropy and LZ77 hot paths#714
hjanuschka wants to merge 2 commits into
libjxl:mainfrom
hjanuschka:perf/pr08-entropy-lz77-hotpath

Conversation

@hjanuschka

Copy link
Copy Markdown
Collaborator

This makes ANS/Huffman/LZ77 read paths more direct in hot loops by inlining and removing repeated bounds-check overhead where invariants are already validated. It also adds a no-LZ77 clustered read helper for specialization call sites. Unsafe is only used for unchecked indexing under validated context/window invariants, with debug assertions documenting each bound.

@github-actions

Copy link
Copy Markdown

Benchmark @ a1507cc

MULTI-FILE BENCHMARK RESULTS (4 files)
  CPU architecture: x86_64
  WARNING: System appears noisy: high system load (1.91). Results may be unreliable.
Statistics:
  Confidence:               99.0%
  Max relative error:        3.0%

Comparing: e883140e (Base) vs 5334cbe0 (PR)

File Base (MP/s) PR (MP/s) Δ%
bike.jxl 24.486 24.392 -0.39% ±2.9%
green_queen_modular_e3.jxl 7.897 7.651 -3.12% ±0.5%
green_queen_vardct_e3.jxl 23.997 23.816 -0.76% ±1.1%
sunset_logo.jxl 2.784 2.977 +6.91% ±0.9%

@veluca93

Copy link
Copy Markdown
Member

This PR clearly has some speed benefits, but I am not convinced by the approach to unsafe - I will look at this more in depth and I will try to see how it can be improved.

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.

2 participants