- Notifications
You must be signed in to change notification settings - Fork407
Improve performance of UseConsistentIndentation even more > another 10% speedup for formatter#1461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…peedup for formatter
rjmholt left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Really awesome! Honestly I think removing LINQ use generally from PSSA could provide performance boosts across the board
Uh oh!
There was an error while loading.Please reload this page.
Co-Authored-By: Robert Holt <rjmholt@gmail.com>
bergmeister commentedApr 24, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Now, Linq consumers 18.5% of the CPU (but this include everything including SMA, therefore it is hard to say how much of that stems from PSSA only), so there is some potential but it's not as big as one would think. |

PR Summary
This now reduced the total CPU time of this rule to only from 12% to 2% on a run of a warm run Invoke-Formatter (compared to current master with the 3 recent speed improvements). Improvements will be smaller for smaller scripts as this was tested against PowerShell's build.psm1 3000+ line module (same as with previous PRs), therefore it rather ensures performance scales much better.
Basically, because the rule goes over every token, any looping, inside it, even when it is only performed for each line as in this case, it has a measurable impact (both in the profiler but also actual timings). Therfore making sure we iterate over fewer items in the
pipelineAstslist, by having a minimum index, which increases with each line and breaking the loop early if the line number is bigger than the current line. This is possible because the queried functionPositionIsEqualonly returns pipeline asts on the same line.PR Checklist
.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.