Comment From: mhalbritter
I did some benchmarks, where I measured the total time taken in AutoConfigurationImportSelector (which calls OnClassCondition.getOutcomes).
With platform threads, using the spring-boot-smoke-test-actuator, this averages to about 45 ms. With virtual threads, using this code:
private static final class ThreadedOutcomesResolver implements OutcomesResolver {
private final Future<ConditionOutcome[]> future;
private ThreadedOutcomesResolver(OutcomesResolver outcomesResolver) {
VirtualThreadTaskExecutor executor = new VirtualThreadTaskExecutor("OnClassCondition-outcomes-resolver-");
this.future = executor.submit(outcomesResolver::resolveOutcomes);
}
@Override
public ConditionOutcome[] resolveOutcomes() {
try {
return this.future.get();
}
catch (InterruptedException | ExecutionException ex) {
throw new RuntimeException("Failed to resolve outcome", ex);
}
}
}
this averages to about 52 ms.
Switching to virtual threads doesn't give any benefit here.