Merged
Conversation
e1fd711 to
44fdba2
Compare
Contributor
Author
|
Every time This either saves 1.4MB or 1.9MB of memory according to the benchmarks. I'm not sure whats causing this variance. Timing is inaccurate
|
44fdba2 to
a09b880
Compare
a09b880 to
38fd2ec
Compare
belav
added a commit
that referenced
this pull request
Dec 31, 2025
It appears that `SyntaxNodeComparer` is run after a file is formated, optimisation here may be impactful - Prevent null `Func<T, T, Result>` allocations (still seeing some in the profiler, no idea how to sotp this) - Prevent boxing of `SyntaxTokenList`, `SyntaxNodeOrTokenList` - Use `OrderBy.ToArray` instead of `OrderBy.ToList` - Create `AllSeparatorsButLast` to prevent boxing `SeparatedSyntaxList<SyntaxNode>` and `IEnumerable` creation I have some other idea, but I'm focusing on the unhappy path right now. ### Benchmark (comparing `complexCode`) #### Before | Method | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated | |--------------------------- |---------:|--------:|--------:|----------:|----------:|----------:|----------:| | Default_SyntaxNodeComparer | 229.1 ms | 4.55 ms | 7.60 ms | 5000.0000 | 3000.0000 | 1000.0000 | 40.53 MB | #### After | Method | Mean | Error | StdDev | Gen0 | Gen1 | Allocated | |--------------------------- |---------:|--------:|--------:|----------:|----------:|----------:| | Default_SyntaxNodeComparer | 187.4 ms | 3.51 ms | 7.64 ms | 3000.0000 | 1000.0000 | 31.39 MB | Co-authored-by: Bela VanderVoort <twobitbela@gmail.com>
belav
added a commit
that referenced
this pull request
Feb 20, 2026
It appears that `SyntaxNodeComparer` is run after a file is formated, optimisation here may be impactful - Prevent null `Func<T, T, Result>` allocations (still seeing some in the profiler, no idea how to sotp this) - Prevent boxing of `SyntaxTokenList`, `SyntaxNodeOrTokenList` - Use `OrderBy.ToArray` instead of `OrderBy.ToList` - Create `AllSeparatorsButLast` to prevent boxing `SeparatedSyntaxList<SyntaxNode>` and `IEnumerable` creation I have some other idea, but I'm focusing on the unhappy path right now. ### Benchmark (comparing `complexCode`) #### Before | Method | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated | |--------------------------- |---------:|--------:|--------:|----------:|----------:|----------:|----------:| | Default_SyntaxNodeComparer | 229.1 ms | 4.55 ms | 7.60 ms | 5000.0000 | 3000.0000 | 1000.0000 | 40.53 MB | #### After | Method | Mean | Error | StdDev | Gen0 | Gen1 | Allocated | |--------------------------- |---------:|--------:|--------:|----------:|----------:|----------:| | Default_SyntaxNodeComparer | 187.4 ms | 3.51 ms | 7.64 ms | 3000.0000 | 1000.0000 | 31.39 MB | Co-authored-by: Bela VanderVoort <twobitbela@gmail.com>
belav
added a commit
that referenced
this pull request
Mar 12, 2026
It appears that `SyntaxNodeComparer` is run after a file is formated, optimisation here may be impactful - Prevent null `Func<T, T, Result>` allocations (still seeing some in the profiler, no idea how to sotp this) - Prevent boxing of `SyntaxTokenList`, `SyntaxNodeOrTokenList` - Use `OrderBy.ToArray` instead of `OrderBy.ToList` - Create `AllSeparatorsButLast` to prevent boxing `SeparatedSyntaxList<SyntaxNode>` and `IEnumerable` creation I have some other idea, but I'm focusing on the unhappy path right now. ### Benchmark (comparing `complexCode`) #### Before | Method | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated | |--------------------------- |---------:|--------:|--------:|----------:|----------:|----------:|----------:| | Default_SyntaxNodeComparer | 229.1 ms | 4.55 ms | 7.60 ms | 5000.0000 | 3000.0000 | 1000.0000 | 40.53 MB | #### After | Method | Mean | Error | StdDev | Gen0 | Gen1 | Allocated | |--------------------------- |---------:|--------:|--------:|----------:|----------:|----------:| | Default_SyntaxNodeComparer | 187.4 ms | 3.51 ms | 7.64 ms | 3000.0000 | 1000.0000 | 31.39 MB | Co-authored-by: Bela VanderVoort <twobitbela@gmail.com>
belav
added a commit
that referenced
this pull request
Apr 4, 2026
It appears that `SyntaxNodeComparer` is run after a file is formated, optimisation here may be impactful - Prevent null `Func<T, T, Result>` allocations (still seeing some in the profiler, no idea how to sotp this) - Prevent boxing of `SyntaxTokenList`, `SyntaxNodeOrTokenList` - Use `OrderBy.ToArray` instead of `OrderBy.ToList` - Create `AllSeparatorsButLast` to prevent boxing `SeparatedSyntaxList<SyntaxNode>` and `IEnumerable` creation I have some other idea, but I'm focusing on the unhappy path right now. ### Benchmark (comparing `complexCode`) #### Before | Method | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated | |--------------------------- |---------:|--------:|--------:|----------:|----------:|----------:|----------:| | Default_SyntaxNodeComparer | 229.1 ms | 4.55 ms | 7.60 ms | 5000.0000 | 3000.0000 | 1000.0000 | 40.53 MB | #### After | Method | Mean | Error | StdDev | Gen0 | Gen1 | Allocated | |--------------------------- |---------:|--------:|--------:|----------:|----------:|----------:| | Default_SyntaxNodeComparer | 187.4 ms | 3.51 ms | 7.64 ms | 3000.0000 | 1000.0000 | 31.39 MB | Co-authored-by: Bela VanderVoort <twobitbela@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It appears that
SyntaxNodeCompareris run after a file is formated, optimisation here may be impactfulFunc<T, T, Result>allocations (still seeing some in the profiler, no idea how to sotp this)SyntaxTokenList,SyntaxNodeOrTokenListOrderBy.ToArrayinstead ofOrderBy.ToListAllSeparatorsButLastto prevent boxingSeparatedSyntaxList<SyntaxNode>andIEnumerablecreationI have some other idea, but I'm focusing on the unhappy path right now.
Benchmark (comparing
complexCode)Before
After