-
-
Notifications
You must be signed in to change notification settings - Fork 424
Use BufferedOutputStream when writing the Zip file to improve performance
#1579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use BufferedOutputStream when writing the Zip file to improve performance
#1579
Conversation
When not using STORED entries use a BufferedOutputStream to avoid lots of small writes to the file system. Testing this with a 300mb jar build I see the total build time going from 40s to 30s. Note that it is not possible to do this with STORED entries as the implementation requires a RandomAccessFile to update the CRC after write.
c6d623a to
37b2918
Compare
BufferedOutputStream when writing the Zip file to improve performance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves ZIP file creation performance by using BufferedOutputStream for non-STORED compression methods. The change conditionally wraps the file output stream with a buffer to reduce system call overhead during ZIP file writing.
Key changes:
- Modified
DefaultZipCompressorto conditionally useBufferedOutputStreambased on compression method - Added changelog entry documenting the performance improvement
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| DefaultZipCompressor.groovy | Adds conditional buffering logic to improve ZIP writing performance for non-STORED entries |
| README.md | Documents the performance improvement in the changelog |
src/main/groovy/com/github/jengelman/gradle/plugins/shadow/internal/DefaultZipCompressor.groovy
Show resolved
Hide resolved
src/main/groovy/com/github/jengelman/gradle/plugins/shadow/internal/DefaultZipCompressor.groovy
Outdated
Show resolved
Hide resolved
…ernal/DefaultZipCompressor.groovy
When not using STORED entries use a BufferedOutputStream to avoid lots of small writes to the file system.
Testing this with a 300mb jar build I see the total build time going from 40s to 30s.
Note that it is not possible to do this with STORED entries as the implementation requires a RandomAccessFile to update the CRC after write.