Closed Bug 1947431 Opened 1 year ago Closed 1 year ago

Implement zstd for DecompressionStream

Categories

(Core :: DOM: Streams, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
138 Branch
Tracking Status
firefox138 --- fixed

People

(Reporter: saschanaz, Assigned: nordzilla)

References

Details

Attachments

(4 files, 2 obsolete files)

We want this for internal usage as we already ship zstd. For that purpose having decoding-only is fine. Shipping would be blocked by standards consensus.

See Also: → 1944316
See Also: → 1945670

I think I'd like to take this, so I'm assigning myself.

NOTE: I will be out tomorrow, and Monday is a US holiday, so if someone with higher context gets to this between now and Tuesday, feel free to take over, though my preference would be to finish this out next week.

I looked at this a bit today, and pushed up some WIP patches, more or less a 1:1 mirror of the ZLib version, but using third_party/zstd/lib/zstd.h instead. It's not ready for formal review yet, which is why it is still in WIP, but it is working.


I do have a few questions.

  1. We define CompressionFormat here. If this is only to be supported for decompression for the time being, do I need to make a DecompressionFormat equivalent? Or perhaps just add the enum variant and throw in the CompressionStream if it gets CompressionFormat::Zstd?

  2. How can I ensure that this is supported only internally? Perhaps something like [ChromeOnly]?

  3. Is it okay to modify the web platform tests with these updates if there isn't consensus on standardized adoption yet? If not, where would be the best place to put tests?


Thanks!

Assignee: nobody → enordin
Flags: needinfo?(krosylight)

(In reply to Erik Nordin [:nordzilla] from comment #1)

  1. We define CompressionFormat here. If this is only to be supported for decompression for the time being, do I need to make a DecompressionFormat equivalent? Or perhaps just add the enum variant and throw in the CompressionStream if it gets CompressionFormat::Zstd?

Just add the enum in that list yes.

  1. How can I ensure that this is supported only internally? Perhaps something like [ChromeOnly]?

I'm not sure that we can do [ChromeOnly] on an enum variant. We can throw in the ctor or something. Kagami will know for sure.

  1. Is it okay to modify the web platform tests with these updates if there isn't consensus on standardized adoption yet? If not, where would be the best place to put tests?

https://searchfox.org/mozilla-central/source/testing/web-platform/mozilla/tests is where we put WPTs that aren't quite standard. You can make a temporary copy.

All Paul said. 👍🏻

Flags: needinfo?(krosylight)
Attachment #9466077 - Attachment description: WIP: Bug 1947431 - Implement ZstdDecompressionStreamAlgorithms → WIP: Bug 1947431 - Add "zstd" as a CompressionFormat
Attachment #9466962 - Attachment description: WIP: Bug 1947431 - Experiment With WPTs → WIP: Bug 1947431 - Implement ZstdDecompressionAlgorithms
Attachment #9466076 - Attachment description: WIP: Bug 1947431 - Rename DecompressionStreamAlgorithms → WIP: Bug 1947431 - Rename DecompressionStreamAlgorithms r=saschanaz!
Attachment #9466077 - Attachment description: WIP: Bug 1947431 - Add "zstd" as a CompressionFormat → WIP: Bug 1947431 - Add "zstd" as a CompressionFormat r=saschanaz!
Attachment #9466962 - Attachment description: WIP: Bug 1947431 - Implement ZstdDecompressionAlgorithms → WIP: Bug 1947431 - Implement ZstdDecompressionAlgorithms r=saschanaz!
Attachment #9466076 - Attachment description: WIP: Bug 1947431 - Rename DecompressionStreamAlgorithms r=saschanaz! → Bug 1947431 - Rename DecompressionStreamAlgorithms r=saschanaz!
Attachment #9466077 - Attachment description: WIP: Bug 1947431 - Add "zstd" as a CompressionFormat r=saschanaz! → Bug 1947431 - Add "zstd" as a CompressionFormat r=saschanaz!
Attachment #9466962 - Attachment description: WIP: Bug 1947431 - Implement ZstdDecompressionAlgorithms r=saschanaz! → Bug 1947431 - Implement ZstdDecompressionAlgorithms r=saschanaz!
Attachment #9466077 - Attachment description: Bug 1947431 - Add "zstd" as a CompressionFormat r=saschanaz! → Bug 1947431 - Add "zstd" as a CompressionFormat variant r=saschanaz!
Attachment #9466962 - Attachment description: Bug 1947431 - Implement ZstdDecompressionAlgorithms r=saschanaz! → Bug 1947431 - Implement ZstdDecompressionStreamAlgorithms r=saschanaz!
Attachment #9466962 - Attachment description: Bug 1947431 - Implement ZstdDecompressionStreamAlgorithms r=saschanaz! → Bug 1947431 - Implement ZstdDecompressionAlgorithms r=saschanaz!
Attachment #9466077 - Attachment description: Bug 1947431 - Add "zstd" as a CompressionFormat variant r=saschanaz! → Bug 1947431 - Add "zstd" as a CompressionFormat r=saschanaz!
Attachment #9466962 - Attachment description: Bug 1947431 - Implement ZstdDecompressionAlgorithms r=saschanaz! → Bug 1947431 - Implement ZstdDecompressionAlgorithms r=jesup!,saschanaz!

Renames ZLibHelper.h to be CompressionStreamHelper.h and attempts
to make shared functionality between various implementations of
CompressionStreamAlgorithms and DecompressionStreamAlgorithms as
easily shared as possible.

Introduces a new static pref for the "zstd" format to be used
with CompressionStream and DecompressionStream. Rewrites our
current WPTs to utilize this pref instead of being forced to
construct the stream within a privileged context.

Attachment #9467790 - Attachment description: WIP: Bug 1947431 - Add dom.zstd_compression_streams.enabled static pref r=#saschanaz! → Bug 1947431 - Add dom.zstd_compression_streams.enabled static pref r=saschanaz!
Attachment #9467790 - Attachment is obsolete: true
Attachment #9467790 - Attachment description: Bug 1947431 - Add dom.zstd_compression_streams.enabled static pref r=saschanaz! → Bug 1947431 - Implement ZstdDecompressionAlgorithms r=jesup!,saschanaz!
Attachment #9467790 - Attachment is obsolete: false
Attachment #9467790 - Attachment is obsolete: true

Removes the use of a temporary array from the DecompressionStreamAlgorithms
implementation of DecompressAndEnqueue, instead enqueuing each chunk as they
come rather than collecting all chunks into an array prior to enqueueing.

Attachment #9467808 - Attachment description: WIP: Bug 1947431 - (Tentative) Remove temporary array from DecompressionStreamAlgorithms r=saschanaz! → Bug 1947431 - (Tentative) Remove temporary array from DecompressionStreamAlgorithms r=jesup!,saschanaz!
Attachment #9467808 - Attachment description: Bug 1947431 - (Tentative) Remove temporary array from DecompressionStreamAlgorithms r=jesup!,saschanaz! → Bug 1947431 - (Tentative) Remove temporary array from (De)compressionStreamAlgorithms r=jesup!,saschanaz!
Attachment #9467808 - Attachment is obsolete: true
Pushed by enordin@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/b04b63d5c8ee Rename DecompressionStreamAlgorithms r=saschanaz https://hg.mozilla.org/integration/autoland/rev/43b5795653f1 Add "zstd" as a CompressionFormat r=saschanaz,webidl https://hg.mozilla.org/integration/autoland/rev/1dcbc510621b Implement ZstdDecompressionAlgorithms r=saschanaz,jesup https://hg.mozilla.org/integration/autoland/rev/85df9c1b9761 Refactor ZLibHelper.h r=saschanaz

Unfortunately, there was one spot that I neglected to update within a MOZ_ASSERT(), which only runs in debug builds.

All of the local and try builds that I ran were optimized :(

Queuing for re-landing.

Flags: needinfo?(enordin)
Pushed by enordin@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4d38cd80339c Rename DecompressionStreamAlgorithms r=saschanaz https://hg.mozilla.org/integration/autoland/rev/8e20d3170fb3 Add "zstd" as a CompressionFormat r=saschanaz,webidl https://hg.mozilla.org/integration/autoland/rev/62564a163d7b Implement ZstdDecompressionAlgorithms r=saschanaz,jesup https://hg.mozilla.org/integration/autoland/rev/782b2ffd766b Refactor ZLibHelper.h r=saschanaz

This lead to a 4KB increase in installer size on Windows, which is below any threshold for alerts. Consider this comment as only a FYI.

Thanks Mayank, this is expected for this (important) feature.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: