Repository navigation
Reduce tar extraction overhead and improve async archive creation - #135357
Open
JeremyKuhne wants to merge 2 commits into
Open
JeremyKuhne wants to merge 2 commits into
JeremyKuhne wants to merge 2 commits into
Conversation
Reuse extraction handles and ordinary root resolution, reduce path allocations and tiny-file buffers, and batch owned archive writes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 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: @dotnet/area-system-formats-tar |
Skip descendant link probes for initially empty ordinary destinations until a symbolic-link entry is encountered. Preserve fallback validation and add Unix link, permission, and cancellation guards. Forward cancellation during output flushing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Security-sensitive cross-platform path handling changed substantially, and macOS execution was not validated.
0 open findings
What changed in this PR
Optimizes tar extraction and file-backed archive creation while preserving extraction security and metadata behavior.
Changes:
- Reduces path-resolution calls and per-entry allocations.
- Improves buffering, async flushing, timestamps, and sequential reads.
- Adds cross-platform regression and cancellation coverage.
| File | Description |
|---|---|
TarFile.ExtractToDirectory.Stream.Tests.cs |
Covers empty roots and late links. |
TarFile.ExtractToDirectory.File.Tests.Windows.cs |
Tests Windows reparse-root handling. |
TarFile.ExtractToDirectory.File.Tests.Unix.cs |
Tests Unix links and permissions. |
TarFile.ExtractToDirectory.File.Tests.cs |
Adds root-retargeting test support. |
TarEntry.ExtractToFile.Tests.cs |
Tests cancellation and timestamps. |
TarWriter.Windows.cs |
Adds sequential-read hints. |
TarFile.cs |
Adds output buffering and extraction context. |
TarEntry.Windows.cs |
Optimizes Windows path resolution. |
TarEntry.Unix.cs |
Optimizes Unix path resolution. |
TarEntry.cs |
Reworks containment checks and file extraction. |
System.Formats.Tar.csproj |
Includes required Windows interop sources. |
🧠 Review effort: Balanced
This was referenced Oct 8, 2026
Closed
This branch has not been deployed
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.
Reduce filesystem calls and per-entry allocations during tar extraction, and batch writes during file-backed archive creation. No public API is added.
Changes
Performance
BenchmarkDotNet Release API measurements on Windows 11 / Ryzen 7 9700X, with the same 12.0.0-dev runtime before and after. Windows extraction compares the original implementation with this update; creation measurements cover the unchanged final creation implementation. Paired cells are sync / async. Allocation is cumulative managed memory per archive, not peak memory; negative percentages mean improvement.
Real archives
The workloads extract the .NET 11 RC SDK (~726 MB payload) and Runtime (~87 MB) tar/tar.gz archives, and repack the same trees as uncompressed tar.
SDK tar extraction saves about two seconds per archive: 40-43% less time and 70-74% less allocation. Gzip extraction is approximately 32% faster.
Synthetic workloads
Small contains 32 tiny files, Tiny contains 4,096 256-byte files, Mixed contains 256 files totaling ~17 MiB, and Large contains four 16 MiB files.
Creation benefits are primarily asynchronous. The larger owned output buffer adds 60 KiB per synchronous archive.
Linux SDK tar
Full before/after on WSL2 Ubuntu 26.04 using its native ext4 filesystem: the original implementation before this PR versus the complete current PR, with the same Release 12.0.0-dev runtime and SDK tar archive. Each cell is sync / async, matching the Windows tables.
SDK tar extraction saves 340 ms sync / 305 ms async, with 76-78% less allocation.
Validation and scope
Passed on Windows:
The corresponding
.dotnet/dotnet buildcommands also pass in WSL with Linux paths and the same properties.Related to dotnet/runtime#135128.
Note
This description was generated with GitHub Copilot.