microsoft / microsoft/vs-threading

VSTHRD002 and VSTHRD010 - Performance issues?

Open
#1,526 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

analyzers
Dominant language
C#
Stars
1k
Forks
160
Avg merge
1d 12h
Merged PRs (30d)
28

Description

I would like to share my observation regarding build performance when using the VSTHRD002UseJtfRunAnalyzer and VSTHRD010MainThreadUsageAnalyzer.

Observation

We observe that the build takes significantly longer than expected in a project that uses:

  • Microsoft.VisualStudio.Threading.Analyzers
  • .NET 10
  • EF Core 10 with Code Migrations.

Build duration comparison (with analyzers vs. no analyzers):

dotnet build~58 seconds.
dotnet build -p:RunAnalyzers=false~10 seconds.

Analyzer timing from MSBuild.exe /v:d /p:reportanalyzer=true shows

Time (s)    %   Analyzer
  668,239   99   Microsoft.VisualStudio.Threading.Analyzers.CSharp, Version=17.14.15.42505, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
  370,871   55      Microsoft.VisualStudio.Threading.Analyzers.VSTHRD010MainThreadUsageAnalyzer (VSTHRD010)
  290,486   43      Microsoft.VisualStudio.Threading.Analyzers.VSTHRD002UseJtfRunAnalyzer (VSTHRD002)
  3,736   <1      Microsoft.VisualStudio.Threading.Analyzers.VSTHRD103UseAsyncOptionAnalyzer (VSTHRD103)
  1,340   <1      Microsoft.VisualStudio.Threading.Analyzers.CSharpVSTHRD110ObserveResultOfAsyncCallsAnalyzer (VSTHRD110)
  1,252   <1      Microsoft.VisualStudio.Threading.Analyzers.CSharpVSTHRD012SpecifyJtfWhereAllowed (VSTHRD012)
  0,196   <1      Microsoft.VisualStudio.Threading.Analyzers.CSharpVSTHRD109AvoidAssertInAsyncMethodsAnalyzer (VSTHRD109)

The two analyzers (VSTHRD010 and VSTHRD002) account for the large majority of analyzer execution time.

Project details

  • The EF Core model contains ~100 model entities (SQL Server tables) in a Model project.
  • An Entity contains DbContext and 175 database migrations.
  • Each migration consist of two files:
    • the migration itself
    • and the "*.Designer.cs" file.
  • The designer files in project grow in time from ~60 kB to ~180 kB.
  • Total size of designer files in Entity project is 22,16 MB.
  • Total size of code files in Entity project is 22,86 MB.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported MSBuild analyzer timing and compare dotnet build with dotnet build -p:RunAnalyzers=false in a project containing the described EF Core migrations and large designer files. Investigate VSTHRD010 and VSTHRD002 first; done should mean identifying the source of their disproportionate cost and documenting or validating a concrete improvement.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
devtools, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.