Repository navigation
Cache oversized string references in the binary logger - #15524
Conversation
Independent PerfStar binlog experiment based on 3df416b. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the bounded large-string cache change.
No open issues 🎉
What changed in this PR
Adds a bounded cache to MSBuild’s binary logger to avoid repeatedly hashing large strings when the same instance is logged, without changing the serialized format.
Changes:
- Cache up to four large string references, retaining approximately 1 MiB of additional string data per writer.
- Leave strings above 131,072 characters on the existing path.
- Add regression tests for serialized-byte equality, cache eviction, and retention limits.
| File | Description |
|---|---|
src/Build/Logging/BinaryLogger/BuildEventArgsWriter.cs |
Adds the bounded large-string reference cache and reuses cached record IDs and hashes. |
src/Build.UnitTests/BuildEventArgsSerialization_Tests.cs |
Adds byte-equality, eviction round-trip, and retention-budget tests. |
Review effort: Balanced
There was a problem hiding this comment.
LGTM — Test Coverage & Completeness. The tests deterministically cover byte-for-byte serialization invariance, direct-mapped cache eviction/readability, the inclusive upper eligibility boundary, oversized exclusion, four-slot capacity, and the retention budget with strong assertions.
Warning
Firewall blocked 4 domains
The following domains were blocked by the firewall during workflow execution:
api.github.comgithub.compatchdiff.githubusercontent.comraw.githubusercontent.com
[!TIP]
api.github.com is blocked because GitHub API access uses the built-in GitHub tools by default. Instead of adding api.github.com to network.allowed, use tools.github.mode: gh-proxy for direct pre-authenticated GitHub CLI access without requiring network access to api.github.com:
tools:
github:
mode: gh-proxySee GitHub Tools for more information on gh-proxy mode.
To allow these domains, add them to the network.allowed list in your workflow frontmatter:
network:
allowed:
- defaults
- "api.github.com"
- "github.com"
- "patchdiff.githubusercontent.com"
- "raw.githubusercontent.com"See Network Configuration for more information.
Generated by Expert Code Review (on open) for #15524 · copilot · gpt56 · 630.5 AIC · ⌖ 0.521 AIC · ⊞ 21.7K
baronfel
left a comment
There was a problem hiding this comment.
Seems reasonable! A few questions:
- how many such 'large strings' are found in an existing orchardcore build? could/should we tune the cache size based on that?
- how did you choose the large string threshold?
- this only impacts
- overall build time by reducing binlog processing time overall?
- memory use of the msbuild process because N indexes are cached for the lifetime of an eventargs writer?
- this does not impact
- binlog size because we're still writing the same string reference in the binlog?
In the sampled OC logs, the key case was
The lower bound is from an existing small-string cache, and the upper bound is a power of two that keeps approximately 1MiB per writer, so it is more of a reasonable guess.
It affects primarily the binary logger serialization CPU: a cache hit skips rescanning the string for its content hash and resues the hash. Memory can increase a little bit, but it is bounded by the size. And right, there is no size reduction in binlog, because it was already stored and written. This only avoids repeated work finding that same ID. |
Context
The binary logger repeatedly scans large strings even when the same string instance has already been logged. This PR avoids that repeated work.
Changes
Performance
PerfStar: OrchardCore warm incremental MT build with binary logging; medians from five iterations per OS, control run 15979812 versus cache-only run 15982075.
Comparison: Linux · Windows
Preliminary single-pair results: binlog-off medians also drifted (+4.47% Linux, +8.30% Windows), so these do not establish a general speedup; Windows is inconclusive.
Testing