Skip to content

Address profiling review feedback #8374

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

Merged
merged 4 commits into from
Jul 9, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions SUPPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ If the language server crashes, general logs are often helpful for diagnosing th

When investigating performance issues, we may request a performance trace of the language server to diagnose what is causing the problem. These are typically taken via [dotnet-trace](https://learn.microsoft.com/en-us/dotnet/core/diagnostics/dotnet-trace) (a cross platform tool to collect performance traces of .NET processes)

The C# extension has a built in command, `csharp.recordTrace` to help with trace collection. This command will install `dotnet-trace` as a global tool and invoke it against the language server.
The C# extension has a built in command, `csharp.recordLanguageServerTrace` to help with trace collection. This command will install `dotnet-trace` as a global tool and invoke it against the language server.

1. Invoke the `csharp.recordTrace` command
1. Invoke the record language server trace command
![alt text](docs/recordTraceCommand.png)
2. Select the folder to save the trace.
3. Accept the default trace arguments, or change them if requested
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1889,8 +1889,8 @@
"enablement": "dotnet.server.activationContext == 'OmniSharp'"
},
{
"command": "csharp.recordTrace",
"title": "%command.csharp.recordTrace%",
"command": "csharp.recordLanguageServerTrace",
"title": "%command.csharp.recordLanguageServerTrace%",
"category": "CSharp",
"enablement": "dotnet.server.activationContext == 'Roslyn' || dotnet.server.activationContext == 'RoslynDevKit'"
},
Expand Down
2 changes: 1 addition & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"command.csharp.attachToProcess": "Attach to a .NET 5+ or .NET Core process",
"command.csharp.reportIssue": "Report an issue",
"command.csharp.showDecompilationTerms": "Show the decompiler terms agreement",
"command.csharp.recordTrace": "Record a performance trace of the C# Language Server",
"command.csharp.recordLanguageServerTrace": "Record a performance trace of the C# Language Server",
"command.extension.showRazorCSharpWindow": "Show Razor CSharp",
"command.extension.showRazorHtmlWindow": "Show Razor Html",
"command.razor.reportIssue": "Report a Razor issue",
Expand Down
14 changes: 7 additions & 7 deletions src/lsptoolshost/profiling/profiling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function registerTraceCommand(
outputChannel: vscode.LogOutputChannel
): void {
context.subscriptions.push(
vscode.commands.registerCommand('csharp.recordTrace', async () => {
vscode.commands.registerCommand('csharp.recordLanguageServerTrace', async () => {
await vscode.window.withProgress(
{
location: vscode.ProgressLocation.Notification,
Expand Down Expand Up @@ -86,9 +86,9 @@ async function executeDotNetTraceCommand(
throw new Error(vscode.l10n.t('Language server process not found, ensure the server is running.'));
}

let traceFolder: string | undefined = '';
let traceFolderUri: vscode.Uri | undefined;
if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders?.length >= 1) {
traceFolder = vscode.workspace.workspaceFolders[0].uri.fsPath;
traceFolderUri = vscode.workspace.workspaceFolders[0].uri;
}

// Prompt the user for the folder to save the trace file
Expand All @@ -97,7 +97,7 @@ async function executeDotNetTraceCommand(
canSelectFiles: false,
canSelectFolders: true,
canSelectMany: false,
defaultUri: traceFolder ? vscode.Uri.file(traceFolder) : undefined,
defaultUri: traceFolderUri ? traceFolderUri : undefined,
openLabel: vscode.l10n.t('Select Trace Folder'),
title: vscode.l10n.t('Select Folder to Save Trace File'),
});
Expand All @@ -107,7 +107,7 @@ async function executeDotNetTraceCommand(
return;
}

traceFolder = uris[0].fsPath;
const traceFolder = uris[0].fsPath;

if (!fs.existsSync(traceFolder)) {
throw new Error(vscode.l10n.t(`Folder for trace file {0} does not exist`, traceFolder));
Expand All @@ -129,14 +129,14 @@ async function executeDotNetTraceCommand(
return;
}

const terminal = await getOrCreateTerminal(traceFolder, outputChannel);

const dotnetTraceInstalled = await verifyOrAcquireDotnetTrace(traceFolder, progress, outputChannel);
if (!dotnetTraceInstalled) {
// Cancelled or unable to install dotnet-trace
return;
}

const terminal = await getOrCreateTerminal(traceFolder, outputChannel);

const args = ['collect', ...userArgs.split(' ')];

progress.report({ message: vscode.l10n.t('Recording trace...') });
Expand Down
Loading