-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Improve compression performance by conditionally skipping lazy evaluation #4533
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
Open
BiplabRaut
wants to merge
1
commit into
facebook:dev
Choose a base branch
from
amd:zstd_fast_compress
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+110
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,38 @@ | |
| The benefit is that ZSTD_DUBT_UNSORTED_MARK cannot be mishandled after table reuse with a different strategy. | ||
| This constant is required by ZSTD_compressBlock_btlazy2() and ZSTD_reduceTable_internal() */ | ||
|
|
||
| #ifdef ZSTD_LAZY_SKIP_LONG_MATCHES | ||
| /* Lazy evaluation is performed only if the first match length | ||
| * is <= ZSTD_compressFastLazyLimit */ | ||
| #define ZSTD_COMPRESS_FAST_BASE_LAZY_LIMIT 5 | ||
|
|
||
| #define ZSTD_MAX_CLEVEL 22 | ||
| static const size_t ZSTD_compressFastLazyLimit[ZSTD_MAX_CLEVEL + 1] = { | ||
| ZSTD_COMPRESS_FAST_BASE_LAZY_LIMIT, /* base for negative levels */ | ||
| 0, /* level 1 */ | ||
| 0, /* level 2 */ | ||
| 0, /* level 3 */ | ||
| 0, /* level 4 */ | ||
| 0, /* level 5 */ | ||
| ZSTD_COMPRESS_FAST_BASE_LAZY_LIMIT, /* level 6 */ | ||
| ZSTD_COMPRESS_FAST_BASE_LAZY_LIMIT + 1, /* level 7 */ | ||
| 0, /* level 8.*/ | ||
| 0, /* level 9.*/ | ||
| 0, /* level 10.*/ | ||
| 0, /* level 11.*/ | ||
| 0, /* level 12.*/ | ||
| 0, /* level 13 */ | ||
| 0, /* level 14 */ | ||
| 0, /* level 15 */ | ||
| 0, /* level 16 */ | ||
| 0, /* level 17 */ | ||
| 0, /* level 18 */ | ||
| 0, /* level 19 */ | ||
| 0, /* level 20 */ | ||
| 0, /* level 21 */ | ||
| 0, /* level 22 */ | ||
| }; | ||
| #endif | ||
|
|
||
| /*-************************************* | ||
| * Context memory management | ||
|
|
@@ -105,6 +137,9 @@ typedef struct { | |
| BYTE* ofCode; | ||
| size_t maxNbSeq; | ||
| size_t maxNbLit; | ||
| #ifdef ZSTD_LAZY_SKIP_LONG_MATCHES | ||
| size_t lazyLimit; /* Match length limit to allow lazy evaluation */ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is unwelcome, I would prefer we avoid adding a conditional variable here. |
||
| #endif | ||
|
|
||
| /* longLengthPos and longLengthType to allow us to represent either a single litLength or matchLength | ||
| * in the seqStore that has a value larger than U16 (if it exists). To do so, we increment | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
That seems way too low.
In fact, in many cases, the search is targeting 5-byte matches, so all matches would trigger this condition, effectively changing
_lazyinto_greedy.