Skip to content

pzstd: add --stream-size option for stdin compression - #4759

Open
VirajMishra1 wants to merge 1 commit into
facebook:devfrom
VirajMishra1:add-pzstd-stream-size
Open

pzstd: add --stream-size option for stdin compression#4759
VirajMishra1 wants to merge 1 commit into
facebook:devfrom
VirajMishra1:add-pzstd-stream-size

Conversation

@VirajMishra1

Copy link
Copy Markdown

Adds --stream-size=N to pzstd, matching the existing flag in the main zstd CLI. When compressing from stdin/pipe, this tells the compressor the total input size so it can:

  • Write the content size in the frame header
  • Select optimal window size via ZSTD_getParams / ZSTD_adjustCParams

Without this flag, pzstd compressing from stdin has no way to communicate the input size to the compression context, resulting in suboptimal compression parameters.

Changes (all within contrib/pzstd/):

  • Options.h -- added streamSrcSize field, passed to ZSTD_getParams() and ZSTD_adjustCParams() in determineParameters()
  • Options.cpp -- added parseUnsignedLL() helper (matches existing parseUnsigned style), --stream-size parsing with = and space-separated syntax, usage text
  • Pzstd.cpp -- when input is stdin and streamSrcSize > 0, use it as inputSize instead of 0
  • test/OptionsTest.cpp -- added StreamSize test covering both syntaxes, missing argument, non-numeric argument, and default value

Build succeeds, round-trip smoke test passes.

Closes #3171

Add --stream-size flag to pzstd, matching the existing flag in the main
zstd CLI. When compressing from stdin/pipe, this tells the compressor
the total input size, enabling it to write the content size in the frame
header and optimize window size for better compression ratios.

Closes facebook#3171
@meta-cla meta-cla Bot added the CLA Signed label Sep 3, 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.

Add stream-size option to pzstd

1 participant