Skip to content

NativeRuntimeEventSource is too slow initialized #60963

Closed

Description

@iSazonov

We have moved PowerShell 7.2 RC to latest pre-RTM .Net 6.0 build and I see 20% perf win in startup scenario vs PowerShell 7.1 based on .Net 5.0. Thanks .Net team for great work!

Nevertheless I still see in PerfView that System.Diagnostics.Tracing.NativeRuntimeEventSource::.cctor() is noticeable slow - in my test it is 12% in PowerShell startup scenario. (Trace file PerfViewData-7.2-Startup-Exit.speedscope.json.zip )
It seems a root of the issue System.Attribute::GetCustomAttributes(System.Reflection.MemberInfo, System.Type, System.Boolean) is slow.

There is related issue #44713. Too bad it wasn't fixed in the #45121. :-(

Activity

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Oct 28, 2021
  2. stephentoub commented on Oct 28, 2021

    @stephentoub
    Member

    There's a catch-22 here: the costs you're seeing mostly only show up as part of running a trace, as it's the act of enabling ETW that's causing the EventSource to generate and output its manifest, which in turn is what's triggering it to use reflection to walk itself. So these costs generally don't show up in real usage and only appear because you're looking at it.

    The answer here isn't to try to make getting attributes faster, it's to avoid needing to do it at all. #49659 tracks that.
    Also #43390.

  3. iSazonov commented on Oct 28, 2021

    @iSazonov
    ContributorAuthor

    PowerShell uses System.Diagnostics.Tracing at startup too and I hope it can benefit if GetCustomAttributes will be faster.
    I doubt that it is possible to completely avoid dependence on custom attributes in PowerShell but I hope we will benefit directly and indirectly from source generators in the area too.

  4. stephentoub commented on Oct 28, 2021

    @stephentoub
    Member

    PowerShell uses System.Diagnostics.Tracing at startup too and I hope it can benefit if GetCustomAttributes will be faster.

    Do you mean it has its own EventSource? That would be covered by an EventSource source generator as well.

  5. iSazonov commented on Oct 28, 2021

    @iSazonov
    ContributorAuthor

    Yes, 3 at least. And yes, I hope PowerShell could benefit from source generators.

  6. stephentoub commented on Oct 28, 2021

    @stephentoub
    Member

    Right. That's covered by the other issues. I'll close this then.

  7. ghost locked as resolved and limited conversation to collaborators on Nov 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions