Skip to content

Rewrite analyzer using Roslyn Operations for speed and cross-language support #19648

Closed

Description

@toshke994

I am upgrading our project from .netcore 2.1 to 3.1.1. (and EF core with it). One of the projects that doesn't use EF at all references another project that does reference it, and as a result building the first project takes around 30 minutes.

I have isolated the problem in the sample app.
Build time while referencing Microsoft.EntityFrameworkCore.Analyzers (3.1.1) ~10000ms
Build time without referencing Microsoft.EntityFrameworkCore.Analyzers (3.1.1) ~200ms

Steps to reproduce

BuildSpeedTest.zip

Build a provided solution while referencing Microsoft.EntityFrameworkCore.Analyzers (3.1.1) and it should take ~10000ms (±1s)
Build without referencing Microsoft.EntityFrameworkCore.Analyzers (3.1.1), or disable running analyzers during the build and it should take ~200ms

Reducing the size of StaticArray will reduce the build time and vice versa.

Further technical details

EF Core version: 3.1.1
Target framework: .NET Core 3.1
Operating system: Windows 10 Pro (Version 1909)
IDE: Visual Studio 2019 16.4.3

Activity

  1. ajcvickers commented on Jan 21, 2020

    @ajcvickers
    Contributor

    Related to #18618 and possibly #19597

    /cc @roji

  2. ajcvickers commented on Jan 29, 2020

    @ajcvickers
    Contributor

    @roji I see a difference in build times on my machine, although it's not nearly as pronounced as reported above. I have again captured and attached diagnostic build logs. It doesn't look to me that this is specific to the EF analyzers, but more related to how the build operates with/without analyzers turned on. However, I could be totally wrong!

    Could you take a look at the logs and then follow up with your analyzer contacts?

    with_analyzers.txt
    without_analyzers.txt

  3. ajcvickers commented on Jan 29, 2020

    @ajcvickers
    Contributor

    Attaching binlogs here too.

    binlogs.zip

  4. roji commented on Jan 29, 2020

    @roji
    Member

    @ajcvickers thanks for the work... I'll follow up on this.

  5. roji commented on Jan 31, 2020

    @roji
    Member

    Note: will continue investigation in #19597 assuming this is a dup until we see otherwise.

  6. roji commented on Feb 3, 2020

    @roji
    Member

    This is not a dup of #19597, and I repro a x10 degradation in build time (with --no-incremental --no-restore). I'll investigate further.

  7. self-assigned this
    on Feb 3, 2020
  8. added this to the 5.0.0 milestone on Feb 7, 2020
  9. changed the title [-]Adding Microsoft.EntityFrameworkCore.Analyzers (3.1.1) slows down build significantly[/-] [+]Rewrite analyzer using Roslyn Operations for speed and cross-language support[/+] on Aug 8, 2020
  10. roji commented on Aug 8, 2020

    @roji
    Member

    As suggested by @mvasani and @sharwell, rewriting the analyzer using Operations brought the build time from around 10 seconds to 2, roughly the same as without the analyzer. Thanks!

  11. added a commit that references this issue on Aug 8, 2020
    e5b877e
  12. 1 remaining item

  13. added a commit that references this issue on Aug 8, 2020
    cf3db52
  14. added a commit that references this issue on Aug 16, 2020
    bc68329
  15. modified the milestones: 5.0.0, on Aug 16, 2020
  16. modified the milestones: , 5.0.0 on Nov 7, 2020
  17. added theissue type on Jun 15, 2025
  18. marked Analyzer memory issue #23010 as a duplicate of this issue on Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions