Skip to content

Selective lazy evaluation with targetLength-adaptive gating - #4727

Open
BiplabRaut wants to merge 1 commit into
facebook:devfrom
amd:zstd_selective_lazy_opt
Open

Selective lazy evaluation with targetLength-adaptive gating#4727
BiplabRaut wants to merge 1 commit into
facebook:devfrom
amd:zstd_selective_lazy_opt

Conversation

@BiplabRaut

Copy link
Copy Markdown

Introduce ZSTD_SELECTIVE_LAZY compile-time option to reduce lazy evaluation overhead in the compression hot path for lazy and lazy2 strategies:

  • TargetLength-adaptive match length threshold: skip depth-1/depth-2 re-search when the initial match is strong (>= 12 bytes for low targetLength configurations, >= 16 bytes otherwise), or when the match is a repcode or has a short offset (<= 256)
  • Repcode early exit at depth-1 and depth-2: bypass expensive searchMax when a repcode match is already accepted, since regular matches cannot practically beat zero-cost offset encoding

All changes are gated behind ZSTD_SELECTIVE_LAZY. Default build produces upstream-identical output and passes existing deterministic tests.

Detailed Performance Results :

Enable with: make ZSTD_SELECTIVE_LAZY=1

image image image image image image image image

Introduce ZSTD_SELECTIVE_LAZY compile-time option to reduce lazy evaluation
overhead in the compression hot path for lazy and lazy2 strategies:

- TargetLength-adaptive match length threshold: skip depth-1/depth-2
  re-search when the initial match is strong (>= 12 bytes for low
  targetLength configurations, >= 16 bytes otherwise), or when the
  match is a repcode or has a short offset (<= 256)
- Repcode early exit at depth-1 and depth-2: bypass expensive searchMax
  when a repcode match is already accepted, since regular matches
  cannot practically beat zero-cost offset encoding

All changes are gated behind ZSTD_SELECTIVE_LAZY. Default build produces
upstream-identical output and passes existing deterministic tests.

Enable with: make ZSTD_SELECTIVE_LAZY=1
@meta-cla meta-cla Bot added the CLA Signed label Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants