Open
Description
Description
When using tokio::spawn
, the task
to spawn is passed through a number of functions before it is moved to the heap:
- https://github.com/tokio-rs/tokio/blob/master/tokio/src/task/spawn.rs#L121
- https://github.com/tokio-rs/tokio/blob/master/tokio/src/runtime/spawner.rs#L23
- https://github.com/tokio-rs/tokio/blob/master/tokio/src/runtime/thread_pool/spawner.rs#L31
- https://github.com/tokio-rs/tokio/blob/master/tokio/src/runtime/thread_pool/slice.rs#L58
- https://github.com/tokio-rs/tokio/blob/master/tokio/src/task/mod.rs#L308
In my case, I had 150kb of stack space remaining (checked using stacker::remaining_stack
), and I was passing a 50kb task. So for each stack frame above, 50kb of stack was used until the task was moved to the heap in the form of a RawTask
.
This is typically not an issue with optimized builds since most of the stack frames are inlined and the task size is significantly decreased through optimizations. But it might be possible to be nicer towards non-optimized builds by moving the task to the heap as early as possible.
Activity