Skip to content

Relax StackGuard thresholds? #18970

@majocha

Description

@majocha

Current default StackGuard depths can result in tens of thousands thread switches during compilation and / or type checking, especially when CEs and resumable state machines are involved.

For example compiling IcedTasks.Tests.fsproj for net9.0:

caller source jumps
remapExprImpl TypedTreeOps.fs:6008 2089
CheckExpr TailCallChecks.fs:315 1382
exprF TypedTreeOps.fs:7448 29661
CheckExpr PostInferenceChecks.fs:1152 173
OptimizeExpr Optimizer.fs:2343 23959

It seems this can add 10% or more to build time for projects with heavy CE use.

Taking IcedTasks.Tests as example, rising the relevant StackGuard depths makes the Optimizations phase go from 12s to 8s and the overall build time from 24s to 19s.

Most of the default depths are currently 50 or 100, I raised them x2 to test this and got zero thread switches during build.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions