Skip to content

perf: make StaticPropertyInitializationGenerator incremental#4638

Merged
thomhurst merged 1 commit intothomhurst:mainfrom
TimothyMakkison:static_prop_generator_incre
Feb 6, 2026
Merged

perf: make StaticPropertyInitializationGenerator incremental#4638
thomhurst merged 1 commit intothomhurst:mainfrom
TimothyMakkison:static_prop_generator_incre

Conversation

@TimothyMakkison
Copy link
Contributor

  • Add PropertyWithDataSourceModel and associated types
  • Return ImmutableArray<PropertyWithDataSource> from GetSemanticTargetForGeneration
  • Move enabledProvider check to earlier in pipeline to reduce work
  • ToUniquePropertyModels ensures that only distinct properties are converter into PropertyWithDataSourceModel
  • Only call GetStaticPropertyDataSources instead of doing a unnecessary call in GenerateStaticPropertyInitialization

@TimothyMakkison
Copy link
Contributor Author

TimothyMakkison commented Feb 3, 2026

  • Fixed run length assertion in AotConverterTests
  • Refactor and rename methods in the parse step
  • Use a reusable properties list and keep track of already visited nodes
  • Add tests to ensure that the generator is incremental
Method Mean Error StdDev Gen0 Allocated
RunGenerator 20.42 ms 0.354 ms 0.562 ms 250.0000 2.38 MB

Time and memory usage seems suspiciously low 🤔 but the tests appear to pass

@TimothyMakkison TimothyMakkison marked this pull request as ready for review February 3, 2026 21:50
@TimothyMakkison TimothyMakkison force-pushed the static_prop_generator_incre branch 2 times, most recently from 486c58e to 4ccfdb3 Compare February 5, 2026 00:26
@claude
Copy link
Contributor

claude bot commented Feb 6, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

This is a well-structured performance optimization that properly implements incremental source generation patterns. The separation of parsing and generation phases, introduction of value-based model types, and proper use of EquatableArray all follow Roslyn best practices for incremental generators.

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.

2 participants