-
Notifications
You must be signed in to change notification settings - Fork 832
Closed
Labels
Milestone
Description
A small amount of our code is very slow to compile in VS2026, i.e. with the latest F# compiler.
We had a file with 3675 lines of generated ADO.Net code, which previously took about 5s to compile, and with VS2026 took 100s. I was able to make a simple reproduction:
namespace GeneratedADONET.TableGetters
open System
open System.Data
open Microsoft.Data.SqlClient
open System.Collections.Immutable
type ISqlConnection =
abstract Connection: SqlConnection
abstract Transaction: SqlTransaction option
type Document1(Id: int, Code: int, Serialization: byte[], RowVersion: byte[]) =
member _.Id = Id
member _.Code = Code
member _.Serialization = Serialization
member _.RowVersion = RowVersion
static member Execute(conn: ISqlConnection) =
task {
use command = new SqlCommand("SELECT * FROM [dbo].[Document]", conn.Connection)
conn.Transaction |> Option.iter(fun t -> command.Transaction <- t)
use! reader = command.ExecuteReaderAsync()
let b = ImmutableArray.CreateBuilder<Document1>()
while reader.Read() do
b.Add(Document1(reader.GetInt32(0), reader.GetInt32(1), reader.[2] :?> byte[], reader.[3] :?> byte[]))
return b.ToImmutable()
}
...
// Copy the above, and replace Document1 with Document2 up to Document50
The fsproj is:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference></PropertyGroup>
<ItemGroup>
<Compile Include="Generated.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FSharp.Core" />
<PackageReference Include="Microsoft.Data.SqlClient" />
</ItemGroup>
</Project>
The result of the above is file with 746 lines of code taking 55s to compile on my system. I can put it in a github repo if that would help.
It's possibly O(n^2) in the number of copies of Document[N].
I can't see anything difficult about the code, and replacing it with very similar code for other tables gives very different timings.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
New