Skip to content

Commit

Permalink
task: quickly send task to heap on debug mode (#4009)
Browse files Browse the repository at this point in the history
  • Loading branch information
blasrodri authored Aug 12, 2021
1 parent b501f25 commit 84c4a6d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tokio/src/task/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ cfg_rt! {
T: Future + Send + 'static,
T::Output: Send + 'static,
{
spawn_inner(future, None)
// preventing stack overflows on debug mode, by quickly sending the
// task to the heap.
if cfg!(debug_assertions) && std::mem::size_of::<T>() > 2048 {
spawn_inner(Box::pin(future), None)
} else {
spawn_inner(future, None)
}
}

#[cfg_attr(tokio_track_caller, track_caller)]
Expand Down

1 comment on commit 84c4a6d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'sync_semaphore'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 84c4a6d Previous: 032c55e Ratio
contended_concurrent_single 2456 ns/iter (± 15) 952 ns/iter (± 126) 2.58

This comment was automatically generated by workflow using github-action-benchmark.

CC: @tokio-rs/maintainers

Please sign in to comment.