Problem
The current implementation uses double tokio::spawn calls, creating unnecessary task churn:
listener.accept() → spawn(process_stream) → inside process_stream another spawn(app.handle_connection)
Affected Locations
- Lines 341-342 in src/server.rs
- Lines 373-376 in src/server.rs
Current Code
tokio::spawn(async move {
app.handle_connection(stream).await;
});
Suggested Improvement
Unless the inner spawn isolates crash-safety or blocking work, call app.handle_connection directly:
app.handle_connection(stream).await;
Benefits
- Reduces task scheduling overhead
- Simplifies the execution flow
- Eliminates one unnecessary context switch
Context
This is a performance optimization that reduces the complexity of the async task execution without affecting functionality.
References
Reported by: @leynos
Problem
The current implementation uses double
tokio::spawncalls, creating unnecessary task churn:listener.accept()→spawn(process_stream)→ insideprocess_streamanotherspawn(app.handle_connection)Affected Locations
Current Code
Suggested Improvement
Unless the inner spawn isolates crash-safety or blocking work, call
app.handle_connectiondirectly:Benefits
Context
This is a performance optimization that reduces the complexity of the async task execution without affecting functionality.
References
Reported by: @leynos