async-std icon indicating copy to clipboard operation
async-std copied to clipboard

Ways to specify thread stack size

Open lihe07 opened this issue 3 years ago • 1 comments

When we are trying to spawn a memory costy task with async-std async_std::task::spawn(some_future()) It throws thread 'async-std/runtime' has overflowed its stack

Although we can solve this problem with the following code:

thread::Builder::new().stack_size(32 * 1024).spawn(|| {
    async_std::task::block_on(some_future())
}).unwrap();

But if async_std also has the specified task stack size, it can save some time.

lihe07 avatar Mar 16 '22 02:03 lihe07

If that future is a large set of async functions you may be able to break it up manually using a pinned box for some memory indirection, which should help I think.

Fishrock123 avatar May 10 '22 19:05 Fishrock123