Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
7a41d85
fix some inconsistencies
majocha Feb 23, 2024
22e955a
we don't intend to dispose this ever
majocha Feb 23, 2024
a0d5694
Merge branch 'main' into use-logger-fixes
majocha Feb 23, 2024
8768355
Merge branch 'main' into use-logger-fixes
majocha Feb 24, 2024
86db4d3
Merge branch 'main' into use-logger-fixes
majocha Feb 26, 2024
8be519e
removed
majocha Feb 26, 2024
7351011
Merge branch 'use-logger-fixes' into al-wip
majocha Feb 26, 2024
8e9a815
multiple loggers
majocha Feb 26, 2024
6dab107
fix RegisterAndImportReferencedAssemblies
majocha Feb 26, 2024
e0fbb8d
fix deadlock in fsi
majocha Feb 27, 2024
70beb11
fix some BuildGraphTests
majocha Feb 27, 2024
757d6cd
restore asyncmemoize
majocha Feb 27, 2024
3d56838
fix missing logger in test
majocha Feb 27, 2024
e6a1640
Merge remote-tracking branch 'dotnet/main' into al-wip
majocha Feb 27, 2024
cb72156
format
majocha Feb 27, 2024
afaf692
fix transparent compiler nre
majocha Feb 27, 2024
cc7a690
cleanup
majocha Feb 27, 2024
fd105bd
default value
majocha Feb 27, 2024
51ad4ce
add some comments
majocha Feb 28, 2024
c271c57
foramt and notes to make it green if it's green
majocha Feb 28, 2024
0ca7fe6
wrap any parallel computations that potentially push diagnostics
majocha Feb 28, 2024
ee46955
try to fix buildgraphtests
majocha Feb 28, 2024
7c3cd98
try to eradicate deadlocks in tests
majocha Feb 28, 2024
6afb997
Merge remote-tracking branch 'fsharp/main' into al-wip
majocha Feb 28, 2024
2d0a74e
fix buildgraph test
majocha Feb 28, 2024
adf0417
disable for a moment
majocha Feb 28, 2024
204ed81
Merge branch 'main' into al-wip
majocha Feb 28, 2024
3673b46
flatten exceptions
majocha Feb 28, 2024
cafa476
Merge remote-tracking branch 'dotnet/main' into al-wip
majocha Feb 28, 2024
fbb3a4a
reshuffle
majocha Feb 28, 2024
e793736
Merge remote-tracking branch 'dotnet/main' into al-wip
majocha Feb 28, 2024
46e81bd
prevent graphnode deadlock
majocha Feb 28, 2024
29563c1
yield
majocha Feb 29, 2024
24180d0
diff
majocha Feb 29, 2024
63492dc
add some comments
majocha Feb 29, 2024
b025759
Merge branch 'main' into al-wip
majocha Mar 1, 2024
0e3f726
add AsyncLocal test
majocha Mar 1, 2024
779b11b
more testing
majocha Mar 1, 2024
b44b6e0
Merge branch 'main' into al-wip
majocha Mar 1, 2024
c1ce15c
Merge branch 'main' into al-wip
majocha Mar 1, 2024
335b618
Merge branch 'main' into al-wip
majocha Mar 4, 2024
0c1f805
Merge branch 'main' into al-wip
majocha Mar 4, 2024
2882de9
Merge branch 'main' into al-wip
majocha Mar 5, 2024
0b367bd
Merge branch 'main' into al-wip
majocha Mar 5, 2024
ecba2ec
Merge branch 'main' into al-wip
majocha Mar 5, 2024
049e276
Merge branch 'main' into al-wip
majocha Mar 6, 2024
7093530
Merge branch 'main' into al-wip
majocha Mar 6, 2024
69e49a7
not needed after all?
majocha Mar 6, 2024
bd6f5c1
test
majocha Mar 6, 2024
fc1293b
Merge branch 'main' into al-wip
majocha Mar 7, 2024
a650e04
format
majocha Mar 7, 2024
6eba688
revert
majocha Mar 7, 2024
5ed3239
Merge branch 'main' into al-wip
majocha Mar 7, 2024
128ca82
Merge branch 'main' into al-wip
majocha Mar 7, 2024
fb91545
try RunContinuationsAsynchronously
majocha Mar 8, 2024
c96ff79
Merge branch 'main' into al-wip
majocha Mar 8, 2024
00821e3
try to deal with deadlock another way
majocha Mar 10, 2024
c570ff6
Merge branch 'main' into al-wip
majocha Mar 11, 2024
75e4457
nope
majocha Mar 11, 2024
0b43270
Merge branch 'al-wip' of https://github.com/majocha/fsharp into al-wip
majocha Mar 11, 2024
2bbddd8
Merge branch 'main' into al-wip
majocha Mar 11, 2024
6bd5a08
revert
majocha Mar 11, 2024
7ca795f
Merge branch 'al-wip' of https://github.com/majocha/fsharp into al-wip
majocha Mar 11, 2024
4574370
Merge branch 'main' into al-wip
majocha Mar 11, 2024
7783850
format
majocha Mar 12, 2024
8519c78
Merge branch 'main' into al-wip
majocha Mar 12, 2024
cc486c7
Merge branch 'al-wip' of https://github.com/majocha/fsharp into al-wip
majocha Mar 12, 2024
4508fe8
Merge branch 'main' into al-wip
majocha Mar 12, 2024
05c6298
Merge branch 'main' into al-wip
majocha Mar 13, 2024
4420340
Merge branch 'main' into al-wip
majocha Mar 14, 2024
153bfb8
merge main
majocha Mar 23, 2024
6200cbc
merge main
majocha Apr 29, 2024
862870b
restore release notes
majocha Apr 29, 2024
50fd92c
Merge branch 'main' into al-wip
majocha Apr 30, 2024
1f2c7f3
add test for ListParallel
majocha Apr 30, 2024
d94c8bd
merge main
majocha May 3, 2024
b7922f2
Merge remote-tracking branch 'dotnet/main' into al-wip
majocha May 3, 2024
e05cfe5
speed up test
majocha May 4, 2024
b9b01eb
improve test
majocha May 5, 2024
87ccfa3
simpler MultipleDiagnosticsLoggers
majocha May 6, 2024
f4cf7e6
rename and speedup test
majocha May 6, 2024
2dccbba
Merge branch 'main' into al-wip
majocha May 7, 2024
f94c3da
parallel logging perf
majocha May 7, 2024
e30dbde
Merge remote-tracking branch 'fsharp/main' into al-wip
majocha May 7, 2024
f4eeac9
Merge remote-tracking branch 'dotnet/main' into al-wip
majocha May 8, 2024
27dd989
remove SwitchToThreadPool
majocha May 8, 2024
8c77c0c
sequential
majocha May 9, 2024
76ae65f
Revert "sequential"
majocha May 9, 2024
684462e
Merge branch 'main' into al-wip
majocha May 9, 2024
4d5248f
Merge branch 'main' into al-wip
majocha May 13, 2024
1330fe0
Merge branch 'main' into al-wip
majocha May 13, 2024
45323a7
Merge branch 'main' into al-wip
psfinaki May 14, 2024
aec0451
revert spurious change
majocha May 14, 2024
f711156
fix comments
majocha May 14, 2024
a2641f5
test MultipleDiagnosticsLoggers
majocha May 14, 2024
afdd041
add comment and clean up
majocha May 14, 2024
f22f2f2
Merge branch 'main' into al-wip
majocha May 14, 2024
a67d898
Merge branch 'main' into al-wip
majocha May 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
default value
  • Loading branch information
majocha committed Feb 27, 2024
commit fd105bd4dd2d5db5ed67924716862e755e53f776
45 changes: 20 additions & 25 deletions src/Compiler/Facilities/DiagnosticsLogger.fs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,13 @@ let DiscardErrorsLogger =
member _.ErrorCount = 0
}

let AssertFalseDiagnosticsLogger =
{ new DiagnosticsLogger("AssertFalseDiagnosticsLogger") with
// TODO: reenable these asserts in the compiler service
member _.DiagnosticSink(diagnostic, severity) = (* assert false; *) ()
member _.ErrorCount = (* assert false; *) 0
}

type CapturingDiagnosticsLogger(nm, ?eagerFormat) =
inherit DiagnosticsLogger(nm)
let mutable errorCount = 0
Expand All @@ -368,26 +375,19 @@ type CapturingDiagnosticsLogger(nm, ?eagerFormat) =
let errors = diagnostics.ToArray()
errors |> Array.iter diagnosticsLogger.DiagnosticSink

let trace prefix (dl: DiagnosticsLogger) =
let name = if box dl |> isNull then "NULL" else dl.DebugDisplay()
Trace.WriteLine $"t:{Thread.CurrentThread.ManagedThreadId} {prefix} {name}"
dl

let buildPhase = AsyncLocal<_>()
let diagnosticsLogger = AsyncLocal<_>()
let buildPhase = AsyncLocal<BuildPhase voption>()
let diagnosticsLogger = AsyncLocal<DiagnosticsLogger voption>()

/// Type holds thread-static globals for use by the compiler.
type internal DiagnosticsThreadStatics =

static member BuildPhaseUnchecked = buildPhase.Value

static member BuildPhase
with get () = buildPhase.Value
and set v = buildPhase.Value <- v
with get () = buildPhase.Value |> ValueOption.defaultValue BuildPhase.DefaultPhase
and set v = buildPhase.Value <- ValueSome v

static member DiagnosticsLogger
with get () = diagnosticsLogger.Value
and set v = diagnosticsLogger.Value <- v
with get () = diagnosticsLogger.Value |> ValueOption.defaultValue AssertFalseDiagnosticsLogger
and set v = diagnosticsLogger.Value <- ValueSome v

[<AutoOpen>]
module DiagnosticsLoggerExtensions =
Expand Down Expand Up @@ -418,7 +418,6 @@ module DiagnosticsLoggerExtensions =
type DiagnosticsLogger with

member x.EmitDiagnostic(exn, severity) =
trace "error emitted to " x |> ignore

match exn with
| InternalError(s, _)
Expand Down Expand Up @@ -491,24 +490,21 @@ module DiagnosticsLoggerExtensions =

/// NOTE: The change will be undone when the returned "unwind" object disposes
let UseBuildPhase (phase: BuildPhase) =
let oldBuildPhase = DiagnosticsThreadStatics.BuildPhaseUnchecked
let oldBuildPhase = buildPhase.Value
DiagnosticsThreadStatics.BuildPhase <- phase

{ new IDisposable with
member x.Dispose() =
DiagnosticsThreadStatics.BuildPhase <- oldBuildPhase
member x.Dispose() = buildPhase.Value <- oldBuildPhase
}

/// NOTE: The change will be undone when the returned "unwind" object disposes
let UseTransformedDiagnosticsLogger (transformer: DiagnosticsLogger -> #DiagnosticsLogger) =
let oldLogger = DiagnosticsThreadStatics.DiagnosticsLogger |> trace "old"
DiagnosticsThreadStatics.DiagnosticsLogger <- transformer oldLogger |> trace "new"
Trace.Indent()
let UseTransformedDiagnosticsLogger (transformer: DiagnosticsLogger -> DiagnosticsLogger) =
let oldLogger = DiagnosticsThreadStatics.DiagnosticsLogger
DiagnosticsThreadStatics.DiagnosticsLogger <- transformer oldLogger

{ new IDisposable with
member _.Dispose() =
DiagnosticsThreadStatics.DiagnosticsLogger <- oldLogger |> trace "restore"
Trace.Unindent()
DiagnosticsThreadStatics.DiagnosticsLogger <- oldLogger
}

let UseDiagnosticsLogger newLogger =
Expand All @@ -518,7 +514,6 @@ let SetThreadBuildPhaseNoUnwind (phase: BuildPhase) =
DiagnosticsThreadStatics.BuildPhase <- phase

let SetThreadDiagnosticsLoggerNoUnwind diagnosticsLogger =
//trace "no unwind"
DiagnosticsThreadStatics.DiagnosticsLogger <- diagnosticsLogger

/// This represents the thread-local state established as each task function runs as part of the build.
Expand All @@ -528,7 +523,7 @@ type CompilationGlobalsScope(diagnosticsLogger: DiagnosticsLogger, buildPhase: B
let unwindEL = UseDiagnosticsLogger diagnosticsLogger
let unwindBP = UseBuildPhase buildPhase

new() = new CompilationGlobalsScope(diagnosticsLogger.Value, buildPhase.Value)
new() = new CompilationGlobalsScope(DiagnosticsThreadStatics.DiagnosticsLogger, DiagnosticsThreadStatics.BuildPhase)

member _.DiagnosticsLogger = diagnosticsLogger
member _.BuildPhase = buildPhase
Expand Down
7 changes: 4 additions & 3 deletions src/Compiler/Facilities/DiagnosticsLogger.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ type DiagnosticsLogger =
/// Represents a DiagnosticsLogger that discards diagnostics
val DiscardErrorsLogger: DiagnosticsLogger

/// Represents a DiagnosticsLogger that ignores diagnostics and asserts
val AssertFalseDiagnosticsLogger: DiagnosticsLogger

/// Represents a DiagnosticsLogger that captures all diagnostics, optionally formatting them
/// eagerly.
type CapturingDiagnosticsLogger =
Expand All @@ -229,8 +232,6 @@ type DiagnosticsThreadStatics =

static member BuildPhase: BuildPhase with get, set

static member BuildPhaseUnchecked: BuildPhase

static member DiagnosticsLogger: DiagnosticsLogger with get, set

[<AutoOpen>]
Expand Down Expand Up @@ -275,7 +276,7 @@ module DiagnosticsLoggerExtensions =
val UseBuildPhase: phase: BuildPhase -> IDisposable

/// NOTE: The change will be undone when the returned "unwind" object disposes
val UseTransformedDiagnosticsLogger: transformer: (DiagnosticsLogger -> #DiagnosticsLogger) -> IDisposable
val UseTransformedDiagnosticsLogger: transformer: (DiagnosticsLogger -> DiagnosticsLogger) -> IDisposable

val UseDiagnosticsLogger: newLogger: DiagnosticsLogger -> IDisposable

Expand Down