Skip to content

Conversation

@dsyme
Copy link
Contributor

@dsyme dsyme commented Aug 20, 2022

Workaround #13730 to help make this repo more usable

DOTNET_gcServer=1

This largely corrects the perf of the F# compiler in .NET 7 preview 7 when used from build.bat

Ideally we would prefer the workaround

COMPLUS_GCName=clrgc.dll

but this seems to kill fslex and fsyacc - there may be something we can do for that, not sure. (and should this be DOTNET_GCName=clrgc.dll cc @mangod9 )

@dsyme
Copy link
Contributor Author

dsyme commented Aug 20, 2022

Sigh, setting ServerGC seems to kill fscyacc:

D:\a\_work\1\s\buildtools\buildtools.targets(54,5): error MSB3073: The command ""D:\a\_work\1\s\.dotnet\dotnet.exe" "D:\a\_work\1\s\artifacts\\Bootstrap\fsyacc\fsyacc.dll" -o "D:\a\_work\1\s\artifacts\obj\FSharp.Compiler.Service\Proto\netstandard2.0\pars.fs" -v --module FSharp.Compiler.Parser --open FSharp.Compiler --open FSharp.Compiler.Syntax --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing pars.fsy" exited with code 1. [D:\a\_work\1\s\src\Compiler\FSharp.Compiler.Service.fsproj]

Build FAILED.

FSYACC : error FSY000: Object reference not set to an instance of an object. [D:\a\_work\1\s\src\Compiler\FSharp.Compiler.Service.fsproj]
D:\a\_work\1\s\buildtools\buildtools.targets(54,5): error MSB3073: The command ""D:\a\_work\1\s\.dotnet\dotnet.exe" "D:\a\_work\1\s\artifacts\\Bootstrap\fsyacc\fsyacc.dll" -o "D:\a\_work\1\s\artifacts\obj\FSharp.Compiler.Service\Proto\netstandard2.0\pars.fs" -v --module FSharp.Compiler.Parser --open FSharp.Compiler --open FSharp.Compiler.Syntax --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing pars.fsy" exited with code 1. [D:\a\_work\1\s\src\Compiler\FSharp.Compiler.Service.fsproj]
    0 Warning(s)
    2 Error(s)

@vzarytovskii
Copy link
Member

We can theoretically set it only for proto, fsharp, and visualfsharp solutions.
It will be an even worse hack though.

@mangod9
Copy link
Member

mangod9 commented Aug 20, 2022

but this seems to kill fslex and fsyacc - there may be something we can do for that, not sure. (and should this be DOTNET_GCName=clrgc.dll cc @mangod9 )

yeah DOTNET_* is the preferred way in 6+, but both are supported atm. Perhaps your other projects are failing since they arent compiling against latest 7preview7 drop? clrgc.dll has been included only starting in preview7

@dsyme
Copy link
Contributor Author

dsyme commented Aug 20, 2022

We can theoretically set it only for proto, fsharp, and visualfsharp solutions.

It's that we need to set it for just fsc executions. I'll see if it can be done

<SetEnvironmentVariableTask Name="DOTNET_gcServer" Value="1" />
</Target>
<Target Name="UnsetGcServerAfterRunningSdkCompiler" AfterTargets="CoreCompile" Condition="'$(Configuration)' == 'Proto' OR '$(DisableCompilerRedirection)'=='true'">
<SetEnvironmentVariableTask Name="DOTNET_gcServer" Value="0" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately this is not a stable way of setting/unsetting the environment variable for only the execution of fsc in a multiproc setting.

AFAICS MSBuild has no way to say "use this environment variable when running these tasks".

Not sure if there's much else we can do to get the compiler in .NET SDK 7 p7 working efficiently.

@dsyme
Copy link
Contributor Author

dsyme commented Aug 20, 2022

@vzarytovskii I give up here - I have no idea how to get the environment variable DOTNET_gcServer=1 set only for executions of the F# compiler that comes from the .NET SDK. As usual MSBuild is the hardest thing in the universe. I guess we could execute via a batch file or similar.

@EgorBo
Copy link
Member

EgorBo commented Aug 22, 2022

Can confirm, the following command:

C:\prj\fsharp\src\Compiler> dotnet "C:\prj\fsharp\artifacts\\Bootstrap\fsyacc\fsyacc.dll" -o 
"C:\prj\fsharp\artifacts\obj\FSharp.Compiler.Service\Proto\netstandard2.0\pars.fs" -v 
--module FSharp.Compiler.Parser --open FSharp.Compiler --open FSharp.Compiler.Syntax 
--internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing pars.fsy

crashes all the time on the latest daily .net7 + server GC mode with either AVE or NRE in random places e.g.
image

@EgorBo
Copy link
Member

EgorBo commented Aug 22, 2022

Tested with various modes including GCStress=0xC, disabled/enabled R2R, disabled optimizations in jit - it only reproduces with gcServer=1 so sounds like a gc bug to me cc @dotnet/gc @jkotas

@dsyme
Copy link
Contributor Author

dsyme commented Aug 22, 2022

@EgorBo Thank you for looking at this

@vzarytovskii
Copy link
Member

vzarytovskii commented Aug 22, 2022

Here's a standalone repro, instructions are in readme: https://github.com/vzarytovskii/fsyacc-issue-repro/tree/main

Update: Turning tailcalls and optimize off does not change anything - still fails.

@Maoni0
Copy link
Member

Maoni0 commented Aug 23, 2022

thanks for the repro @vzarytovskii, we will take a look (I just quickly tried and I can repro it).

@PeterSolMS
Copy link

I'm investigating - I suspect we are not handling mark stack overflow in Server GC correctly in this case.

@vzarytovskii
Copy link
Member

@PeterSolMS Any luck with investigation? I suppose, fix will target rc2?

@PeterSolMS
Copy link

Sorry about not keeping this up to date - I checked in a fix, PR is here dotnet/runtime#74571.

Fix should be in RC2.

@dsyme dsyme closed this Sep 23, 2022
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.

6 participants