Summary
The per-test entry point chains through 4 async layers before any real work happens, each materializing its own state machine. Estimated 2 state machines per test removed.
Evidence
Trace (inclusive %):
11.54% TestRunner.ExecuteTestAsync
11.28% TestRunner.ExecuteTestInternalAsync
11.10% TestCoordinator.ExecuteTestAsync ← pure forward
11.10% TestCoordinator.ExecuteTestInternalAsync
10.13% TestCoordinator.ExecuteTestLifecycleAsync
9.94% TestExecutor.ExecuteAsync
TUnit.Engine/Services/TestExecution/TestCoordinator.cs:50-51 is a pure forwarding async method:
public ValueTask ExecuteTestAsync(AbstractExecutableTest test, CancellationToken cancellationToken)
=> ExecuteTestInternalAsync(test, cancellationToken);
ExecuteTestLifecycleAsync is an inline-able wrapper on the no-retry branch.
Proposed fix
- Inline pure-forward
TestCoordinator.ExecuteTestAsync into its caller.
- Inline
ExecuteTestLifecycleAsync into ExecuteTestInternalAsync for the no-retry path.
- Audit
TestRunner.ExecuteTestAsync → ExecuteTestInternalAsync for the same pattern.
Expected impact
- 2-3 async state machines per test removed.
- Directly reduces
AsyncMethodBuilderCore.Start 2.93% self time observed in the trace.
Files
TUnit.Engine/Services/TestExecution/TestCoordinator.cs:50-51, 53, 279
TUnit.Engine/Scheduling/TestRunner.cs:48, 91, 125
TUnit.Engine/TestExecutor.cs:69
Summary
The per-test entry point chains through 4 async layers before any real work happens, each materializing its own state machine. Estimated 2 state machines per test removed.
Evidence
Trace (inclusive %):
TUnit.Engine/Services/TestExecution/TestCoordinator.cs:50-51is a pure forwarding async method:ExecuteTestLifecycleAsyncis an inline-able wrapper on the no-retry branch.Proposed fix
TestCoordinator.ExecuteTestAsyncinto its caller.ExecuteTestLifecycleAsyncintoExecuteTestInternalAsyncfor the no-retry path.TestRunner.ExecuteTestAsync→ExecuteTestInternalAsyncfor the same pattern.Expected impact
AsyncMethodBuilderCore.Start2.93% self time observed in the trace.Files
TUnit.Engine/Services/TestExecution/TestCoordinator.cs:50-51, 53, 279TUnit.Engine/Scheduling/TestRunner.cs:48, 91, 125TUnit.Engine/TestExecutor.cs:69