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
VS 2022 Preview - Startup time for CoreClr compiler slower than desktop #11907
We recently switched to using the CoreClr compiler for builds in VS instead of the desktop compiler. Doing so, we regressed compile-time performance.
TFM: net5
// Learn more about F# at http://docs.microsoft.com/dotnet/fsharpopenSystem// Define a function to construct a message to printletfrom whom =
sprintf "from %s" whom
[<EntryPoint>]letmain argv =letmessage= from "F#"// Call the function
printfn "Hello world %s" message
0// return an integer exit code
CoreClr compiler: 1326 ms Fsc 1 calls
Desktop compiler: 586 ms Fsc 1 calls
It's over double the cost.
This is basically the startup time; I imagine the compiler doesn't actually perform worse on the CoreClr. However, this can be surprising for users as the additional 740ms build-cost per project will add up.
We recently switched to using the CoreClr compiler for builds in VS instead of the desktop compiler. Doing so, we regressed compile-time performance.
TFM: net5
// Learn more about F# at http://docs.microsoft.com/dotnet/fsharpopenSystem// Define a function to construct a message to printletfrom whom =
sprintf "from %s" whom
[<EntryPoint>]letmain argv =letmessage= from "F#"// Call the function
printfn "Hello world %s" message
0// return an integer exit code
CoreClr compiler: 1326 ms Fsc 1 calls
Desktop compiler: 586 ms Fsc 1 calls
It's over double the cost.
This is basically the startup time; I imagine the compiler doesn't actually perform worse on the CoreClr. However, this can be surprising for users as the additional 740ms build-cost per project will add up.
Hm, that's interesting. Did you manage to see which part is taking more time? Do we know if it's actually fsc, or something before?
Edit: I mean, can it be msbuild or something? CoreCLR also uses crossgen, right?
It's not msbuild. It's simply that the JIT is taking longer on the CoreClr.
CoreClr
Desktop
For FSharp.Compiler.Private.dll, the desktop JIT took 0.5ms, where as the CoreClr JIT took 439ms.
FSharp.Core.dll takes longer as well. The runtime libraries take longer on the CoreClr but not nearly the same magnitude as the F# compiler.
@jkotas ,
Hey mate, it looks as if cross-gen'd F# assemblies are spending an awfully large amount of time in the Jit. Who should we work with, or how can analyse what is going on here?
cc @dotnet/crossgen-contrib. @TIHan@KevinRansom is there a standalone repro you can share ? Also would be good to know what tooling you are using to crossgen the assemblies.
Do you know how many functions you have with tail. prefixes in them? Currently any such function will be skipped during crossgen. I'd be curious to see if dotnet/runtime#56669 has an effect on x64 Windows (it should allow a significant fraction of these functions to be crossgenned).
@jakobbotsch - We emit 'tail' prefix pretty frequently; basically any function call that could be tail recursive we emit the prefix. That's not entirely true for every single function, but it's mostly true.
This has been identified as being an issue with crossgen, the coreclr team have done some stellar work and improved the amount of .tailcalls that get crossgened.
Activity
TIHan commentedon Aug 2, 2021
// cc @KevinRansom @jonsequitur
vzarytovskii commentedon Aug 2, 2021
Hm, that's interesting. Did you manage to see which part is taking more time? Do we know if it's actually fsc, or something before?
Edit: I mean, can it be msbuild or something? CoreCLR also uses crossgen, right?
TIHan commentedon Aug 3, 2021
It's not msbuild. It's simply that the JIT is taking longer on the CoreClr.
CoreClr

Desktop

For FSharp.Compiler.Private.dll, the desktop JIT took 0.5ms, where as the CoreClr JIT took 439ms.
FSharp.Core.dll takes longer as well. The runtime libraries take longer on the CoreClr but not nearly the same magnitude as the F# compiler.
TIHan commentedon Aug 3, 2021
I think we may not have cross-gen enabled in the SDK; we may have to do this -> https://docs.microsoft.com/en-us/dotnet/core/deploying/ready-to-run
// cc @brettfo
KevinRansom commentedon Aug 3, 2021
Yes ... there is a steep performance degrade between desktop and coreclr:
The following shows --times for exactly the same inputs between desktop and coreclr for dotnet 6 and 5.05
KevinRansom commentedon Aug 3, 2021
The shipped binary has been compiled with cross-gen:
We build IL only, note the flag: IL Only
When shipped it has been transformed by crossgen to IL Library:
KevinRansom commentedon Aug 3, 2021
@jkotas ,
Hey mate, it looks as if cross-gen'd F# assemblies are spending an awfully large amount of time in the Jit. Who should we work with, or how can analyse what is going on here?
Thanks
Kevin
KevinRansom commentedon Aug 3, 2021
I have done a sanity check back to 2.1 and the behavior seems similar, so at least it's not a regression.
jkotas commentedon Aug 4, 2021
@mangod9 Could your team please take a look?
mangod9 commentedon Aug 4, 2021
cc @dotnet/crossgen-contrib. @TIHan @KevinRansom is there a standalone repro you can share ? Also would be good to know what tooling you are using to crossgen the assemblies.
jakobbotsch commentedon Aug 4, 2021
Do you know how many functions you have with tail. prefixes in them? Currently any such function will be skipped during crossgen. I'd be curious to see if dotnet/runtime#56669 has an effect on x64 Windows (it should allow a significant fraction of these functions to be crossgenned).
TIHan commentedon Sep 15, 2021
@jakobbotsch - We emit 'tail' prefix pretty frequently; basically any function call that could be tail recursive we emit the prefix. That's not entirely true for every single function, but it's mostly true.
KevinRansom commentedon Sep 27, 2021
This has been identified as being an issue with crossgen, the coreclr team have done some stellar work and improved the amount of .tailcalls that get crossgened.
Their PR is here: dotnet/runtime#56669
We will close this issue. And add a tracking issue to identify further issues once 56669 is available