You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
F# compiler is really slow when trying to compile .net8.0 project with SDK 8.0.303 #17501
So, the bad news is that I can't reproduce it on my mac, on both net7.0 and net8.0 as targets, compilation takes about a minute (47-55 seconds) on my machine (M2 macbook). net6.0 in main with the same SDK (8.0.100) takes about 4 seconds, which leads me to believe that it is the same sort of issue as described in fsprojects/Fleece#146.
TL;DR of the issue is: around .NET7 BCL rolled out "Static abstracts in interfaces" feature (which led to much bigger interfaces hirearchy), at the same time we rolled out support for static abstracts as well as some changes to SRTPs. And what I think is happening is that once you introduce new BCL, some of the functionality in your tests is making typechecking go brrr, and performance degrades significantly, see discussion in the issue above, as well as Don's comment in fsharp/fslang-design@71cd2e0.
Conclusion: with all this in mind, the the best current course of action (for us or contributors) would be to:
Take current compiler from main.
Build it (Release).
Create a global.json file pointing to latest .NET9 SDK (preview 6 at the moment of me commenting it).
Include it in the project from OP (tests project, from master branch, point to custom compiler via UseLocalCompiler.Directory.Build.props importing).
Profile it with net6.0 (default) target.
Change target to net8.0 (or switch branch to otk5-add-matrx-simd-equal, bba4019df27b0a54ff48ca2205d681dbe990824b at the moment of me commenting it).
Include custom compiler there again. Profile it again.
See what's different/what's wrong.
Try to make it better.
As a temporary workaround(s), there were some comments from @gusty in the original issue in Fleece, which might help.
The worst part is that the more people will move to net8.0 as TFM, the more people might hit this issue. I will try to collect some profiles once I have some free time, unless someone will beat me to it.
changed the title [-]F# compiler hangs when trying to compile .net8.0 project with SDK 8.0.303[/-][+]F# compiler is really slow when trying to compile .net8.0 project with SDK 8.0.303[/+]on Aug 8, 2024
@T-Gro you should talk to Jared about his complog tool. I think Roslyn uses it in part to make it easy to extract out these kind of calls into something that can be independently tested across versions.
Using <LangVersion>preview</LangVersion> does indeed help compile times, though it does still take around a minute to compile the project. That's down from a 17 minute build, so it definitely helps, thanks.
Given that the preview exists, I'll redo #18225 and get some timings of builds with netstandard2.0, dotnet9 without language preview, and dotnet9 with language preview.
Hopefully it works and then we can push to get this out of LangPreview and also into IDEs!
I'm coming back to this issue again and again. IntelliSense is unusably slow, it takes multiple minutes to get error messages and even syntax highlighting is broken. I guess this is also possibly related to (or made worse by) #18807 as we are also using xUnit in this project.
Compiling from command line does seem to alleviate the issue, but it doesn't help IDE performance...
The issues I'm describing are experienced on the opentk5.0 branch. https://github.com/opentk/opentk/tree/opentk5.0
The current master branch uses net6.0 and isn't affected by this problem.
The issues I'm describing are experienced on the opentk5.0 branch. https://github.com/opentk/opentk/tree/opentk5.0 The current master branch uses net6.0 and isn't affected by this problem.
What's the VS version? The initial fix was only affecting compiler, not IDE. VS fix went in much later, May 1st (#18499), and was merged in VS even later, June 16th (#18691).
I have suspicion this didn't end up in 17.14? @T-Gro
How does the compilation fix get out of preview and can that be done asap? F# compiling slowly with modern dotnet is an urgent problem and I heard teams are rushing things in now for dotnet10. @vzarytovskii@T-Gro
How does the compilation fix get out of preview and can that be done asap? F# compiling slowly with modern dotnet is an urgent problem and I heard teams are rushing things in now for dotnet10. @vzarytovskii@T-Gro
Usually it has to be bumped to specific language version (or removed from under the flag in general) once it's close to release, not sure if the window is closed already for NET10 or if it was moved from under the preview already. It's a question to @T-Gro
Activity
vzarytovskii commentedon Aug 7, 2024
So, the bad news is that I can't reproduce it on my mac, on both
net7.0andnet8.0as targets, compilation takes about a minute (47-55 seconds) on my machine (M2 macbook).net6.0inmainwith the same SDK (8.0.100) takes about 4 seconds, which leads me to believe that it is the same sort of issue as described in fsprojects/Fleece#146.TL;DR of the issue is: around .NET7 BCL rolled out "Static abstracts in interfaces" feature (which led to much bigger interfaces hirearchy), at the same time we rolled out support for static abstracts as well as some changes to SRTPs. And what I think is happening is that once you introduce new BCL, some of the functionality in your tests is making typechecking go brrr, and performance degrades significantly, see discussion in the issue above, as well as Don's comment in fsharp/fslang-design@71cd2e0.
Conclusion: with all this in mind, the the best current course of action (for us or contributors) would be to:
main.global.jsonfile pointing to latest.NET9SDK (preview 6 at the moment of me commenting it).masterbranch, point to custom compiler viaUseLocalCompiler.Directory.Build.propsimporting).net6.0(default) target.net8.0(or switch branch tootk5-add-matrx-simd-equal,bba4019df27b0a54ff48ca2205d681dbe990824bat the moment of me commenting it).As a temporary workaround(s), there were some comments from @gusty in the original issue in Fleece, which might help.
vzarytovskii commentedon Aug 7, 2024
The worst part is that the more people will move to
net8.0as TFM, the more people might hit this issue. I will try to collect some profiles once I have some free time, unless someone will beat me to it.vzarytovskii commentedon Aug 7, 2024
Profiles for
masterbranch with tests project upgraded tonet6.0:net6.zip
otk5-add-matrx-simd-equalbranch built with no changes (net8.0):net8.zip
Running via .NET9p6 runtime host, with net8 SDK assemblies, on latest
mainof compiler.In case if someone wants to look at it.
vzarytovskii commentedon Aug 7, 2024
Compiler spent a minute (out of ~2 under profiling) in just getting interfaces for all types:

Additionally, some type directed conversions are involved:

(I presume, when we try to find conversions we need to traverse all interfaces)
vzarytovskii commentedon Aug 7, 2024
I will experiment with caching stuff more once I'm off of work.
[-]F# compiler hangs when trying to compile .net8.0 project with SDK 8.0.303[/-][+]F# compiler is really slow when trying to compile .net8.0 project with SDK 8.0.303[/+]25 remaining items
baronfel commentedon Apr 7, 2025
@T-Gro you should talk to Jared about his complog tool. I think Roslyn uses it in part to make it easy to extract out these kind of calls into something that can be independently tested across versions.
haraldsteinlechner commentedon Apr 7, 2025
@T-Gro thanks for clarification and the great work. Yes i will set something up!
NogginBops commentedon Jul 5, 2025
Is this still not fixed for the .net8 or .net9 sdk?
I still have multi-minute builds and it's very bad...
majocha commentedon Jul 6, 2025
Hi @NogginBops, the fix is currently enabled only under language version preview.
Please try setting
in your projects.
NogginBops commentedon Jul 6, 2025
Using
<LangVersion>preview</LangVersion>does indeed help compile times, though it does still take around a minute to compile the project. That's down from a 17 minute build, so it definitely helps, thanks.Try to improve F# test compile times by using the preview language ve…
charlesroddie commentedon Jul 11, 2025
Given that the preview exists, I'll redo #18225 and get some timings of builds with netstandard2.0, dotnet9 without language preview, and dotnet9 with language preview.
Hopefully it works and then we can push to get this out of LangPreview and also into IDEs!
NogginBops commentedon Aug 25, 2025
I'm coming back to this issue again and again. IntelliSense is unusably slow, it takes multiple minutes to get error messages and even syntax highlighting is broken. I guess this is also possibly related to (or made worse by) #18807 as we are also using xUnit in this project.
Compiling from command line does seem to alleviate the issue, but it doesn't help IDE performance...
majocha commentedon Aug 25, 2025
@NogginBops I think the changes to caching to make this faster are already in. At least in VS preview.
Edit: NOPE.
NogginBops commentedon Aug 26, 2025
The issues I'm describing are experienced on the
opentk5.0branch.https://github.com/opentk/opentk/tree/opentk5.0
The current master branch uses
net6.0and isn't affected by this problem.Here is a video showing what I'm experiencing:
https://github.com/user-attachments/assets/10fa70e2-c7cc-4aed-8dd5-8e84d74a2624
vzarytovskii commentedon Aug 26, 2025
What's the VS version? The initial fix was only affecting compiler, not IDE. VS fix went in much later, May 1st (#18499), and was merged in VS even later, June 16th (#18691).
I have suspicion this didn't end up in 17.14? @T-Gro
majocha commentedon Aug 26, 2025
Right! I forgot.
Unfortunately, I can confirm the fix is not in most recent 17.14.
charlesroddie commentedon Sep 15, 2025
How does the compilation fix get out of preview and can that be done asap? F# compiling slowly with modern dotnet is an urgent problem and I heard teams are rushing things in now for dotnet10. @vzarytovskii @T-Gro
vzarytovskii commentedon Sep 15, 2025
Usually it has to be bumped to specific language version (or removed from under the flag in general) once it's close to release, not sure if the window is closed already for NET10 or if it was moved from under the preview already. It's a question to @T-Gro
Update:
fsharp/src/Compiler/Facilities/LanguageFeatures.fs
Line 231 in 8f6bf85
It already is 10
T-Gro commentedon Sep 15, 2025
It is in for .NET 10.
Specifically, if you use the preview VS2026 + .NET10rc1, you should see the improvement 👍