-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix up superblock mode #2100
Fix up superblock mode #2100
Conversation
7184e79
to
f28bc9a
Compare
@@ -2463,6 +2460,16 @@ static size_t ZSTD_compressBlock_targetCBlockSize_body(ZSTD_CCtx* zc, | |||
{ | |||
DEBUGLOG(6, "Attempting ZSTD_compressSuperBlock()"); | |||
if (bss == ZSTDbss_compress) { | |||
if (/* We don't want to emit our first block as a RLE even if it qualifies because | |||
* doing so will cause the decoder (cli only) to throw a "should consume all input error." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
* Returns the ZSTD_sequenceLength for the given sequences. It handles the decoding of long sequences | ||
* indicated by longLengthPos and longLengthID, and adds MINMATCH back to matchLength. | ||
*/ | ||
MEM_STATIC ZSTD_sequenceLength ZSTD_getSequenceLength(seqStore_t const* seqStore, seqDef const* seq) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that this function, ZSTD_getSequenceLength()
, is only used within zstd_compress_superblock.c
.
Therefore, why is it implemented in common/zstd_internal.h
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a generic helper function related to sequences. By putting it near the sequences, hopefully the next person who needs to read a litlen/matchlen will use this function, and see the reasoning behind it. A refactor of existing helper code, like the sequence collector, should switch it to using this function.
@@ -16,6 +16,7 @@ | |||
#include "zstd_compress_sequences.h" | |||
#include "zstd_compress_literals.h" | |||
#include "zstd_compress_superblock.h" | |||
#include "zstd_internal.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor : document a reason for this dependency (getSequenceLength()
)
tests/fuzzer.c
Outdated
@@ -12,6 +12,7 @@ | |||
/*-************************************ | |||
* Compiler specific | |||
**************************************/ | |||
#include "zstd_internal.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor : document a reason for this additional dependency.
Question : why does it have to be here, rather than in the * Includes
paragraph below ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohhh, that is why I ended up with duplicate includes... I think vscode decided to start silently adding missing includes...
tests/fuzzer.c
Outdated
DISPLAYLEVEL(3, "OK \n"); | ||
|
||
DISPLAYLEVEL(3, "test%3d: superblock with no literals : ", testNb++); | ||
// Generate the same data 20 times over |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor nit : avoid //
comment style
Thanks for this fairly large fix, complete with a new test set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only some minor nits suggested, looks good to me
Fixes:
ZSTD_minGain()
.Tests:
simple_round_trip
fuzzer enables superblock mode, it checks that the compressed size isn't expanded too much.Remaining limitations:
Fixes #2096