Skip to content

[3.0] Improve generator performance#2567

Merged
Exanite merged 25 commits intodotnet:develop/3.0from
Exanite:feature/performance
Apr 18, 2026
Merged

[3.0] Improve generator performance#2567
Exanite merged 25 commits intodotnet:develop/3.0from
Exanite:feature/performance

Conversation

@Exanite
Copy link
Copy Markdown
Member

@Exanite Exanite commented Apr 13, 2026

Summary of the PR

This branch will be where I investigate performance improvements to the Silk 3.0 bindings generator.

Related issues, Discord discussions, or proposals

Discord thread for discussing development: https://discord.com/channels/521092042781229087/1493337581805371432

Further Comments

Tasks

  • Update ClangSharp
    • Decision: Going to move this to [3.0] Update SDL #2570
    • This is because updating ClangSharp required updating SDL... and that caused further build problems
  • Optimize renamer
    • Track relevant identifiers and only resolve symbols for relevant identifiers instead of for all identifiers
  • Optimize PrettifyNames
    • Optimize document rename path conflict detection
  • Consider removing NormalizeWhitespace calls where possible
  • Investigate ContainsAny calls, particularly when called by TryParseNativeTypeName. This shows up as a hotspot during profiling.
    • Not worth optimizing (will improve only by ~100 ms and worsens code maintainability)
    • Also likely to not affect the Microsoft bindings
  • Consider removing ModCSharpSyntaxRewriter
  • Regenerate all bindings on Windows to ensure no changes

Exanite added 12 commits April 14, 2026 19:08
These were written before I installed the CSharpier plugin so they were not formatted.
GetTypeInfo should be unnecessary since it gets the type of an expression.

For non-type expressions (eg: `5` is an int), this isn't useful for us.
This is arguably an indirect reference to int, but the current Silk generator only cares about modifying direct references.

For type expressions (eg: `int` refers to int), GetSymbolInfo will also return the same symbol.
*Roslyn already caches this internally. This is mainly for avoiding the async method call.
Difference is probably not measurable, but theoretically this is faster.
Conflict checking was O(n), now it is O(1).
This is to prevent false negatives from mismatched path formats.
@Exanite Exanite force-pushed the feature/performance branch from a934c2b to 878a90f Compare April 14, 2026 23:09
Exanite added 9 commits April 16, 2026 17:21
(cherry picked from commit 6b12c69)
…sync

This change caused incorrect behavior since the document ids can come from projects other than the source project (namely the test project).
This broken when semantic models were requested for test project documents from the source project compilation.
@Exanite Exanite force-pushed the feature/performance branch from 9ab6f5b to 07e05f0 Compare April 17, 2026 22:07
Copy link
Copy Markdown
Member Author

@Exanite Exanite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self code review complete. My review comments point out why things are changed, but the code should make sense without them.

I've also regenerated the bindings using Windows to verify that no output changes have occurred.

Comment thread sources/SilkTouch/SilkTouch/Profiling/ProfilingScope.cs
Comment thread sources/SilkTouch/SilkTouch/Mods/TransformHandles.cs
Comment thread sources/SilkTouch/SilkTouch/Mods/PrettifyNames.cs
Comment thread sources/SilkTouch/SilkTouch/Mods/PrettifyNames.cs
Comment thread sources/SilkTouch/SilkTouch/Mods/PrettifyNames.cs
Comment thread sources/SilkTouch/SilkTouch/Mods/ChangeNamespace.cs
Comment thread sources/SilkTouch/SilkTouch/Mods/Common/MSBuildModContext.cs
@Exanite Exanite marked this pull request as ready for review April 17, 2026 22:30
@Exanite Exanite requested a review from a team as a code owner April 17, 2026 22:30
@Exanite Exanite merged commit 133c257 into dotnet:develop/3.0 Apr 18, 2026
19 checks passed
@Exanite Exanite deleted the feature/performance branch April 18, 2026 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants