task: allocate callback on heap immediately in debug mode
@@ -193,8 +193,12 @@ impl Handle {
F: FnOnce() -> R + Send + 'static,
R: Send + 'static,
{
+ if cfg!(debug_assertions) && std::mem::size_of::<F>() > 2048 {
+ self.spawn_blocking_inner(Box::new(func), None)
+ } else {
self.spawn_blocking_inner(func, None)
}
+ }
#[cfg_attr(tokio_track_caller, track_caller)]
pub(crate) fn spawn_blocking_inner<F, R>(&self, func: F, name: Option<&str>) -> JoinHandle<R>
