refactor(pm): use libdeflater for gzip decompression - #2570
Conversation
Summary of ChangesHello @elrrrrrrr, 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 undertakes a significant refactoring of the package downloader module to enhance its overall performance and resource efficiency. The changes focus on optimizing the decompression and extraction of gzipped tarballs by leveraging more performant libraries and parallelizing file system operations. This leads to a more robust and faster download process, crucial for efficient package management. Highlights
Changelog
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
|
There was a problem hiding this comment.
Code Review
This pull request refactors the downloader to use libdeflate for faster gzip decompression, which is a great performance improvement. The code is well-structured, separating network, decompression, and file writing logic. The introduction of a buffer pool is also a nice touch.
However, I've found a few issues that need to be addressed:
- A critical bug in the
OnceMapimplementation that could lead to packages not being extracted. - Several places where errors are silently ignored, which could make debugging difficult.
- A test that seems to be broken after the refactoring.
I've left detailed comments on these points below.
7075a8a to
9dc71dd
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a significant refactoring of the package downloader to improve performance by replacing async-compression and tokio-tar with the much faster libdeflate. The new implementation shifts from a streaming model to an in-memory batch processing approach, which is a valid trade-off for performance in this context. The code is well-structured, utilizing a OnceMap for concurrent downloads, a buffer pool to reduce allocations, and rayon for parallel file I/O.
My review focuses on the robustness and clarity of the new implementation. I've identified a potential issue where the decompression logic might fail for files with very high compression ratios and suggested a more robust retry mechanism. I also pointed out a small piece of redundant code that can be removed to improve clarity. Overall, this is a high-quality performance enhancement.
07ef8fe to
242b796
Compare
58540db to
f87d561
Compare
| fn collect_entries( | ||
| src: &Path, | ||
| dst: &Path, | ||
| files: &mut Vec<CloneEntry>, |
| } | ||
|
|
||
| // Phase 3: Clone files sequentially | ||
| for entry in &files { |
There was a problem hiding this comment.
嗯嗯,现在就是同步同步 fs 放在 spawn_blocking 里去执行,性能会比之前 async 异步 api 好一些。
还试过使用 rayon 来并发写入,这个场景性能提升不明显没有采用
Uh oh!
There was an error while loading. Please reload this page.