-
-
Notifications
You must be signed in to change notification settings - Fork 108
perf: reuse List and remove ToArray call
#4362
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 that removes unnecessary array allocation and reuses a list buffer in circular dependency detection. Critical IssuesNone found SuggestionsCircularDependencyDetector.cs: Verify buffer reuse correctnessThe buffer reuse optimization looks correct. The pathBuffer is mutated during the DFS traversal in HasCycleDfs. The PR correctly makes a defensive copy when a cycle is found. The logic is sound because:
TestScheduler.cs: Consider consistencyAt line 134 (after the PR), you're passing executableTests (a List) directly to GroupTestsByConstraintsAsync. However, at lines 246 and 277 in the same file, the code still creates arrays with ToArray() before calling the same method. For consistency and to avoid the same allocation overhead, consider removing those ToArray() calls too in a follow-up PR. VerdictAPPROVE - No critical issues. Clean performance optimization that saves ~2MB in allocations as claimed. |
ToArraycall inScheduleAndExecuteAsyncList<AbstractExecutableTest>inCircularDependencyDetector, clearing it each time.Should save around 2MB in
List<AbstractExecutableTest>andAbstractExecutableTest[]allocations