Skip to content

Let FSharpProjectSnapshot.FromOptions take reference stamps from the host - #20459

Open
xperiandri wants to merge 1 commit into
dotnet:mainfrom
xperiandri:perf/snapshot-reference-stamps
Open

Let FSharpProjectSnapshot.FromOptions take reference stamps from the host#20459
xperiandri wants to merge 1 commit into
dotnet:mainfrom
xperiandri:perf/snapshot-reference-stamps

Conversation

@xperiandri

Copy link
Copy Markdown
Contributor

Description

FSharpProjectSnapshot.FromOptions stats every -r: reference (FileSystem.GetLastWriteTimeShim) each time a snapshot is built from options. Under the transparent compiler in Visual Studio that is the from-scratch path for every new Roslyn Project instance whose options are not reusable — after every options recompute, since FSharpProjectOptions.AreSameForChecking compares only the Stamp — so a project with a few hundred references pays a few hundred stats per typecheck request.

This adds an optional getReferenceStamp: string -> DateTime to FromOptions. A host that already tracks the last-write times of its references (#20457 keeps them behind an IVsAsyncFileChangeEx2 watcher) supplies them; everyone else gets the same FileSystem.GetLastWriteTimeShim as before. The callback is threaded through the recursive call for FSharpReferencedProject.FSharpReference, so referenced projects' snapshots use it too.

No behaviour change for existing callers; the surface-area baseline gains the new optional parameter on the existing overload.

Checklist

  • Test cases added — FSharpChecker/ProjectSnapshot.fs: the stamps of both the project and its referenced F# project come from the callback.
  • Performance benchmarks added in case of performance changes — none; the change removes a stat per reference only when a host opts in, the default path is unchanged.
  • Release notes entry updated — docs/release-notes/.FSharp.Compiler.Service/11.0.100.md.

@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

❗ Release notes required

You can open this PR in browser to add release notes: open in github.dev


✅ Found changes and release notes in following paths:

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

@xperiandri
xperiandri force-pushed the perf/snapshot-reference-stamps branch from 268d203 to c75a5bd Compare September 6, 2026 04:08
@xperiandri xperiandri changed the title Let FSharpProjectSnapshot.FromOptions take reference stamps from the host Let FSharpProjectSnapshot.FromOptions take reference stamps from the host Sep 6, 2026
FSharpProjectSnapshot.FromOptions stats every -r: reference each time a snapshot is built from options; under the transparent compiler in Visual Studio that is every from-scratch snapshot after an options recompute. A host that already tracks the last-write times of its references can pass getReferenceStamp instead; the default stays FileSystem.GetLastWriteTimeShim. The callback is threaded through the recursive call for referenced F# projects.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@xperiandri
xperiandri force-pushed the perf/snapshot-reference-stamps branch from c75a5bd to dab34ee Compare September 6, 2026 04:35
@github-actions github-actions Bot added the AI-Tooling-Check-Scanned-Clean Tooling check: diff analyzed, no interesting infrastructure files label Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-Tooling-Check-Scanned-Clean Tooling check: diff analyzed, no interesting infrastructure files

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

1 participant