From fb44d317a67ae3f27f90314c5d6ce58dc8589d09 Mon Sep 17 00:00:00 2001 From: Jimmy Byrd Date: Fri, 21 Jul 2023 23:11:25 -0400 Subject: [PATCH] Adds more garbage collection settings --- release/package.json | 25 +++++++++++++++++++++++-- src/Core/LanguageService.fs | 11 ++++++++--- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/release/package.json b/release/package.json index 25ea3631..2c78611f 100644 --- a/release/package.json +++ b/release/package.json @@ -532,7 +532,8 @@ "FSharp.fsac.conserveMemory": { "default": false, "description": "Configures FsAutoComplete with settings intended to reduce memory consumption. Requires restart.", - "type": "boolean" + "type": "boolean", + "deprecationMessage": "This setting is deprecated. Use FSharp.fsac.gc.conserveMemory instead." }, "FSharp.fsac.dotnetArgs": { "default": [], @@ -542,6 +543,26 @@ }, "type": "array" }, + "FSharp.fsac.gc.conserveMemory" : { + "default": 1, + "markdownDescription": "Configures the garbage collector to [conserve memory](https://learn.microsoft.com/en-us/dotnet/core/runtime-config/garbage-collector#conserve-memory) at the expense of more frequent garbage collections and possibly longer pause times. [Large Object Heap](https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/large-object-heap) will be compacted automatically if it has too much fragmentation. Requires restart.", + "type": "integer", + "minimum": 0, + "maximum": 9 + }, + "FSharp.fsac.gc.heapCount" : { + "default": 2, + "markdownDescription": "Limits the number of [heaps](https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/fundamentals#the-managed-heap) created by the garbage collector. Applies to server garbage collection only. See [Middle Ground between Server and Workstation GC](https://devblogs.microsoft.com/dotnet/middle-ground-between-server-and-workstation-gc/) for more details. This can allow FSAC to still benefit from Server garbage collection while still limiting the number of heaps. Requires restart.", + "type": "integer", + "required": [ + "FSharp.fsac.gc.server" + ] + }, + "FSharp.fsac.gc.server": { + "default": true, + "markdownDescription": "Configures whether the application uses workstation garbage collection or server garbage collection. See [Workstation vs Server Garbage Collection](https://devblogs.microsoft.com/premier-developer/understanding-different-gc-modes-with-concurrency-visualizer/#workstation-gc-vs-server-gc) for more details. Workstation will use less memory but Server will have more throughput. Requires restart.", + "type": "boolean" + }, "FSharp.fsac.netCoreDllPath": { "default": "", "description": "The path to the \u0027fsautocomplete.dll\u0027, a directory containing TFM-specific versions of fsautocomplete.dll, or a directory containing fsautocomplete.dll. Useful for debugging a self-built FSAC. If a DLL is specified, uses it directly. If a directory is specified and it contains TFM-specific folders (net6.0, net7.0, etc) then that directory will be probed for the best TFM to use for the current runtime. This is useful when working with a local copy of FSAC, you can point directly to the bin/Debug or bin/Release folder and it\u0027ll Just Work. Finally, if a directory is specified and there are no TFM paths, then fsautocomplete.dll from that directory is used. Requires restart.", @@ -1720,4 +1741,4 @@ "url": "https://github.com/ionide/ionide-vscode-fsharp.git" }, "version": "7.8.2" -} \ No newline at end of file +} diff --git a/src/Core/LanguageService.fs b/src/Core/LanguageService.fs index db10d77d..6de1bf8d 100644 --- a/src/Core/LanguageService.fs +++ b/src/Core/LanguageService.fs @@ -632,7 +632,11 @@ Consider: let enableProjectGraph = "FSharp.enableMSBuildProjectGraph" |> Configuration.get false - let conserveMemory = "FSharp.fsac.conserveMemory" |> Configuration.get false + let gcConserveMemory = "FSharp.fsac.gc.conserveMemory" |> Configuration.get 1 + + let gcHeapCount = "FSharp.fsac.gc.heapCount" |> Configuration.get 2 + + let gcServer = "FSharp.fsac.gc.server" |> Configuration.get true let parallelReferenceResolution = "FSharp.fsac.parallelReferenceResolution" |> Configuration.get false @@ -788,8 +792,9 @@ Consider: let fsacEnvVars = [ yield! fsacEnvVars - if conserveMemory then - yield "DOTNET_GCConserveMemory", box "9" + yield "DOTNET_GCHeapCount", box (gcHeapCount.ToString("X")) // Requires hexadecimal value + yield "DOTNET_GCConserveMemory", box gcConserveMemory + yield "DOTNET_GCServer", box gcServer if parallelReferenceResolution then yield "FCS_ParallelReferenceResolution", box "true" ]