Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump stackguard depths values by 10% #16754

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dawedawe
Copy link
Contributor

Description

Just an experiment to see if this is still safe for the CI.

Currently used stackguard depths:

Method Source Mean Error StdDev Gen0 Gen1 Gen2 Allocated
CheckCE CE100xnest1.fs 970.2 us 11.98 us 10.62 us 1.9531 - - 399.07 KB
CompileCE CE100xnest1.fs 617,619.5 us 5,090.12 us 4,512.26 us 2000.0000 1000.0000 1000.0000 245893.58 KB
CheckCE CE100xnest5.fs 939.1 us 13.46 us 12.59 us 1.9531 - - 463.35 KB
CompileCE CE100xnest5.fs 6,063,118.7 us 30,310.18 us 28,352.16 us 19000.0000 3000.0000 2000.0000 2211482.66 KB
CheckCE CE200xnest5.fs 1,078.6 us 12.66 us 11.22 us 3.9063 1.9531 1.9531 539.94 KB
CompileCE CE200xnest5.fs 112,085,850.0 us 1,020,478.77 us 904,627.85 us 331000.0000 78000.0000 63000.0000 12184208.6 KB
CheckCE CEwCO100xnest5.fs 1,296.1 us 25.79 us 25.33 us 7.8125 5.8594 3.9063 703.78 KB
CompileCE CEwCO100xnest5.fs 414,402.7 us 7,389.49 us 6,550.59 us - - - 272771.18 KB
CheckCE CEwCO500xnest1.fs 1,021.9 us 13.37 us 12.50 us 3.9063 - - 486.01 KB
CompileCE CEwCO500xnest1.fs 2,501,643.4 us 20,112.73 us 17,829.41 us 3000.0000 2000.0000 1000.0000 574831.59 KB

Every stackguard depth x 1.1:

Method Source Mean Error StdDev Gen0 Gen1 Gen2 Allocated
CheckCE CE100xnest1.fs 975.6 us 18.85 us 26.42 us 1.9531 - - 402.44 KB
CompileCE CE100xnest1.fs 561,934.6 us 7,912.15 us 7,401.03 us 1000.0000 - - 247158.37 KB
CheckCE CE100xnest5.fs 920.4 us 18.05 us 16.00 us 1.9531 - - 470.81 KB
CompileCE CE100xnest5.fs 5,637,651.6 us 61,547.10 us 54,559.90 us 17000.0000 3000.0000 2000.0000 2185399.07 KB
CheckCE CE200xnest5.fs 1,077.0 us 21.35 us 29.93 us 3.9063 1.9531 1.9531 547.4 KB
CompileCE CE200xnest5.fs 100,545,766.4 us 1,179,599.59 us 1,103,398.19 us 279000.0000 80000.0000 60000.0000 11736391.63 KB
CheckCE CEwCO100xnest5.fs 1,298.0 us 24.81 us 29.54 us 5.8594 3.9063 3.9063 704.88 KB
CompileCE CEwCO100xnest5.fs 369,277.6 us 6,146.04 us 5,448.30 us - - - 269019.16 KB
CheckCE CEwCO500xnest1.fs 981.7 us 19.46 us 23.17 us 3.9063 - - 489.4 KB
CompileCE CEwCO500xnest1.fs 2,302,916.6 us 29,280.40 us 27,388.90 us 3000.0000 2000.0000 1000.0000 568457.97 KB

Checklist

  • Test cases added

  • Performance benchmarks added in case of performance changes

  • Release notes entry updated:

    Please make sure to add an entry with short succinct description of the change as well as link to this pull request to the respective release notes file, if applicable.

    Release notes files:

    • If anything under src/Compiler has been changed, please make sure to make an entry in docs/release-notes/.FSharp.Compiler.Service/<version>.md, where <version> is usually "highest" one, e.g. 42.8.200
    • If language feature was added (i.e. LanguageFeatures.fsi was changed), please add it to docs/releae-notes/.Language/preview.md
    • If a change to FSharp.Core was made, please make sure to edit docs/release-notes/.FSharp.Core/<version>.md where version is "highest" one, e.g. 8.0.200.

    Information about the release notes entries format can be found in the documentation.
    Example:

    If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request.

Copy link
Contributor

❗ Release notes required

@dawedawe,

Caution

No release notes found for the changed paths (see table below).

Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format.

The following format is recommended for this repository:

* <Informative description>. ([PR #XXXXX](https://github.com/dotnet/fsharp/pull/XXXXX))

See examples in the files, listed in the table below or in th full documentation at https://fsharp.github.io/fsharp-compiler-docs/release-notes/About.html.

If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request.

You can open this PR in browser to add release notes: open in github.dev

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/8.0.300.md No release notes found or release notes format is not correct

@auduchinok
Copy link
Member

auduchinok commented Feb 23, 2024

Please test it carefully on macOS, where the stack size is the smallest and where the most of stackoverlow reports were coming from before this guard was added. There were many reports coming from macOS users.

Maybe we could use different sizes depending on the used OS somehow?

@dawedawe
Copy link
Contributor Author

Yes, I have another branch that sets the limit according to the platform.
I'll merge it here.

Copy link
Member

@vzarytovskii vzarytovskii left a comment

Choose a reason for hiding this comment

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

Yeah, I would be extremely careful with it, there's no way really to properly test it except of some sort of fuzzing (which we are lacking now).

#endif

static member GetDepthOption(name: string) =
GetEnvInteger ("FSHARP_" + name + "StackGuardDepth") StackGuard.DefaultDepth

static member GetOsDependentDepth(mac: int, unix: int, win: int, other: int) : int =
Copy link
Member

Choose a reason for hiding this comment

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

This should be inline, also should be taking an environment variable as parameter and taking value from env inside.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, yeah, looks nice. Just the inlining is an issue:

C:\Users\schae\src\fsharp\src\Compiler\Facilities\DiagnosticsLogger.fs(882,9): warning FS1116: A value marked as 'inline' has an unexpected value [C:\Users\schae\src\fsharp\src\Compiler\FSharp.Compiler.Service.fsproj::TargetFramework=netstandard2.0]
C:\Users\schae\src\fsharp\src\Compiler\Facilities\DiagnosticsLogger.fs(882,9): error FS1114: The value 'FSharp.Compiler.DiagnosticsLogger.StackGuard.GetOsDependentDepth' was marked inline but was not bound in the optimization environment [C:\Users\schae\src\fsharp\src\Compiler\FSharp.Compiler.Service.fsproj::TargetFramework=netstandard2.0]
C:\Users\schae\src\fsharp\src\Compiler\Facilities\DiagnosticsLogger.fs(888,26): error FS1113: The value 'GetOsDependentDepth' was marked inline but its implementation makes use of an internal or private function which is not sufficiently accessible [C:\Users\schae\src\fsharp\src\Compiler\FSharp.Compiler.Service.fsproj::TargetFramework=netstandard2.0]  
C:\Users\schae\src\fsharp\src\Compiler\Facilities\DiagnosticsLogger.fs(882,9): error FS1118: Failed to inline the value 'GetOsDependentDepth' marked 'inline', perhaps because a recursive value was marked 'inline' [C:\Users\schae\src\fsharp\src\Compiler\FSharp.Compiler.Service.fsproj::TargetFramework=netstandard2.0]

Copy link
Member

Choose a reason for hiding this comment

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

Hm, that is awkward...It's fine then, JIT will be able to inline it likely.

Copy link
Member

Choose a reason for hiding this comment

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

I'll look into inlining issue though.

Copy link
Member

Choose a reason for hiding this comment

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

I would prefer not to have code that compiles on windows but not the mac. So probably keep the limits the same.

Copy link
Member

Choose a reason for hiding this comment

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

This is all the way around, on Mac the limit is lower -> we will spawn another thread earlier. So it will work, but will have different frames limit on different OSs

@vzarytovskii
Copy link
Member

Ironically, I ran benchmarks on this branch (on macOS), and immediately got SO :D To be fair, I've gotten the same on the main.

@dawedawe
Copy link
Contributor Author

dawedawe commented Mar 1, 2024

Ironically, I ran benchmarks on this branch (on macOS), and immediately got SO :D To be fair, I've gotten the same on the main.

Yeah, main and this branch should be the same regarding macOs, as there's no bump for macOS in this branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: New
Development

Successfully merging this pull request may close these issues.

None yet

4 participants