Repository navigation
Pool Deflater instances to reuse native compression state - #134790
Closed
alinpahontu2912 with Copilot wants to merge 4 commits into
Closed
alinpahontu2912 with Copilot wants to merge 4 commits into
alinpahontu2912 with Copilot wants to merge 4 commits into
Conversation
|
Azure Pipelines: 16 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @karelz, @dotnet/area-system-io-compression |
Co-authored-by: alinpahontu2912 <56953855+alinpahontu2912@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix DeflateStream page-fault regression by pooling Deflater instances
Pool Deflater instances to reuse native compression state
Sep 28, 2026
Co-authored-by: alinpahontu2912 <56953855+alinpahontu2912@users.noreply.github.com>
Retain deterministic ownership checks while exercising concurrent rentals and returns. Ensure batch-owned streams are disposed when assertions or writes fail. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d488efd3-0804-456f-9286-2129a5cf5c6e
This was referenced Sep 29, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Short-lived compressors repeatedly allocate and free large native deflate state. This change adds a bounded pool of native compression states, reusing matching states through the existing native reset operation.
Validation
Local Windows x64 Release build completed with zero warnings and errors. All 7 focused pool tests, 2,659 default System.IO.Compression tests, and 367 default System.IO.Compression.ZipFile tests passed. Default suites exclude OuterLoop and failing categories. Other platforms were not exercised locally.
Performance and accepted tradeoff
The local reproduction uses the seeded 5,000-byte, half-random input from #134700. Baseline Deflater source from 084d619 and the revised implementation were built and run in separate private CoreRun hosts with the same runtime and native library; the hosts differed only in System.IO.Compression.dll. These are patch-before/after measurements, not a direct .NET 8 versus .NET 10 comparison.
Warm runs used 2,000 warm-up operations followed by 20,000 measured operations. Median elapsed time across three repetitions:
Process page faults per operation fell from 9.394 to 0.033 at DOP 8 and from 11.329 to 0.046 at DOP 12. Native allocation/reset call counts were not instrumented.
Known limitation: a synthetic workload cycling 12 configurations (four compression levels across Deflate, GZip, and ZLib) exceeds the eight-slot working set. At DOP 4, five additional paired runs confirmed median warm elapsed time increased from 258.3 ms to 332.1 ms, a 28.5% slowdown. Pooling is not a universal throughput improvement.
A 16-slot candidate reduced the synthetic churn but gave no consistent additional benefit for the original fixed-configuration workload, doubled the estimated idle native-memory budget to 5.2 MiB, and did not eliminate over-capacity slowdowns. Retain eight slots and accept this documented limitation rather than add adaptive admission, per-key pools, trimming, or more synchronization machinery. These local measurements are workload-specific, not universal performance guarantees.
Resolves #134788
Note
This description and the follow-up test improvements were prepared with GitHub Copilot.