Fix setting of common properties (-mmt=n
option is ignored by many handlers)
#349
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.
This PR fixes setting of
-mmt=n
option for many handlers (previously ignored by zstd, brotli, lz*, etc), so adding-mmt=1
to the call like below caused multi-threaded processing with default number of threads:So parallel compression of multiple files with several processes can cause unneeded context switches due to unexpected multi-threaded processing.
Analyze
Return after call of
SetCommonProperty
(setting common propertiesmt
andmemuse
to members ofCCommonMethodProps
avoid that properties gets added regularly, so many handlers setting that viaSetCoderProperties
wouldn't consider that option at all, because option doesn't exists in the props.For example this branch was previously never reachable:
7-Zip-zstd/CPP/7zip/Compress/ZstdEncoder.cpp
Line 58 in 8f52579
Alternatively one'd rewrite it in every affected handler like in:
7-Zip-zstd/CPP/7zip/Archive/ZstdHandler.cpp
Line 276 in 8f52579
with:
Just it would be not quite backwards compatible (if one remove dup processing in
SetCoderProperties
at the same time).As well as one should extend encoder and/or decoder of every handler, and this fix is minimalistic in opposite.