Skip to content

Build the cref resolver only when a doc comment has a cref - #1557

Merged
nojaf merged 4 commits into
ionide:mainfrom
nojaf:t3code/reviewer-mode-prototype
Oct 10, 2026
Merged

nojaf merged 4 commits into
ionide:mainfrom
nojaf:t3code/reviewer-mode-prototype

Conversation

@nojaf

@nojaf nojaf commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Three fixes that came out of measuring FSAC's memory on the Fantomas solution with the transparent compiler. One commit each. CHANGELOG.md gets a 0.85.1 section, so merging this publishes 0.85.1.

Changes

  • Build the cref resolver only when a doc comment has a cref (ParseAndCheckResults.fs). Hover asked for the resolver on every tooltip, and building it lists every entity of every referenced assembly. Now it is built on the first cref it resolves. This came in with Resolve cref links in hover and documentation #1527, so 0.85.0 has it.
  • Skip files without the symbol's name in Find References (AdaptiveServerState.fs, String.containsIdentifier in Utils.fs). FCS 43.12 imports all references of a project before it parses a file of it, also when the file then fails FCS's own identifier test. FSAC now checks the text of the file for the name as a whole identifier first. FCS takes its identifiers from the tokens of the file, so this skips no file FCS would search. Transparent compiler only: the background compiler path searches without an identifier test, so the filter could change its results.
  • Make DisableInMemoryProjectReferences work again (ProjectWorkspace.fs, AdaptiveServerState.fs). It has done nothing since Remove older impls #1174. With the setting on, a referenced F# project comes from its output DLL, for both compilers, and Find References follows MSBuild's project references to find dependent projects. The unused FSharpCompilerServiceChecker.DisableInMemoryProjectReferences property is removed. The setting stays off by default: a DLL does not show changes made since the last build.

Results

Fantomas solution, transparent compiler, replaying a reading session: open CodePrinter.fs, hover, navigate, read SyntaxOak.fs, then Find References on SyntaxOak.Expr.

Before After
Memory at the end of the session 1,170 MB 770 MB
Memory added by the first hover 65 MB 1 MB
Memory added by Find References 480 MB 215 MB
First hover 1.1 s 50 ms
Find References 3.0 s 1.5 s

Averages of four runs before and three after; runs differ by up to 40 MB. Find References returns the same 672 references in 9 files before and after, and with DisableInMemoryProjectReferences on.

Tests

  • CoreUtilsTests.fs: String.containsIdentifier (whole identifiers, 'a, backticks, operators).
  • SnapshotTests.fs: with the setting on, Console1 references Library1.dll as a PE reference.
  • Full suite, net10.0, both compilers: 5,863 passed, 0 failed.

Related

nojaf added 4 commits October 10, 2026 17:35
Hover asks for the cref resolver on every tooltip, and GetCrefResolver
built it right away. Building it lists every entity of every assembly
the project references, so the first hover in a project paid for that
list, also when the doc comment had no cref to resolve. The resolver is
now built when the first cref is resolved.

On the Fantomas solution with the transparent compiler, the first hover
in CodePrinter.fs took 50 ms instead of 1.1 to 1.2 s, and the server
grew by 1 MB instead of 47 to 72 MB.
With a project snapshot, FCS parses each file it is asked to search and
only looks further when the identifiers of the file contain the name of
the symbol, or the name of the attribute without its suffix. But FCS
43.12 imports all references of the project before it parses a file of
it. So Find References imported the references of every project that
depends on the declaring project, also of projects that have no file
with the name.

FSAC now looks for these names in the text of the file first, as whole
identifiers (`Expr` is not in `Expression`), and does not ask FCS when
they are not there. FCS takes its identifiers from the tokens of the
file, so every identifier it finds is in the text: this skips no file
that FCS would search. Only the transparent compiler path does this. The
background compiler searches files without the identifier test, so the
same filter could change its results.

On the Fantomas solution, Find References on SyntaxOak.Expr found the
same 672 references in 9 files. It took 1.5 to 1.6 s instead of 2.7 to
3.3 s, and the server grew by 199 to 227 MB instead of 460 to 502 MB.
The setting has done nothing since the older server implementations
were removed (ionide#1174): nothing set the checker property it used to set,
and nothing read that property. With the setting on, a referenced F#
project now comes from its output DLL, for both compilers. With the
transparent compiler, the snapshot gets a PE reference to the DLL. With
the background compiler, the options have no referenced projects, so FCS
reads the DLL from the command line, as before ionide#1174. The unused checker
property is removed.

Find References finds the projects that depend on the declaring project
through the referenced projects of the snapshots or options. With the
setting on, a DLL reference names no project, so it now also follows
the project references that MSBuild reports.

On the Fantomas solution with the setting on, Find References on
SyntaxOak.Expr found the same 672 references in 9 files.

A DLL reflects the last build of its project, not changes made since,
so the setting stays off by default.
CHANGELOG.md gets the 0.85.1 section, so merging this publishes 0.85.1:
the first hover in a file is fast again, Find References skips files
that do not contain the name, and DisableInMemoryProjectReferences works
again.
@nojaf
nojaf merged commit a47e60e into ionide:main Oct 10, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant