Revert "Remove custom allocator."#117949
Conversation
This reverts commit c62bc5b.
There was a problem hiding this comment.
Pull Request Overview
This PR reverts the removal of the custom allocator for zlib to address performance regression in .NET 9.0. A partner reported poor performance caused by native heap fragmentation when using the standard process heap for zlib allocations.
- Reintroduces custom allocator implementation with defense-in-depth security features
- Adds platform-specific allocator implementations for Windows and Unix systems
- Integrates custom allocator into zlib initialization
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| zlib_allocator_win.c | Windows-specific custom allocator with separate heap and security cookies |
| zlib_allocator_unix.c | Unix-specific custom allocator using malloc/calloc with security validation |
| zlib_allocator.h | Header file declaring the custom allocator function signatures |
| pal_zlib.c | Integration point to use custom allocator in zlib stream initialization |
| CMakeLists.txt | Build configuration to include platform-appropriate allocator source file |
src/native/libs/System.IO.Compression.Native/zlib_allocator_win.c
Outdated
Show resolved
Hide resolved
src/native/libs/System.IO.Compression.Native/zlib_allocator_win.c
Outdated
Show resolved
Hide resolved
|
Tagging subscribers to this area: @dotnet/area-system-io-compression |
src/native/libs/System.IO.Compression.Native/zlib_allocator_win.c
Outdated
Show resolved
Hide resolved
src/native/libs/System.IO.Compression.Native/zlib_allocator_win.c
Outdated
Show resolved
Hide resolved
src/native/libs/System.IO.Compression.Native/zlib_allocator_win.c
Outdated
Show resolved
Hide resolved
|
Performance results from this change compared to other iterations. Here
|
src/native/libs/System.IO.Compression.Native/zlib_allocator_win.c
Outdated
Show resolved
Hide resolved
|
/backport to release/9.0-staging |
|
Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/16680374285 |
This reverts commit c62bc5b.
We had reports from a partner that they were seeing poor performance from .NET 9.0 that pointed to heap allocation in zlib.
This was caused by native heap fragmentation. We tested the partner's service with a fix that added back the zlib custom allocator and it resolved the issue. We shipped 9.0 preview 7 and RC1 with the allocator, it was removed in RC2. This is a clean revert of the commit that removed the allocator.
We intend to ask for this fix for servicing in .NET 9.0 once it's in.