Skip to content

perf: refactor ignore logic to prevent duplicate work and allocations - #1898

Open
TimothyMakkison wants to merge 1 commit into
belav:mainfrom
TimothyMakkison:perf_ignore
Open

perf: refactor ignore logic to prevent duplicate work and allocations#1898
TimothyMakkison wants to merge 1 commit into
belav:mainfrom
TimothyMakkison:perf_ignore

Conversation

@TimothyMakkison

@TimothyMakkison TimothyMakkison commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Builds on #1897, supports #1893

IgnoreList

  • Convert alwaysIgnoredRules to use IgnoreRule[], avoiding the cost of compiling the regex for each construction of IgnoreList
  • Instead of concatenating alwaysIgnoredRules and the parsed rules we simply evaluate one after the other to avoid allocating a List or larger array

IgnoreRule

StringExtensions

Benchmarks - from #1896

Note that timing isn't very accurate due to low iteration count

Before

Method Mean Error StdDev Gen0 Gen1 Gen2 Allocated
FormatCli 737.4 ms 116.9 ms 30.36 ms 6000.0000 - - 57.53 MB
CheckFiles 43,895.1 ms 639.7 ms 98.99 ms 53000.0000 52000.0000 2000.0000 459.28 MB

After

Method Mean Error StdDev Gen0 Gen1 Gen2 Allocated
FormatCli 643.6 ms 63.36 ms 16.46 ms 2000.0000 - - 24.9 MB
CheckFiles 33,135.1 ms 842.61 ms 130.39 ms 45000.0000 44000.0000 2000.0000 393.78 MB

Pretty large performance gains for FormatCli, curious to see how large the real world impact will be.

@TimothyMakkison

TimothyMakkison commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

After #1888 it would be worth switching most of these methods over to using ReadOnlySpan<char> while using GetAlternateLookup.
In StringExtensions.NormalisePath should be changed to accept ReadOnlySpan<char>, checking for : either allocating a new string or returning a trimmed value.
There are other areas where SearchValues could replace string[] for lookups

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant