-
-
Notifications
You must be signed in to change notification settings - Fork 109
perf: use VLB and make methods sync in EventReceiverOrchestrator
#4410
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
SummaryPerformance optimization using ValueListBuilder for allocation reduction and making methods synchronous. Critical IssuesMissing try-finally in RegisterReceivers (line 41-77): The ValueListBuilder is only disposed if no exception occurs. This could leak array pool buffers. VerdictREQUEST CHANGES - Need try-finally block around VLB usage. |
Detailed FixIn EventReceiverOrchestrator.RegisterReceivers, the ValueListBuilder needs try-finally: Before: vlb.Dispose() only runs if no exception occurs This prevents leaking array pool buffers when exceptions occur during event object enumeration or registration. Performance NotesThe changes are excellent for performance:
The only minor point is the duplicated early-exit logic in InvokeTestEndEventReceiversAsync, but the performance benefit likely justifies it. |
ValueListBuilderinRegisterReceiversBefore
After
Fun fact:
Attribute.EqualsandAttribute.GetHashCodeallocate aFieldInfo[]each time they are called.