Skip to content

Let the editor answer reference timestamps for the incremental builder - #20761

Merged
T-Gro merged 5 commits into
dotnet:mainfrom
xperiandri:perf/reference-stamp-provider
Oct 20, 2026
Merged

T-Gro merged 5 commits into
dotnet:mainfrom
xperiandri:perf/reference-stamp-provider

Conversation

@xperiandri

Copy link
Copy Markdown
Contributor

With the background compiler, every request re-reads the last-write time of each non-framework reference of the project to decide whether its imports are stale. FSharpChecker.SetReferenceStampProvider (internal) lets a host that already watches those files answer instead.

Details
  • The provider is asked both when a builder is created and when it checks for staleness, so a host view that lags the disk cannot recreate a builder on every request.
  • Project references keep their in-memory logical stamps. A checker nobody gave a provider stats as before.
  • Internal, so no surface-area change. Visual Studio will set it from the tracker in Cache reference timestamps behind an IVsAsyncFileChangeEx2 watcher for snapshot reuse #20457 once both are in.

🤖 Generated with Claude Code

@xperiandri
xperiandri requested a review from a team as a code owner October 11, 2026 09:53
Copilot AI balanced review requested due to automatic review settings October 11, 2026 09:53
@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ Release-note check exempted

The NO_RELEASE_NOTES label or localization-bot authorship exempts this pull request.

xperiandri added a commit to xperiandri/fsharp that referenced this pull request Oct 11, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new optional callback representation conflicts with the compiler’s required voption convention and needs a thread-safe multi-file adjustment.

1 open finding
What changed in this PR

Adds an internal host-provided reference timestamp source to reduce repeated filesystem access during incremental checking.

Changes:

  • Routes the provider through FSharpChecker and background compilers.
  • Uses host stamps for non-framework references while preserving project-reference stamps.
  • Adds integration tests and release notes.
File Description
ReferenceStampProviderTests.fs Tests provider behavior and invalidation.
FSharp.Compiler.Service.Tests.fsproj Includes the new tests.
TransparentCompiler.fs Forwards provider configuration.
service.fsi Declares and documents the internal API.
service.fs Exposes the checker method.
IncrementalBuild.fsi Extends builder creation parameters.
IncrementalBuild.fs Applies host-provided reference stamps.
BackgroundCompiler.fsi Declares provider plumbing.
BackgroundCompiler.fs Stores and forwards the provider.
11.0.200.md Documents the addition.

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Compiler/Service/BackgroundCompiler.fs

@T-Gro T-Gro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 🕵️ LGTM

@github-project-automation github-project-automation Bot moved this from New to In Progress in F# Compiler and Tooling Oct 12, 2026
@T-Gro T-Gro added the AI-reviewed PR reviewed by AI review council label Oct 12, 2026
@T-Gro
T-Gro self-requested a review October 12, 2026 08:44

@T-Gro T-Gro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff is still way too big - apply the NoBloat instructions and CodeCompaction skill.

Especially the massive code comments would benefit not just with drastic reduction, but ideally with well named functions/arguments/bindings/types making the intention clear.

If a well named piece of code just tells what the comment says - delete the comment.

  • Excluding 7 public API documentation lines, this diff still adds 16 implementation and test comment lines and 1513 comment chars.
  • Comments bypass the type system and become stale maintenance state. Keep only durable public contracts; express implementation intent through names, functions, active patterns, discriminated unions, and types.

@T-Gro T-Gro added the NO_RELEASE_NOTES Label for pull requests which signals, that user opted-out of providing release notes label Oct 14, 2026
xperiandri and others added 3 commits October 15, 2026 01:27
The incremental builder decides whether a project's imports are stale by stat'ing every
non-framework reference on every request: IsReferencesInvalidated runs per getOrCreateBuilder
with a fresh TimeStampCache. A host that already watches those files can now answer instead.
FSharpChecker.SetReferenceStampProvider - internal, for the editor - hands builders a
`string -> DateTime` they use both when they are created and when they check for staleness,
so the two never disagree and a host view that lags the disk cannot recreate a builder on
every request. Project references keep their logical stamps, and a checker nobody gave a
provider stats as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The parameter is a new optional value, so it is a voption like the other optional values of
this compiler. The host's field keeps the option it had: the host's thread writes it and any
thread that creates a builder reads it, without a lock, which a single-reference option
carries and a struct does not. It is converted once, where the builder is created.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@xperiandri
xperiandri force-pushed the perf/reference-stamp-provider branch from 849a136 to f4a9961 Compare October 15, 2026 00:47
xperiandri and others added 2 commits October 18, 2026 03:12
The setter's doc states what a host must provide. The notes on the option
field, on the shared stamper and on the steps of each test go, as does the
release note of an internal API.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@xperiandri

Copy link
Copy Markdown
Contributor Author

Addressed the NoBloat / CodeCompaction review in 6d4d94eb79 (plus a merge of main before it, no rebase):

  • The change now adds 3 comment lines, down from 23: the two-line doc of SetReferenceStampProvider, which states what a host has to provide, and the license header of the new test file. The doc on the IBackgroundCompiler member, the notes on the option field and on the stamper, and the narration inside the tests are gone. The stamper is one binding, stampReferencedAssembly, used both when the builder is created and when it checks for staleness, which is what the removed note said.
  • The four tests keep their behavior-named titles and share withFixture, recording and legacyChecker for setup.
  • The release note is removed: the API is internal and the PR carries NO_RELEASE_NOTES.

ReferenceStampProviderTests, SurfaceAreaTest, IncrementalBuilderRaceTests and MultiProjectAnalysisTests pass (19 tests).

@T-Gro T-Gro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖🕵️ LGTM ✅

Dimensions covered (expand)
  • Delta scope, feedback resolution, and pinned-map exclusions (Grok 4.7 High)

xperiandri added a commit to xperiandri/fsharp that referenced this pull request Oct 19, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
xperiandri added a commit to xperiandri/fsharp that referenced this pull request Oct 19, 2026
…al builder

Integration only: on the PR branches this waits for dotnet#20459 and dotnet#20761 to merge.

A snapshot built from scratch takes its `-r:` stamps from the tracker through
FromOptionsWithReferenceStamps, and the checker is given the tracker as its reference stamp
provider, so the incremental builder no longer stats every non-framework reference on every
request. With that the stamps have readers in every configuration, so references are watched
whether or not the transparent compiler and snapshot reuse are on, and the test of that
condition goes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
xperiandri added a commit to xperiandri/fsharp that referenced this pull request Oct 19, 2026
The cherry-pick kept the unlinked copy of the bullet beside the linked one
(release notes merge with merge=union). Drop the unlinked copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
xperiandri added a commit to xperiandri/fsharp that referenced this pull request Oct 19, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
xperiandri added a commit to xperiandri/fsharp that referenced this pull request Oct 19, 2026
…al builder

Integration only: on the PR branches this waits for dotnet#20459 and dotnet#20761 to merge.

A snapshot built from scratch takes its `-r:` stamps from the tracker through
FromOptionsWithReferenceStamps, and the checker is given the tracker as its reference stamp
provider, so the incremental builder no longer stats every non-framework reference on every
request. With that the stamps have readers in every configuration, so references are watched
whether or not the transparent compiler and snapshot reuse are on, and the test of that
condition goes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
xperiandri added a commit to xperiandri/fsharp that referenced this pull request Oct 19, 2026
The cherry-pick kept the unlinked copy of the bullet beside the linked one
(release notes merge with merge=union). Drop the unlinked copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@T-Gro
T-Gro merged commit 1d10808 into dotnet:main Oct 20, 2026
55 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in F# Compiler and Tooling Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-reviewed PR reviewed by AI review council NO_RELEASE_NOTES Label for pull requests which signals, that user opted-out of providing release notes

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants