mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-09 05:24:55 +00:00
[PR #897] [MERGED] Implement ReadByte for BufferedSubStream #1319
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/adamhathcock/sharpcompress/pull/897
Author: @Morilli
Created: 2/16/2025
Status: ✅ Merged
Merged: 2/17/2025
Merged by: @adamhathcock
Base:
master← Head:bufferedsubstream-readbyte📝 Commits (2)
441147cImplement ReadByte for BufferedSubStream2411f4fMerge branch 'master' into bufferedsubstream-readbyte📊 Changes
1 file changed (+24 additions, -0 deletions)
View changed files
📝
src/SharpCompress/IO/BufferedSubStream.cs(+24 -0)📄 Description
I noticed absurd memory allocations when decompressing 7-zip files and tracked it down to
BufferedSubStreamnot overridingReadByte.From the documentation:
The default implementations of ReadByte() and WriteByte(Byte) create a new single-element byte array, and then call your implementations of Read(Byte[], Int32, Int32) and Write(Byte[], Int32, Int32). When you derive from Stream, we recommend that you override these methods to access your internal buffer, if you have one, for substantially better performance.Testing with a ~300MB (compressed size) 7-zip file, I noticed an improvement in decompression speed from ~32 seconds to ~27 seconds and a reduction in memory allocations from ~7GB to ~100MB.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.