EIM-519: add streaming tar.xz decompression using xz2#453
EIM-519: add streaming tar.xz decompression using xz2#453
Conversation
Summary of ChangesHello @alirana01, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical Out-Of-Memory issue encountered during tar.xz archive decompression on Windows by transitioning from an in-memory decompression method to a streaming one. The change significantly reduces memory consumption by processing archive contents on the fly, thereby improving the reliability and performance of the ESP-IDF installation process for large archives. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Hahihula
left a comment
There was a problem hiding this comment.
As discussed offline, the sreaming approach is good idea, but this PR not as it's regresion to already abandoned xz2 crate which is wrapper for liblzma C library. This was causing lot of issues in the past.
| tar = { version = "0.4", default-features = false } | ||
| zip = { version = "2.2.2", default-features = true } | ||
| lzma-rs = "0.3.0" | ||
| xz2 = { version = "0.1.6", features = ["static"] } |
There was a problem hiding this comment.
do not introduce this dependency on C
EIM-519: Fix OOM during tar.xz decompression on Windows
Problem
The ESP-IDF installation fails with on Windows during the tar.xz decompression step due to memory allocation failure. The root cause is that
decompress_tar_xzreads the entire decompressed payload into memory vialzma_rs::xz_decompress(&mut reader, &mut decompressed_data)before passing it to the tar extractor. For large archives this exhausts available memory.Fixes #449
Solution
Replace the in-memory decompression approach with streaming decompression using the
xz2crate'sXzDecoder, which wraps liblzma. The decoder is piped directly intotar::Archive, so data flows from disk through the XZ decoder into the tar extractor without buffering the full decompressed content in memory.Key changes:
xz2 = "0.1.6"(withstaticfeature for cross-platform builds) replaces the in-memorylzma-rsusage for tar.xz decompressiondecompress_tar_xz: Rewritten to useXzDecoder::new(BufReader::new(file))→Archive::new(decoder)streaming pipelineentry.unpack_in(), with debug logging for each entry and summary statistics on completionlzma_rs::xz_decompressandVec<u8>bufferTesting
Checklist
decompress_tar_xzfunction andlzma-rsdependency cleaned up