perf: PropertyInjector defer state machine creation#4321
perf: PropertyInjector defer state machine creation#4321thomhurst merged 1 commit intothomhurst:mainfrom
PropertyInjector defer state machine creation#4321Conversation
|
Parallel tasks is for initialisation. E.g. if 5 docker containers get injected, we want to try and speed up the initialisation of them if they're not dependent on each other. |
SummaryPerformance optimization that defers async state machine creation in property injection, saving ~10 MB on TUnit.TestProject. Critical IssuesNone found ✅ SuggestionsMinor optimization opportunity: The condition check on line 60 (new code) is technically redundant: if (plan.SourceGeneratedProperties.Length > 0 || plan.ReflectionProperties.Length > 0)Since However, this redundancy is harmless and arguably makes the code more explicit about when to delegate to the Core method, so it's not a blocker. Observation: The same fast-path optimization pattern is correctly applied to both Verdict✅ APPROVE - Valid performance optimization with no critical issues. The technique (async state machine elision for fast paths) is a well-known optimization pattern and is correctly implemented here. |
Defer async state machine creation until it's needed. Saves around 10 MB on
TUnit.TestProjectInjectPropertiesRecursiveAsyncis alwaysasyncso no point in deferingInjectPropertiesAsyncusestry finallyso it's not possible to make the methodsyncInjectPropertiesIntoArgumentsAsyncisn't referenced anywhereParallelTaskHelper.ForEachAsyncneeded isInjectSourceGeneratedPropertyAsyncreally that slow?Before
After