-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate strings instead of Roslyn SyntaxNodes in interop source generators #95882
Comments
Tagging subscribers to this area: @dotnet/interop-contrib Issue DetailsSince the start of the interop source generators, we've always decided to use Roslyn
However, it has also lead to a number of problems:
Additionally, the Roslyn team recommends using a Finally, @Sergio0694 updated ComputeSharp to use an "indented text writer" approach and saw a ~460x performance improvement in CPU time and a ~36x Memory footprint improvement. Even if we only get a fraction of that improvement due to our desire to have an extensibility model, doing the work to rewrite the APIs seems worthwhile. Additionally, with that amount of improvement, we may also see build-time improvements for assemblies with lots of
|
Love it! For context, here's my |
FWIW, the regex generator has been using the built-in IndentedTextWriter and it's worked fine.
|
In case if anyone is unaware, there is also an indented string builder proposed at roslyn side: dotnet/roslyn#71162 |
Since the start of the interop source generators, we've always decided to use Roslyn
SyntaxNode
s as both our source-of-truth as well as our go-to emit strategy. This choice has provided us a number of benefits:However, it has also lead to a number of problems:
NormalizeWhitespace
(what we use to handle adding whitespace) is extremely slow.SyntaxNode
s in the sourceSyntaxTree
s due to how we structure some of our internal data types.SyntaxNode
tostring
for Roslyn to parse anyway.Additionally, the Roslyn team recommends using a
string
-based approach.Finally, @Sergio0694 updated ComputeSharp to use an "indented text writer" approach and saw a ~460x performance improvement in CPU time and a ~36x Memory footprint improvement. Even if we only get a fraction of that improvement due to our desire to have an extensibility model, doing the work to rewrite the APIs seems worthwhile.
Additionally, with that amount of improvement, we may also see build-time improvements for assemblies with lots of
LibraryImport
s, such as CoreLib.The text was updated successfully, but these errors were encountered: