compression: support zstd with skippable frame#42862
Conversation
|
Left a quick thought above. Also, would it be possible to amend the commit message to use your (quite informative) PR description in the commit message itself? |
ee5e675 to
d6ba284
Compare
Sure. |
d8f3cde to
e155411
Compare
|
@tonistiigi PTAL (perhaps we need a test image for this as well) |
|
@dkkb - looking at this with @tonistiigi and he pointed out that Lines 178 to 182 in 6014c1e So, the test in the PR passes, but detection may not work as expected when used by |
e155411 to
eb0eb4e
Compare
To avoid misidentifying Zstd, I use an ordered list to detect the compression algorithm for compatibility and performance so that we can quickly identify the skippable frame and remove the unnecessary code. |
@tonistiigi could you have a look? |
As a matter of fact, there are two frame formats defined by Zstandard: Zstandard frames and Skippable frames. So we should probably support zstd algorithms with skippable frames. See https://tools.ietf.org/id/draft-kucherawy-dispatch-zstd-00.html#rfc.section.2 for more details. Signed-off-by: Da McGrady <dabkb@aol.com>
eb0eb4e to
23abee4
Compare
|
@klauspost @giuseppe sgty? If accepted we need the same change in containerd & buildkit as all of them only check single magic atm. |
|
Thank you! |
|
@dkkb Could you make the same update in containerd and buildkit repos? |
Sure. |
Signed-off-by: Da McGrady dabkb@aol.com
- What I did
As a matter of fact, there are two frame formats defined by Zstandard: Zstandard frames and Skippable frames.
So we should probably support zstd algorithms with skippable frames.
See https://tools.ietf.org/id/draft-kucherawy-dispatch-zstd-00.html#rfc.section.2 for more details.
The structure of a single Zstandard frame is as follows, the magic number of Zstandard frame is 0xFD2FB528.
Skippable frames allow the insertion of user-defined data into a flow of concatenated frames. Its design is pretty straightforward, with the sole objective to allow the decoder to quickly skip over user-defined data and continue decoding.
Magic_Number: 0x184D2A5?, which means any value from 0x184D2A50 to 0x184D2A5F.
Frame_Size: This is the size
nof the following UserData, 4 bytes, little-endian format, unsigned 32-bits.- How I did it
In order to accommodate more complicated detectors for Zstd, I changed the
DetectCompressionfunction.- How to verify it
To verify this PR, I created a new test named
TestDetectCompression.- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)
