-
-
Notifications
You must be signed in to change notification settings - Fork 108
perf: PropertyInjector defer state machine creation
#4321
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
Conversation
|
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