Run each analyzers/source-generators in a separate process #62764
Replies: 1 comment 3 replies
-
We already are doing this, just via threads. Please make sure your generator is thread safe!
If by "separate process" you mean each gets its entirely own process (n generators means n processes), that would have a lot of overhead. Creating all the SyntaxTrees and SemanticModels isn't cheap, and we get a lot of performance wins by being able to share those between analyzers and generators. As it stands, we actually are running generators in two places in VS: the main VS process and our OOP process, and just having two is already more expensive than we'd like. Getting that back down to one process is the main goal here.
Once we get more stuff moved to .NET Core this goes away, since we're able to isolate things better there with AssemblyLoadContexts. It also allows us to do much more sane unloading. We're currently working on getting our OOP process moved over, at which point we're going to look at getting generators running in just that process.
Is this causing a specific limitation? We have this limitation currently not just because of VS, but also because of VS Code and other ecosystem tools that aren't all on .NET Core. |
Beta Was this translation helpful? Give feedback.
-
My understanding is that currently, source generators and analyzers are loaded into and run inside the main VS/MSBuild process.
It seems like there could be a lot of advantages to running each analyzer/source-generator in a separate process 🙂
AnalyzerA
has a strict dependency onExampleNuGet
4.0.0 andAnalyzerB
has a strict dependency onExampleNuGet
4.1.0, thenMyProject
is unable to depend on bothAnalyzerA
andAnalyzerB
.I'm sure this has already been considered, but I think it'd make for an interesting discussion, nonetheless, and maybe something productive can come out of it 🙂
Beta Was this translation helpful? Give feedback.
All reactions