Repository navigation
Return raw bytes from ZstandardDictionary.Train - #135424
Conversation
Separate training and persistence from quality-specific dictionary preparation. Synchronize reference and unsupported-platform declarations, update documentation, and migrate the existing training tests. Co-authored-by: Copilot App <[email protected]> Copilot-Session: ca3e02cc-b75c-48c3-97e1-5c22f1ae2c3a
|
Azure Pipelines: Successfully started running 4 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @karelz, @dotnet/area-system-io-compression |
|
Approved by Jeff Schwartz over email to be backported to 11.0 (breaking change doc will be issued) |
|
Added When you commit this breaking change:
Tagging @dotnet/compat for awareness of the breaking change. |
|
/backport to release/11.0 |
|
Started backporting to |
|
@rzikm backporting to |
|
/backport to release/11.0 |
|
Started backporting to |
|
@rzikm backporting to git am output$ git cherry-pick f9b2095b7beb55ba73ec30e660ee6f1987a44546
Auto-merging src/libraries/System.IO.Compression/ref/System.IO.Compression.cs
Auto-merging src/libraries/System.IO.Compression/src/System/IO/Compression/Zstandard/Zstandard.PlatformNotSupported.cs
Auto-merging src/libraries/System.IO.Compression/src/System/IO/Compression/Zstandard/ZstandardDictionary.cs
Auto-merging src/libraries/System.IO.Compression/tests/Zstandard/ZstandardDictionaryTests.cs
CONFLICT (content): Merge conflict in src/libraries/System.IO.Compression/tests/Zstandard/ZstandardDictionaryTests.cs
error: could not apply f9b2095b7be... Return raw bytes from ZstandardDictionary.Train (#135424)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: Return raw bytes from ZstandardDictionary.Train
Using index info to reconstruct a base tree...
M src/libraries/System.IO.Compression/ref/System.IO.Compression.cs
M src/libraries/System.IO.Compression/src/System/IO/Compression/Zstandard/Zstandard.PlatformNotSupported.cs
M src/libraries/System.IO.Compression/src/System/IO/Compression/Zstandard/ZstandardDictionary.cs
M src/libraries/System.IO.Compression/tests/Zstandard/ZstandardDictionaryTests.cs
Falling back to patching base and 3-way merge...
Auto-merging src/libraries/System.IO.Compression/ref/System.IO.Compression.cs
Auto-merging src/libraries/System.IO.Compression/src/System/IO/Compression/Zstandard/Zstandard.PlatformNotSupported.cs
Auto-merging src/libraries/System.IO.Compression/src/System/IO/Compression/Zstandard/ZstandardDictionary.cs
Auto-merging src/libraries/System.IO.Compression/tests/Zstandard/ZstandardDictionaryTests.cs
CONFLICT (content): Merge conflict in src/libraries/System.IO.Compression/tests/Zstandard/ZstandardDictionaryTests.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Return raw bytes from ZstandardDictionary.Train
Error: The process '/usr/bin/git' failed with exit code 128 |
main PR #135424 # Description `Train` currently returns a dictionary prepared at the default quality, which can override the quality requested by callers. Return raw dictionary bytes so callers can prepare the dictionary for their chosen quality. - Update the reference API, browser/WASI stubs, documentation, and existing training test. - Example: ```csharp byte[] data = ZstandardDictionary.Train(samples, sampleLengths, maxDictionarySize); using ZstandardDictionary dictionary = ZstandardDictionary.Create(data, quality: 19); ``` # Customer Impact Without this change, `Train`-produced dictionaries can prevent callers’ requested compression quality from taking effect. # Regression No. `ZstandardDictionary` is new in .NET 11. # Testing — # Risk This is a breaking public API return-type change. The API shape is approved; breaking-change documentation remains tracked. # Package authoring no longer needed in .NET 9 IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version. Keep in mind that we still need package authoring in .NET 8 and older versions. Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: rzikm <[email protected]>
ZstandardDictionary.Traincurrently prepares its result at the default compression quality of 3. That prepared dictionary overrides encoder quality, so callers wanting another quality must extractDataand prepare it again.Return caller-owned dictionary bytes instead, separating offline training/persistence from quality-specific preparation:
Training validation, the small-sample safety guard, and pooled-buffer cleanup are unchanged. Reference and browser/WASI declarations, documentation, and existing training tests are updated. No new tests remain, and no benchmarks were run.
API review: This is a draft prototype of a source/binary breaking return-type change. It requires API and breaking-change approval before merge; the original approval in #59591 specifies the old
ZstandardDictionaryreturn type. Prepared dictionaries still take precedence over encoder quality.Validation (Windows x64, built through a
substshortcut):dotnet build src\libraries\System.IO.Compression\src\System.IO.Compression.csproj -c Release- passed for all implementation target frameworks with normal ApiCompat validation.dotnet build src\libraries\System.IO.Compression\tests\System.IO.Compression.Tests.csproj -c Release /t:Test- passed: 2,999 normal cases, zero failures/skips. The focused existing dictionary cases also passed, 17/17.Fixes: #135265
Resolves #135265
Note
This pull request was prepared with GitHub Copilot.