Skip to content

Conversation

@u1f35c
Copy link
Contributor

@u1f35c u1f35c commented Feb 1, 2022

The use of --long alters the window size internally in the underlying
library (lib/compress/zstd_compress.c:ZSTD_getCParamsFromCCtxParams),
which changes the memory required for decompression. This means that the
reported requirement from the zstd binary when -vv is specified is
incorrect.

A full fix for this would be to add an API call to be able to retrieve
the required decompression memory from the library, but as a
lighterweight fix we can just take account of the fact we've enabled
long mode and update our verbose output appropriately.

Fixes #2968

if (windowLog == 0) {
if (prefs->ldmFlag) {
/* If long mode is set libzstd will set this window size internally */
windowLog = ZSTD_WINDOWLOG_LIMIT_DEFAULT;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--long mode can be activated with a parameter.
For example, --long=30 means "use a 1 GB window size".
The shorter --long is equivalent to --long=27.

This means we can't guarantee that the window size is necessarily ZSTD_WINDOWLOG_LIMIT_DEFAULT when the --long mode is activated, it could be a different value if an explicit parameter was passed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, yes, there's an override via ZSTD_overrideCParams that I missed, so the ldmFlag check should only be performed if the windowLog ends up as 0.

The use of --long alters the window size internally in the underlying
library (lib/compress/zstd_compress.c:ZSTD_getCParamsFromCCtxParams),
which changes the memory required for decompression. This means that the
reported requirement from the zstd binary when -vv is specified is
incorrect.

A full fix for this would be to add an API call to be able to retrieve
the required decompression memory from the library, but as a
lighterweight fix we can just take account of the fact we've enabled
long mode and update our verbose output appropriately.

Fixes facebook#2968
@Cyan4973
Copy link
Contributor

Cyan4973 commented Feb 4, 2022

Thanks @u1f35c !

@Cyan4973 Cyan4973 merged commit fcef199 into facebook:dev Feb 4, 2022
@Cyan4973 Cyan4973 mentioned this pull request Feb 9, 2023
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.

Minor -vv issue.

3 participants