Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to disable server gc #7155

Merged
merged 4 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
15 changes: 10 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1462,17 +1462,22 @@
"default": null,
"description": "%configuration.dotnet.server.crashDumpPath%"
},
"dotnet.server.suppressLspErrorToasts": {
"type": "boolean",
"default": false,
"description": "%configuration.dotnet.server.suppressLspErrorToasts%"
},
"dotnet.server.useServerGC": {
"type": "boolean",
"default": true,
"description": "%configuration.dotnet.server.useServerGC%"
},
"dotnet.enableXamlTools": {
"scope": "machine-overridable",
"type": "boolean",
"default": true,
"description": "%configuration.dotnet.enableXamlTools%"
},
"dotnet.server.suppressLspErrorToasts": {
"type": "boolean",
"default": false,
"description": "%configuration.dotnet.server.suppressLspErrorToasts%"
},
"dotnet.projects.binaryLogPath": {
"scope": "machine-overridable",
"type": "string",
Expand Down
4 changes: 3 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
"configuration.dotnet.server.trace": "Sets the logging level for the language server",
"configuration.dotnet.server.extensionPaths": "Override for path to language server --extension arguments",
"configuration.dotnet.server.crashDumpPath": "Sets a folder path where crash dumps are written to if the language server crashes. Must be writeable by the user.",
"configuration.dotnet.enableXamlTools": "Enables XAML tools when using C# Dev Kit",
"configuration.dotnet.server.suppressLspErrorToasts": "Suppresses error toasts from showing up if the server encounters a recoverable error.",
"configuration.dotnet.server.useServerGC": "Configure the language server to use .NET server garbage collection. Server garbage collection generally provides better performance at the expensive of higher memory consumption.",
"configuration.dotnet.enableXamlTools": "Enables XAML tools when using C# Dev Kit",
"configuration.dotnet.enableXamlToolsPreview": "[Experimental] Enables XAML tools when using C# Dev Kit",
dibarbet marked this conversation as resolved.
Show resolved Hide resolved
"configuration.dotnet.projects.enableAutomaticRestore": "Enables automatic NuGet restore if the extension detects assets are missing.",
"configuration.dotnet.projects.binaryLogPath": "Sets a path where MSBuild binary logs are written to when loading projects, to help diagnose loading errors.",
"configuration.dotnet.preferCSharpExtension": "Forces projects to load with the C# extension only. This can be useful when using legacy project types that are not supported by C# Dev Kit. (Requires window reload)",
Expand Down
13 changes: 12 additions & 1 deletion src/lsptoolshost/roslynLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,9 @@ export class RoslynLanguageServer {
args.push('--extension', extensionPath);
}

if (logLevel && [Trace.Messages, Trace.Verbose].includes(this.GetTraceLevel(logLevel))) {
const isTraceLogLevel = logLevel && [Trace.Messages, Trace.Verbose].includes(this.GetTraceLevel(logLevel));

if (isTraceLogLevel) {
_channel.appendLine(`Starting server at ${serverPath}`);
}

Expand All @@ -616,6 +618,15 @@ export class RoslynLanguageServer {

args.push('--extensionLogDirectory', context.logUri.fsPath);

const env = dotnetInfo.env;
if (!languageServerOptions.useServerGC) {
// The server by default uses serverGC, if the user opts out we need to set the environment variable to disable it.
env.DOTNET_gcServer = '0';
if (isTraceLogLevel) {
_channel.appendLine('ServerGC disabled');
}
}

let childProcess: cp.ChildProcessWithoutNullStreams;
const cpOptions: cp.SpawnOptionsWithoutStdio = {
detached: true,
Expand Down
5 changes: 5 additions & 0 deletions src/shared/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export interface LanguageServerOptions {
readonly componentPaths: { [key: string]: string } | null;
readonly enableXamlTools: boolean;
readonly suppressLspErrorToasts: boolean;
readonly useServerGC: boolean;
}

export interface RazorOptions {
Expand Down Expand Up @@ -410,6 +411,9 @@ class LanguageServerOptionsImpl implements LanguageServerOptions {
public get suppressLspErrorToasts() {
return readOption<boolean>('dotnet.server.suppressLspErrorToasts', false);
}
public get useServerGC() {
return readOption<boolean>('dotnet.server.useServerGC', true);
}
}

class RazorOptionsImpl implements RazorOptions {
Expand Down Expand Up @@ -508,4 +512,5 @@ export const LanguageServerOptionsThatTriggerReload: ReadonlyArray<keyof Languag
'preferCSharpExtension',
'componentPaths',
'enableXamlTools',
'useServerGC',
];
Loading