-
Notifications
You must be signed in to change notification settings - Fork 514
Dynamic ring buffer sizing for BZip2 and ZStandard on non-seekable streams #1269
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
Changes from 2 commits
ddcbb3e
ca52cec
97c4ad2
d278cfb
456a7df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,8 @@ | |||||||||||
| using System.Collections.Generic; | ||||||||||||
| using System.IO; | ||||||||||||
| using SharpCompress.Common; | ||||||||||||
| using SharpCompress.Compressors.BZip2; | ||||||||||||
| using SharpCompress.Factories; | ||||||||||||
| using SharpCompress.Readers; | ||||||||||||
| using SharpCompress.Readers.Tar; | ||||||||||||
| using SharpCompress.Test.Mocks; | ||||||||||||
|
|
@@ -58,6 +60,53 @@ public void Tar_Skip() | |||||||||||
| [Fact] | ||||||||||||
| public void Tar_GZip_OldGnu_Reader() => Read("Tar.oldgnu.tar.gz", CompressionType.GZip); | ||||||||||||
|
|
||||||||||||
| [Fact] | ||||||||||||
| public void Tar_BZip2_Reader_NonSeekable() | ||||||||||||
| { | ||||||||||||
| // Regression test for: Dynamic default RingBuffer for BZip2 | ||||||||||||
| // Opening a .tar.bz2 from a non-seekable stream should succeed | ||||||||||||
| // because EnsureMinimumRewindBufferSize expands the ring buffer | ||||||||||||
| // to hold the BZip2 block before calling IsTarFile. | ||||||||||||
|
Comment on lines
+68
to
+69
|
||||||||||||
| // because EnsureMinimumRewindBufferSize expands the ring buffer | |
| // to hold the BZip2 block before calling IsTarFile. | |
| // because the rewind ring buffer is allocated with enough capacity | |
| // up front (e.g. via MaximumRewindBufferSize / StartRecording) to hold | |
| // the BZip2 block before calling IsTarFile. |
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.
@copilot are there more kinds than just BZip2 to worry about? Zstandard?
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.
Only BZip2 needs the enlarged buffer. The other formats all decompress incrementally:
ZSTD_DStreamInSize() ≈ 128 KBand produces output from each chunk before reading more. The default 160 KB ring buffer is larger, so no special treatment is needed.BZip2 is unique in that it must buffer and decode an entire compressed block before producing any output, and at compression level 9 that block can be up to 900 KB of compressed data.