fix speed of --patch-from mode at high compression levels#4276
Merged
Conversation
c92d015 to
e2aac8f
Compare
terrelln
approved these changes
Feb 3, 2025
lib/compress/zstdmt_compress.c
Outdated
| } else { | ||
| /* note : a loadPrefix becomes an internal CDict */ | ||
| mtctx->cdictLocal = ZSTD_createCDict_advanced(dict, dictSize, | ||
| dictLoadMethod, dictContentType, |
Contributor
There was a problem hiding this comment.
We don't actually care about the dictLoadMethod here, right? If it was ZSTD_dlm_byCopy, the outer ZSTD_CCtx must have already token ownership of the buffer. So we can use byRef here.
Suggested change
| dictLoadMethod, dictContentType, | |
| ZSTD_dlm_byRef, dictContentType, |
lib/compress/zstdmt_compress.c
Outdated
| size_t ZSTDMT_initCStream_internal( | ||
| ZSTDMT_CCtx* mtctx, | ||
| const void* dict, size_t dictSize, ZSTD_dictContentType_e dictContentType, | ||
| const void* dict, size_t dictSize, ZSTD_dictContentType_e dictContentType, ZSTD_dictLoadMethod_e dictLoadMethod, |
Contributor
There was a problem hiding this comment.
Since we can always use byRef, we don't need to ass a dictLoadMethod in here.
| size_t dictSize; | ||
| ZSTD_dictContentType_e dictContentType; | ||
| } ZSTD_prefixDict; | ||
| ZSTD_dictLoadMethod_e loadMethod; |
Contributor
There was a problem hiding this comment.
Since we can always use byRef in ZSTDMT, we don't need to store it here.
improves compression ratio at low levels
by avoiding to duplicate in memory a dictionary that was passed by reference.
thus saving a bit of memory and a little bit of cpu time
--patch-from no longer blocked on first job dictionary loading
This reverts commit 821fc56.
3f96678 to
23e5f80
Compare
Merged
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When employing
--patch-fromin combination with very high compression levels,compression speed plummets significantly, becoming extremely slow.
This issue is mitigated by this patch,
which sensibly reduces compression time for this scenario.
Benchmark: patching
linux-6.7.tar(~1.4GB) fromlinux-6.6.taron a M1 Pro laptop (employing 2 threads by default)
devThe impact is even more pronounced with a larger amount of threads.
Benchmark on a core i7-9700k with 6 threads :
devAlso: improved memory usage of
--patch-from, by skipping an internalCDictcreation that was duplicating reference content in memory.