Skip to content

Reduce strong-fingerprint memory retention - #182

Open
Pawel (92pawelostrowski) wants to merge 2 commits into
microsoft:mainfrom
92pawelostrowski:codex/reduce-fingerprint-memory-retention-v2
Open

Pawel (92pawelostrowski) wants to merge 2 commits into
microsoft:mainfrom
92pawelostrowski:codex/reduce-fingerprint-memory-retention-v2

Conversation

@92pawelostrowski

@92pawelostrowski Pawel (92pawelostrowski) commented Nov 4, 2026 •

Copy link
Copy Markdown

The strong-fingerprint cache holds PathSet objects and expanded fingerprint entries for the factory's lifetime. Use ConditionalWeakTable with lazy tasks so completed entries can be collected and concurrent callers still share a calculation.

Fingerprint hashes and the description-hash cache stay unchanged. Equivalent but separate PathSet objects may now recompute.

Includes regression tests for collection, hash compatibility, concurrency and asynchronous publication. Runtime comparisons use Pawel.MSBuildCacheTesting, a 500-project workload with large strong fingerprints.

Runtime results: #183.

Validation: Release build passed; all 582 unit tests passed (net472 and net9.0).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.
@92pawelostrowski

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="WiseTech Global"

@dfederm

Copy link
Copy Markdown
Member

Based on your results, it looks like performance is regressed, so this change wouldn't be acceptable as-is.

There are likely other low-hanging fruit though for memory usage.

@92pawelostrowski

Copy link
Copy Markdown
Author

Hi David Federman (@dfederm), thanks for taking a look at this.

My initial testing focused on memory. The build-time differences may have been normal fluctuation or other resource usage. I was doing other work on my laptop while those tests were running.

Here is a larger sample: 500-project-results.md.

It contains 48 completed builds across three batches, using 500 projects, 2 and 15 MSBuild workers, and cold and warm caches.

Comparing Local with Official, using arithmetic means across the recorded runs:

  • Average sampled peak private memory: 17.1% lower.
  • Average cold build time: 1.3% less.
  • Average warm build time: 0.7% more.

Memory savings were consistent across batches, ranging from 15.6% to 17.9%. Warm build-time differences went both ways, from 1.6% less to 3.0% more.

I wouldn't jump to the conclusion that there is a build-time regression based on these results. The timing differences vary between batches and could reflect normal fluctuation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants