Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

High cpu usage when parsing scripts that include [ordered] #17308

Copy link
Copy link
@Sjark

Description

@Sjark
Issue body actions

Prerequisites

Steps to reproduce

We are parsing multiple powershell scripts in parallel using Parser.ParseInput but are having issues with perf when the scrips being parsed includes multiple [ordered] attributes/types.

The parser starts to use 100% cpu, and it takes a long time for the parsing to complete.

Repro here

The console app above has 2 identical powershell scripts included, the only difference is that on of them has a bunch of [ordered] before the hashtable assignments.

The one without [ordered] completes almost instantly, while the one with [ordered] takes some time and uses a lot of cpu.

Expected behavior

Parsing to complete in about the same time with both scripts.

Actual behavior

Parsing takes a lot longer and uses a lot more resources when the script includes [ordered].

Error details

The error seems to be related to LookForTypeInAssemblies method within the TypeResolver.cs:68

Every time it finds a [ordered] in the script it goes through all loaded assemblies to try and find the matching type, but since [ordered] is not actually a type (just a helper for creating System.Collections.Specialized.OrderedDictionary) the method returns null, and will search again the next time it finds an [ordered] attribute.

I think there should either be a cache for types that did not match any assemblies, so that it doesn't have to look through the same assemblies for the same type multiple times, or there should be a special case for [ordered] so that it does not even try to search through the assemblies for it.

Environment data

We are using nuget package: System.Management.Automation version 7.2.3

Visuals

No response

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Engine-Performancecore PowerShell engine, interpreter, and runtime performancecore PowerShell engine, interpreter, and runtime performance

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.