Conversation
Replace the legacy 2006 LZMA encoder and custom decoder with the current 7-Zip LZMA SDK C implementation. Adapt the existing NSIS streaming interfaces to LzmaEnc and LzmaDec, preserving the five-byte properties header, end marker, allocator behavior, and single-worker-thread compression model. The modern decoder eliminates the integer modulo performed for every decompressed byte and copies matches in runs, substantially improving extraction performance for large LZMA-compressed payloads.
Author
|
@sredna We were experimenting with replacing NSIS and noticed that our custom installer extracted the payload way faster. Codex identified this performance problem and performed the SDK upgrade. Mind allowing the CI run? |
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.
Updates NSIS from its legacy 2006 LZMA implementation to LZMA SDK 26.03.
The old C++ encoder and custom decoder have been replaced with the current 7-Zip C encoder and decoder. Thin adapters preserve NSIS’s existing compressor and installer-stub interfaces.
Motivation
The legacy decoder advanced its dictionary position using a runtime integer modulo for every decompressed byte:
dictionaryPos = (dictionaryPos + 1) % dictionarySize;Because
dictionarySizeis determined at runtime, this can produce an integer division in the inner decompression loop. Large payloads can therefore incur millions of divisions.The current 7-Zip decoder increments the dictionary position, wraps only at buffer boundaries, and copies matches in runs. This should substantially reduce CPU time during extraction.
Changes
LzmaEnc.LzmaDec.sdk.diff.Compatibility
The generated stream format remains unchanged:
Existing NSIS streaming semantics are also retained, including partial input consumption, bounded output buffers, reset behavior, and the existing result codes.