diff --git a/src/fsharp/vs/Reactor.fs b/src/fsharp/vs/Reactor.fs index aabe7371c6c..96b5149e8c1 100755 --- a/src/fsharp/vs/Reactor.fs +++ b/src/fsharp/vs/Reactor.fs @@ -31,7 +31,7 @@ type internal ReactorCommands = /// There is one global Reactor for the entire language service, no matter how many projects or files /// are open. type Reactor() = - static let pauseBeforeBackgroundWorkDefault = GetEnvInteger "FCS_PauseBeforeBackgroundWorkMilliseconds" 1000 + static let pauseBeforeBackgroundWorkDefault = GetEnvInteger "FCS_PauseBeforeBackgroundWorkMilliseconds" 10 static let theReactor = Reactor() let mutable pauseBeforeBackgroundWork = pauseBeforeBackgroundWorkDefault @@ -59,7 +59,11 @@ type Reactor() = | _, Some _ -> return! inbox.TryReceive(0) | Some _, _ -> - let timeout = (if bg then 0 else pauseBeforeBackgroundWork) + let timeout = + if bg then 0 + else + Trace.TraceInformation("Reactor: {0:n3} pausing {1} milliseconds", DateTime.Now.TimeOfDay.TotalSeconds, pauseBeforeBackgroundWork) + pauseBeforeBackgroundWork return! inbox.TryReceive(timeout) } #if FX_RESHAPED_GLOBALIZATION CultureInfo.CurrentUICulture <- culture @@ -72,7 +76,7 @@ type Reactor() = return! loop (bgOpOpt, onComplete, false) | Some (Op (userOpName, opName, opArg, ct, op, ccont)) -> if ct.IsCancellationRequested then ccont() else - Trace.TraceInformation("Reactor: --> {0}.{1} ({2}), remaining {3}", userOpName, opName, opArg, inbox.CurrentQueueLength) + Trace.TraceInformation("Reactor: {0:n3} --> {1}.{2} ({3}), remaining {4}", DateTime.Now.TimeOfDay.TotalSeconds, userOpName, opName, opArg, inbox.CurrentQueueLength) let time = Stopwatch() time.Start() op ctok @@ -81,25 +85,25 @@ type Reactor() = //if span.TotalMilliseconds > 100.0 then let taken = span.TotalMilliseconds let msg = (if taken > 10000.0 then "BAD-OP: >10s " elif taken > 3000.0 then "BAD-OP: >3s " elif taken > 1000.0 then "BAD-OP: > 1s " elif taken > 500.0 then "BAD-OP: >0.5s " else "") - Trace.TraceInformation("Reactor: {0}<-- {1}.{2}, took {3} ms", msg, userOpName, opName, span.TotalMilliseconds) + Trace.TraceInformation("Reactor: {0:n3} {1}<-- {2}.{3}, took {4} ms", DateTime.Now.TimeOfDay.TotalSeconds, msg, userOpName, opName, span.TotalMilliseconds) return! loop (bgOpOpt, onComplete, false) | Some (WaitForBackgroundOpCompletion channel) -> match bgOpOpt with | None -> () | Some (bgUserOpName, bgOpName, bgOpArg, bgOp) -> - Trace.TraceInformation("Reactor: --> wait for background {0}.{1} ({2}), remaining {3}", bgUserOpName, bgOpName, bgOpArg, inbox.CurrentQueueLength) + Trace.TraceInformation("Reactor: {0:n3} --> wait for background {1}.{2} ({3}), remaining {4}", DateTime.Now.TimeOfDay.TotalSeconds, bgUserOpName, bgOpName, bgOpArg, inbox.CurrentQueueLength) while bgOp ctok do () channel.Reply(()) return! loop (None, onComplete, false) | Some (CompleteAllQueuedOps channel) -> - Trace.TraceInformation("Reactor: --> stop background work and complete all queued ops, remaining {0}", inbox.CurrentQueueLength) + Trace.TraceInformation("Reactor: {0:n3} --> stop background work and complete all queued ops, remaining {1}", DateTime.Now.TimeOfDay.TotalSeconds, inbox.CurrentQueueLength) return! loop (None, Some channel, false) | None -> match bgOpOpt, onComplete with | _, Some onComplete -> onComplete.Reply() | Some (bgUserOpName, bgOpName, bgOpArg, bgOp), None -> - Trace.TraceInformation("Reactor: --> background step {0}.{1} ({2})", bgUserOpName, bgOpName, bgOpArg) + Trace.TraceInformation("Reactor: {0:n3} --> background step {1}.{2} ({3})", DateTime.Now.TimeOfDay.TotalSeconds, bgUserOpName, bgOpName, bgOpArg) let time = Stopwatch() time.Start() let res = bgOp ctok @@ -107,7 +111,7 @@ type Reactor() = let taken = time.Elapsed.TotalMilliseconds //if span.TotalMilliseconds > 100.0 then let msg = (if taken > 10000.0 then "BAD-BG-SLICE: >10s " elif taken > 3000.0 then "BAD-BG-SLICE: >3s " elif taken > 1000.0 then "BAD-BG-SLICE: > 1s " else "") - Trace.TraceInformation("Reactor: {0}<-- background step, took {1}ms", msg, taken) + Trace.TraceInformation("Reactor: {0:n3} {1}<-- background step, took {2}ms", DateTime.Now.TimeOfDay.TotalSeconds, msg, taken) return! loop ((if res then bgOpOpt else None), onComplete, true) | None, None -> failwith "unreachable, should have used inbox.Receive" } @@ -121,15 +125,15 @@ type Reactor() = // [Foreground Mailbox Accessors] ----------------------------------------------------------- member r.SetBackgroundOp(bgOpOpt) = - Trace.TraceInformation("Reactor: enqueue start background, length {0}", builder.CurrentQueueLength) + Trace.TraceInformation("Reactor: {0:n3} enqueue start background, length {1}", DateTime.Now.TimeOfDay.TotalSeconds, builder.CurrentQueueLength) builder.Post(SetBackgroundOp bgOpOpt) member r.EnqueueOp(userOpName, opName, opArg, op) = - Trace.TraceInformation("Reactor: enqueue {0}.{1} ({2}), length {3}", userOpName, opName, opArg, builder.CurrentQueueLength) + Trace.TraceInformation("Reactor: {0:n3} enqueue {1}.{2} ({3}), length {4}", DateTime.Now.TimeOfDay.TotalSeconds, userOpName, opName, opArg, builder.CurrentQueueLength) builder.Post(Op(userOpName, opName, opArg, CancellationToken.None, op, (fun () -> ()))) member r.EnqueueOpPrim(userOpName, opName, opArg, ct, op, ccont) = - Trace.TraceInformation("Reactor: enqueue {0}.{1} ({2}), length {3}", userOpName, opName, opArg, builder.CurrentQueueLength) + Trace.TraceInformation("Reactor: {0:n3} enqueue {1}.{2} ({3}), length {4}", DateTime.Now.TimeOfDay.TotalSeconds, userOpName, opName, opArg, builder.CurrentQueueLength) builder.Post(Op(userOpName, opName, opArg, ct, op, ccont)) member r.CurrentQueueLength = @@ -137,12 +141,12 @@ type Reactor() = // This is for testing only member r.WaitForBackgroundOpCompletion() = - Trace.TraceInformation("Reactor: enqueue wait for background, length {0}", builder.CurrentQueueLength) + Trace.TraceInformation("Reactor: {0:n3} enqueue wait for background, length {0}", DateTime.Now.TimeOfDay.TotalSeconds, builder.CurrentQueueLength) builder.PostAndReply WaitForBackgroundOpCompletion // This is for testing only member r.CompleteAllQueuedOps() = - Trace.TraceInformation("Reactor: enqueue wait for all ops, length {0}", builder.CurrentQueueLength) + Trace.TraceInformation("Reactor: {0:n3} enqueue wait for all ops, length {0}", DateTime.Now.TimeOfDay.TotalSeconds, builder.CurrentQueueLength) builder.PostAndReply CompleteAllQueuedOps member r.EnqueueAndAwaitOpAsync (userOpName, opName, opArg, f) = diff --git a/vsintegration/src/FSharp.Editor/Classification/ColorizationService.fs b/vsintegration/src/FSharp.Editor/Classification/ColorizationService.fs index 942ca639568..78afeb6aa7f 100644 --- a/vsintegration/src/FSharp.Editor/Classification/ColorizationService.fs +++ b/vsintegration/src/FSharp.Editor/Classification/ColorizationService.fs @@ -2,8 +2,10 @@ namespace Microsoft.VisualStudio.FSharp.Editor +open System open System.Composition open System.Collections.Generic +open System.Diagnostics open System.Threading open Microsoft.CodeAnalysis @@ -36,6 +38,7 @@ type internal FSharpColorizationService member this.AddSemanticClassificationsAsync(document: Document, textSpan: TextSpan, result: List, cancellationToken: CancellationToken) = asyncMaybe { + do Trace.TraceInformation("{0:n3} (start) SemanticColorization", DateTime.Now.TimeOfDay.TotalSeconds) do! Async.Sleep DefaultTuning.SemanticColorizationInitialDelay |> liftAsync // be less intrusive, give other work priority most of the time let! options = projectInfoManager.TryGetOptionsForDocumentOrProject(document) let! sourceText = document.GetTextAsync(cancellationToken) diff --git a/vsintegration/src/FSharp.Editor/Diagnostics/SimplifyNameDiagnosticAnalyzer.fs b/vsintegration/src/FSharp.Editor/Diagnostics/SimplifyNameDiagnosticAnalyzer.fs index 72188fc1e45..9532e01fdbf 100644 --- a/vsintegration/src/FSharp.Editor/Diagnostics/SimplifyNameDiagnosticAnalyzer.fs +++ b/vsintegration/src/FSharp.Editor/Diagnostics/SimplifyNameDiagnosticAnalyzer.fs @@ -4,6 +4,7 @@ namespace rec Microsoft.VisualStudio.FSharp.Editor open System open System.Collections.Immutable +open System.Diagnostics open System.Threading open System.Threading.Tasks open System.Runtime.CompilerServices @@ -18,7 +19,8 @@ open Microsoft.VisualStudio.FSharp.LanguageService type private TextVersionHash = int -[] +// Disable until we work out how to make this low priority +//[] type internal SimplifyNameDiagnosticAnalyzer() = inherit DocumentDiagnosticAnalyzer() @@ -47,6 +49,7 @@ type internal SimplifyNameDiagnosticAnalyzer() = override this.AnalyzeSemanticsAsync(document: Document, cancellationToken: CancellationToken) = asyncMaybe { + do Trace.TraceInformation("{0:n3} (start) SimplifyName", DateTime.Now.TimeOfDay.TotalSeconds) do! Async.Sleep DefaultTuning.SimplifyNameInitialDelay |> liftAsync do! Option.guard Settings.CodeFixes.SimplifyName let! options = getProjectInfoManager(document).TryGetOptionsForEditingDocumentOrProject(document) diff --git a/vsintegration/src/FSharp.Editor/Diagnostics/UnusedDeclarationsAnalyzer.fs b/vsintegration/src/FSharp.Editor/Diagnostics/UnusedDeclarationsAnalyzer.fs index fe919017ffc..caed13b7d4b 100644 --- a/vsintegration/src/FSharp.Editor/Diagnostics/UnusedDeclarationsAnalyzer.fs +++ b/vsintegration/src/FSharp.Editor/Diagnostics/UnusedDeclarationsAnalyzer.fs @@ -3,9 +3,10 @@ namespace rec Microsoft.VisualStudio.FSharp.Editor open System +open System.Collections.Generic open System.Collections.Immutable +open System.Diagnostics open System.Threading.Tasks -open System.Collections.Generic open Microsoft.CodeAnalysis open Microsoft.CodeAnalysis.Diagnostics @@ -99,6 +100,7 @@ type internal UnusedDeclarationsAnalyzer() = override __.AnalyzeSemanticsAsync(document, cancellationToken) = asyncMaybe { + do Trace.TraceInformation("{0:n3} (start) UnusedDeclarationsAnalyzer", DateTime.Now.TimeOfDay.TotalSeconds) do! Async.Sleep DefaultTuning.UnusedDeclarationsAnalyzerInitialDelay |> liftAsync // be less intrusive, give other work priority most of the time match getProjectInfoManager(document).TryGetOptionsForEditingDocumentOrProject(document) with | Some options -> diff --git a/vsintegration/src/FSharp.Editor/Diagnostics/UnusedOpensDiagnosticAnalyzer.fs b/vsintegration/src/FSharp.Editor/Diagnostics/UnusedOpensDiagnosticAnalyzer.fs index 64086177a88..cc137a7f913 100644 --- a/vsintegration/src/FSharp.Editor/Diagnostics/UnusedOpensDiagnosticAnalyzer.fs +++ b/vsintegration/src/FSharp.Editor/Diagnostics/UnusedOpensDiagnosticAnalyzer.fs @@ -4,6 +4,7 @@ namespace Microsoft.VisualStudio.FSharp.Editor open System open System.Collections.Immutable +open System.Diagnostics open System.Threading open System.Threading.Tasks @@ -170,6 +171,7 @@ type internal UnusedOpensDiagnosticAnalyzer() = override this.AnalyzeSemanticsAsync(document: Document, cancellationToken: CancellationToken) = asyncMaybe { + do Trace.TraceInformation("{0:n3} (start) UnusedOpensAnalyzer", DateTime.Now.TimeOfDay.TotalSeconds) do! Async.Sleep DefaultTuning.UnusedOpensAnalyzerInitialDelay |> liftAsync // be less intrusive, give other work priority most of the time let! options = getProjectInfoManager(document).TryGetOptionsForEditingDocumentOrProject(document) let! sourceText = document.GetTextAsync() diff --git a/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs b/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs index c206c00793c..85bd8b12a29 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs @@ -59,6 +59,8 @@ type internal FSharpCheckerProvider let solution = workspace.CurrentSolution let documentIds = solution.GetDocumentIdsWithFilePath(fileName) if not documentIds.IsEmpty then + for documentId in documentIds do + Trace.TraceInformation("Requesting Roslyn reanalysis of {0}", documentId) analyzerService.Reanalyze(workspace,documentIds=documentIds) | _ -> () with ex -> @@ -446,6 +448,7 @@ and for referencedSite in ProjectSitesAndFiles.GetReferencedProjectSites (site, this.SystemServiceProvider) do let referencedProjectId = setup referencedSite project.AddProjectReference(ProjectReference referencedProjectId) + workspace.ProjectTracker.AddProject(project) projectId setup (siteProvider.GetProjectSite()) |> ignore diff --git a/vsintegration/src/FSharp.Editor/Options/EditorOptions.fs b/vsintegration/src/FSharp.Editor/Options/EditorOptions.fs index 1f4c2e4b0a4..c282eec090b 100644 --- a/vsintegration/src/FSharp.Editor/Options/EditorOptions.fs +++ b/vsintegration/src/FSharp.Editor/Options/EditorOptions.fs @@ -10,8 +10,8 @@ open OptionsUIHelpers module DefaultTuning = let SemanticColorizationInitialDelay = 0 (* milliseconds *) - let UnusedDeclarationsAnalyzerInitialDelay = 1000 (* milliseconds *) - let UnusedOpensAnalyzerInitialDelay = 2000 (* milliseconds *) + let UnusedDeclarationsAnalyzerInitialDelay = 0 (* 1000 *) (* milliseconds *) + let UnusedOpensAnalyzerInitialDelay = 0 (* 2000 *) (* milliseconds *) let SimplifyNameInitialDelay = 2000 (* milliseconds *) let SimplifyNameEachItemDelay = 5 (* milliseconds *)