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

run analyzers on multiple threads if allowed to #2285

Merged
merged 23 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
37b2fb0
run analyzers on multiple threads if allowed to
TomasEkeli Dec 2, 2021
f445915
Update src/OmniSharp.Shared/Options/RoslynExtensionsOptions.cs
TomasEkeli Dec 3, 2021
5733124
Merge branch 'master' into master
TomasEkeli Dec 3, 2021
fbfd7c0
use the new name of the option
TomasEkeli Dec 3, 2021
cb3a4fc
parallelize the csharp diagnostic worker
TomasEkeli Dec 3, 2021
a7c8c04
rename option
TomasEkeli Dec 3, 2021
145a904
set default timeout wait time for analysis to 30s
TomasEkeli Dec 3, 2021
34f8150
Merge branch 'master' into master
TomasEkeli Dec 4, 2021
1a5a5fe
Merge branch 'master' into master
TomasEkeli Dec 6, 2021
01010e5
really fix the build-error
TomasEkeli Dec 6, 2021
88419d2
Merge branch 'master' into master
TomasEkeli Dec 7, 2021
280f4a7
Merge branch 'OmniSharp:master' into master
TomasEkeli Dec 10, 2021
f1440fd
Merge branch 'master' into master
TomasEkeli Dec 17, 2021
92e1769
Improves concurrent execution of background Roslys analyzers
DaRosenberg Dec 19, 2021
1108e4c
Improved progress event code
DaRosenberg Dec 19, 2021
fb65560
send analyzer event on every percentage increase
Dec 19, 2021
5d7798f
Added parallelization for non-queue-based project analysis
DaRosenberg Dec 19, 2021
e982ab7
Fixed a potential race condition in diagnostics emission
DaRosenberg Dec 19, 2021
d4a582f
Removed duplicated code
DaRosenberg Dec 19, 2021
fd25217
totally unrelated, but irritating
Jan 4, 2022
3bd9fd6
Merge branch 'master' into master
JoeRobich Jan 12, 2022
c191ee7
Merge branch 'master' into master
JoeRobich Jan 12, 2022
21be466
Merge branch 'master' into master
JoeRobich Jan 20, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,33 @@ private async Task Worker(AnalyzerWorkType workType)
.GroupBy(x => x.projectId, x => x.documentId)
.ToImmutableArray();

var analyzerTasks = new List<Task>();
var throttler = new SemaphoreSlim(_options.RoslynExtensionsOptions.ThreadsToUseForAnalyzers);
foreach (var projectGroup in currentWorkGroupedByProjects)
{
var projectPath = solution.GetProject(projectGroup.Key).FilePath;

EventIfBackgroundWork(workType, projectPath, ProjectDiagnosticStatus.Started);

await AnalyzeAndReport(solution, projectGroup);

EventIfBackgroundWork(workType, projectPath, ProjectDiagnosticStatus.Ready);
await throttler.WaitAsync();
analyzerTasks.Add(
Task.Run(async () =>
{
try
{
EventIfBackgroundWork(workType, projectPath, ProjectDiagnosticStatus.Started);

await AnalyzeAndReport(solution, projectGroup);

EventIfBackgroundWork(workType, projectPath, ProjectDiagnosticStatus.Ready);
}
finally
{
throttler.Release();
}
}
)
);
}
await Task.WhenAll(analyzerTasks);

_workQueue.WorkComplete(workType);

Expand Down
3 changes: 3 additions & 0 deletions src/OmniSharp.Shared/Options/RoslynExtensionsOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public class RoslynExtensionsOptions : OmniSharpExtensionsOptions
public bool EnableImportCompletion { get; set; }
public bool EnableAsyncCompletion { get; set; }
public int DocumentAnalysisTimeoutMs { get; set; } = 10 * 1000;
public int ThreadsToUseForAnalyzers { get; set; } = Environment.ProcessorCount == 1
? 1
: Environment.ProcessorCount / 2;
TomasEkeli marked this conversation as resolved.
Show resolved Hide resolved
}

public class OmniSharpExtensionsOptions
Expand Down