#Thread stack size function on the multithread runtime builder

5 messages · Page 1 of 1 (latest)

fleet tendon
#

The desciption on the doc is:
Sets the stack size (in bytes) for worker threads.

The actual stack size may be greater than this value if the platform specifies minimal stack size.

The default stack size for spawned threads is 2 MiB, though this particular stack size is subject to change in the future.

Whats the propurse of this stack?
Is something related the number of poll functions that the worker can call for a single future or something?

tulip charm
fleet tendon
fathom aurora
#

Any time the future yields at an .await, any variables are moved into the future object which Tokio heap allocates. But anything not used over an .await is on the real stack.

#

So a runtime with 4 threads and 1000 tasks is going to have 4 stacks and 1000 future objects on the heap. When a task is running, it's using the stack of one of the workers, but when it goes to sleep, its data is stored in the future object so that others can use the stack.