Repository navigation
Reduce binary logger serialization overhead - #14929
Merged
baronfel merged 6 commits intoSep 15, 2026
Merged
Conversation
Reuse serialized metadata records for items that share immutable copy-on-write metadata, while preserving fallback and AppDomain behavior. Co-authored-by: Copilot <[email protected]> Copilot-Session: f5f373de-cc23-46fa-bd6f-9ba8c1645411
AlesProkop
temporarily deployed
to
copilot-pat-pool
September 4, 2026 08:38 — with
GitHub Actions
Inactive
AlesProkop
temporarily deployed
to
copilot-pat-pool
September 4, 2026 08:39 — with
GitHub Actions
Inactive
AlesProkop
temporarily deployed
to
copilot-pat-pool
September 4, 2026 08:40 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The optimization is localized, preserves the existing on-wire encoding, and is covered by targeted tests including byte-for-byte equivalence checks.
Pull request overview
This PR optimizes binary logger serialization of task item metadata by memoizing previously-emitted NameValueList record IDs for shared copy-on-write immutable metadata dictionaries, reducing repeated enumeration, unescaping, and hashing work in BuildEventArgsWriter.WriteTaskItemList.
Changes:
- Added a
ConditionalWeakTable<ImmutableDictionary<string,string>, StrongBox<int>>cache to reuseNameValueListrecord IDs for items sharing the same immutable backing metadata dictionary. - Introduced a fast path that enumerates immutable backing metadata directly on cache misses while preserving the existing unescape behavior and metadata ordering contract.
- Added focused unit tests covering shared-metadata reuse, empty-metadata short-circuiting,
TaskItemDatafallback behavior, and byte-for-byte equivalence with the legacy path.
File summaries
| File | Description |
|---|---|
| src/Framework/IMetadataContainer.cs | Documents the escaped-value + ordering contract required for BackingMetadata to be safely consumable for serialization fast paths. |
| src/Build/Logging/BinaryLogger/BuildEventArgsWriter.cs | Implements metadata record-id identity caching and updates WriteNameValueList to return the emitted record id for reuse. |
| src/Build.UnitTests/BuildEventArgsSerialization_Tests.cs | Adds regression/compat tests validating reuse, fallbacks, and byte-for-byte serialization equivalence. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot <[email protected]> Copilot-Session: f5f373de-cc23-46fa-bd6f-9ba8c1645411
Co-authored-by: Copilot <[email protected]> Copilot-Session: f5f373de-cc23-46fa-bd6f-9ba8c1645411
Co-authored-by: Copilot <[email protected]> Copilot-Session: f5f373de-cc23-46fa-bd6f-9ba8c1645411
rainersigwald
approved these changes
Sep 11, 2026
Co-authored-by: Rainer Sigwald <[email protected]>
Co-authored-by: Copilot App <[email protected]>
rainersigwald
approved these changes
Sep 14, 2026
baronfel
approved these changes
Sep 15, 2026
This was referenced Sep 15, 2026
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.
Related to #10490
Context
BinaryLogger profiling identified task-item metadata serialization, repeated metadata writer allocation, and repeated string hashing as major contributors to
/bloverhead. This stacks four format-preserving hot-path optimizations that reduce that work without omitting log data.Changes Made
NameValueListrecord IDs for shared immutable task-item metadata.TaskItemDatametadata path that hashes already-materialized metadata directly into string-index records.BinaryWriterassociated with the reusableNameValueListstream.ITaskItemimplementations, transparent proxies, raw replay, empty metadata, escaping, and metadata ordering.BuildEventArgsSerializationTests.Testing
BuildEventArgsSerializationTestsonnet11.0andnet472— passed.src/Samples/Dependency/Dependency.csproj— passed./mt: 94.52 seconds → 85.50 seconds, saving 9.02 seconds / 9.54%.Notes
/bloverhead and 37.3% of the previous/mtoverhead.