Improve processing of the powershell built-in type data from 'types.ps1xml', 'typesV3.ps1xml' and 'GetEvent.types.ps1xml'#10898
Conversation
src/System.Management.Automation/engine/GetEvent_Types_Ps1Xml.cs
Outdated
Show resolved
Hide resolved
|
@PoshChan Please retry windows |
|
@daxian-dbw, successfully started retry of |
src/System.Management.Automation/engine/GetEvent_Types_Ps1Xml.cs
Outdated
Show resolved
Hide resolved
…Data representation.
…o create PSPropertySet
de6525e to
057cac0
Compare
|
@PoshChan Please retry Linux and macOS |
|
@daxian-dbw, I do not understand the build target(s) |
|
@PoshChan Please retry Linux |
|
@PoshChan Please retry macos |
|
@daxian-dbw, successfully started retry of |
|
@daxian-dbw, successfully started retry of |
|
Almost 90% of the CodeFactor issues are existing ones in |
iSazonov
left a comment
There was a problem hiding this comment.
It would be great to add tests to explicitly cover the code.
src/System.Management.Automation/engine/TypeTable_GetEvent_Types_Ps1Xml.cs
Show resolved
Hide resolved
src/System.Management.Automation/engine/TypeTable_GetEvent_Types_Ps1Xml.cs
Show resolved
Hide resolved
|
@PoshChan Please retry macOS |
|
@daxian-dbw, successfully started retry of |
|
@daxian-dbw I expect that the PR reduce significantly allocations. Can you share PerfView info in the PR description if you have? |
|
@iSazonov I added the PrefView screenshot. With the changes in this PR, the memory allocation is less in general. |
|
Is it not possible to speed up the public api? One of the motivations for using the public api was to enable external modules to load their types in a similar manner. We could share the source to the tool I wrote to convert a ps1xml file to the public C# api. |
@lzybkr Are you referring to the I strongly agree it's important that the |
|
@daxian-dbw Have you reviewed CodeFactor issues? All of them in old code? |
|
@adityapatwardhan I have reviewed all CodeFactory issues. 90% of them are about the existing code in |
|
🎉 Handy links: |
PR Summary
Improve processing of the powershell built-in type data from
types.ps1xml,typesV3.ps1xmlandGetEvent.types.ps1xml.A few changes to speed up the processing of the built-in PowerShell type data.
TypeTable.csa little to make it more efficiently at collection allocations.ProcessStandardMembers, which takes an instance ofPSMemberInfoInternalCollection<PSMemberInfo>directly that contains the standard members.ProcessTypeConverterandProcessTypeAdapterfromProcessTypeDataToAdd.PSMemberSetandPSPropertySetthat are used fromTypeTable, which skip argument checks and reuse the passed in collection argument.TypeTablewithout going through theTypeDatarepresentation as the intermediate step.TypeDataobjects constructed inTypes_Ps1Xml,TypesV3_Ps1XmlandGetEvent_Types_Ps1Xml. Then theTypeDataobjects are processed byTypeTable.ProcessTypeDataToAddone by one.TypeDataobjects fromTypes_Ps1Xml.Get(),TypesV3_Ps1Xml.Get()andGetEvent_Types_Ps1Xml.Get()and generate the code that directly register the type information intoTypeTable, so we can get rid of the intermediate step.TypeTable_Types_Ps1Xml.cs,TypeTable_Types_TypesV3_Ps1Xml.csandTypeTable_GetEvent_Types_Ps1Xml.TypeTableis now declared as partial class, and spread inTypeTable.csand the aforementioned 3 files.ValueFactorydelegate instance instead of create a new one for every duplicate one.After this change, creating a default
TypeTableinstance those 3 built-in PowerShell type files takes about 47% less time at a stable state.Runspace.Open()is about 10% faster with the change at a stable state:Memory allocation comparison
The profiling was taken using
pwsh.exe -noprofile -c exit. The left side was built from master branch before this PR. The right side was built with the changes in this PR.As the image below shows, the right side has less memory allocations in general.
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.