Skip to content

Commit a2bc2c8

Browse files
committed
stackguard uses threadpool
1 parent ab0d07d commit a2bc2c8

File tree

2 files changed

+8
-27
lines changed

2 files changed

+8
-27
lines changed

src/Compiler/Facilities/DiagnosticsLogger.fs

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -872,35 +872,22 @@ let internal languageFeatureNotSupportedInLibraryError (langFeature: LanguageFea
872872
type StackGuard(maxDepth: int, name: string) =
873873

874874
let mutable depth = 1
875+
do ignore name
875876

876877
[<DebuggerHidden; DebuggerStepThrough>]
877-
member _.Guard
878-
(
879-
f,
880-
[<CallerMemberName; Optional; DefaultParameterValue("")>] memberName: string,
881-
[<CallerFilePath; Optional; DefaultParameterValue("")>] path: string,
882-
[<CallerLineNumber; Optional; DefaultParameterValue(0)>] line: int
883-
) =
884-
885-
Activity.addEventWithTags
886-
"DiagnosticsLogger.StackGuard.Guard"
887-
(seq {
888-
Activity.Tags.stackGuardName, box name
889-
Activity.Tags.stackGuardCurrentDepth, depth
890-
Activity.Tags.stackGuardMaxDepth, maxDepth
891-
Activity.Tags.callerMemberName, memberName
892-
Activity.Tags.callerFilePath, path
893-
Activity.Tags.callerLineNumber, line
894-
})
878+
member _.Guard f =
895879

896880
depth <- depth + 1
897881

898882
try
899883
if depth % maxDepth = 0 then
900884

901885
async {
902-
do! Async.SwitchToNewThread()
903-
Thread.CurrentThread.Name <- $"F# Extra Compilation Thread for {name} (depth {depth})"
886+
if Environment.Is64BitProcess then
887+
do! Async.SwitchToThreadPool()
888+
else
889+
do! Async.SwitchToNewThread()
890+
904891
return f ()
905892
}
906893
|> Async.RunImmediate

src/Compiler/Facilities/DiagnosticsLogger.fsi

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -463,13 +463,7 @@ type StackGuard =
463463
new: maxDepth: int * name: string -> StackGuard
464464

465465
/// Execute the new function, on a new thread if necessary
466-
member Guard:
467-
f: (unit -> 'T) *
468-
[<CallerMemberName; Optional; DefaultParameterValue("")>] memberName: string *
469-
[<CallerFilePath; Optional; DefaultParameterValue("")>] path: string *
470-
[<CallerLineNumber; Optional; DefaultParameterValue(0)>] line: int ->
471-
'T
472-
466+
member Guard: f: (unit -> 'T) -> 'T
473467
static member GetDepthOption: string -> int
474468

475469
/// This represents the global state established as each task function runs as part of the build.

0 commit comments

Comments
 (0)