Skip to content

Transparent Compiler: fix DependencyGraph cache never finding cached graphs - #20930

Open
DedSec256 wants to merge 2 commits into
dotnet:mainfrom
DedSec256:ber.a/fixDependenciesCache
Open

DedSec256 wants to merge 2 commits into
dotnet:mainfrom
DedSec256:ber.a/fixDependenciesCache

Conversation

@DedSec256

Copy link
Copy Markdown
Contributor

The DependencyGraph cache of the TransparentCompiler never found a cached graph: every request built the graph again, even for the same files at the same versions.

The cache key, built by Extensions.Key in TransparentCompiler.fs, was a tuple of the graph type and the MD5 hash of the file names as a byte[]. LruCache keeps its keys in a Dictionary with the default .NET comparer. For a tuple, that comparer compares an array by reference, and GetKey() creates a new array on every call, so no two keys were ever equal. As a result:

  • the graph was built again on every request. Building it means running FileContentMapping.mkFileContent and DependencyResolution.mkGraph over every file in the set. For example, semantic classification or find references on a file that was just checked rebuilt the graph that the check had built;
  • every request added a new cache entry. Up to 100 graphs were held strongly and 200 weakly, and none of them could ever be found.

This PR keeps the hash in the key as a string, which the default comparer compares by value. The version of the key was already a string.

The new test Dependency graph of the same files is taken from the cache checks a file, requests its semantic classification and asserts that the graph is only requested, not built again. Without the fix it gets [Requested; Started; Finished].

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

✅ Release notes checked


✅ Found changes and release notes in following paths:

Change path Release notes path Description
`src/Compiler` docs/release-notes/.FSharp.Compiler.Service/11.0.200.md

@DedSec256
DedSec256 force-pushed the ber.a/fixDependenciesCache branch from 928454a to d09b035 Compare November 4, 2026 21:47
@DedSec256 DedSec256 closed this Nov 5, 2026
@DedSec256 DedSec256 reopened this Nov 5, 2026

This branch has not been deployed

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

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant