Size template buffers from archive entries - #56193
Merged
JeremyKuhne merged 2 commits intoSep 10, 2026
Merged
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 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
There was a problem hiding this comment.
🟡 Changes recommended
The new ZIP-entry unit test uses a single Stream.Read call assuming it fills the buffer, which is not guaranteed and can cause intermittent failures.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR improves template processing performance by sizing ProcessorState buffers based on known ZIP entry lengths (when available) before opening non-seekable entry streams, while preserving the existing 8 MiB default fallback for unknown/invalid lengths.
Changes:
- Introduces an internal
IKnownLengthFilecontract in TemplateEngine Abstractions and exposes it to Core/Edge (and their unit tests) viaInternalsVisibleTo. - Implements
IKnownLengthFileforZipFileFileso ZIP entry uncompressed length can be queried without opening the entry stream. - Updates
Orchestratorto opportunistically select a smaller processing buffer size whenIKnownLengthFile.Lengthis valid and below the default, and adds focused unit coverage (including ZIP-entry coverage).
File summaries
| File | Description |
|---|---|
| test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/ZipFileFileTests.cs | Adds ZIP-entry length validation coverage for ZipFileFile implementing known-length behavior. |
| test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/OrchestratorTests.cs | Adds unit tests covering buffer-size selection behavior for known/invalid/throwing lengths. |
| src/TemplateEngine/Microsoft.TemplateEngine.Edge/Mount/Archive/ZipFileFile.cs | Implements IKnownLengthFile by exposing ZIP entry uncompressed length. |
| src/TemplateEngine/Microsoft.TemplateEngine.Core/Util/Processor.cs | Makes DefaultBufferSize accessible internally for orchestrator buffer-size decisions. |
| src/TemplateEngine/Microsoft.TemplateEngine.Core/Util/Orchestrator.cs | Uses IKnownLengthFile.Length to choose a smaller buffer size before opening non-seekable streams. |
| src/TemplateEngine/Microsoft.TemplateEngine.Abstractions/Mount/IKnownLengthFile.cs | Adds internal interface for files that can reliably report length. |
| src/TemplateEngine/Microsoft.TemplateEngine.Abstractions/Microsoft.TemplateEngine.Abstractions.csproj | Grants friend access to internals for Core/Edge and their test assemblies. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 1
- Review effort level: Lite
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
joeloff
approved these changes
Sep 10, 2026
JeremyKuhne
had a problem deploying
to
copilot-pat-pool
September 10, 2026 17:32 — with
GitHub Actions
Failure
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.
Summary
Follow-up to #56185 and #56163.
IKnownLengthFileIFile,IProcessorState, andProcessorStateunchangedThe source changes are independent from #56185. Performance was measured on top of its exact head.
Performance
Windows x64 Release ReadyToRun measurements used initialized
dotnet new console --no-restoreoperations.Delta from #56185
The latency comparison used 15 alternating pairs; 11/15 candidate operations were faster with zero semantic mismatches.
Three-PR breakdown
Validation
Microsoft.TemplateEngine.Core.UnitTestsnet11.0andnet481Microsoft.TemplateEngine.Edge.UnitTestsnet11.0andnet481