Skip to content

Excessive stack usage when using tokio::spawn in debug builds #2055

Open
@udoprog

Description

Description

When using tokio::spawn, the task to spawn is passed through a number of functions before it is moved to the heap:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-tokioArea: The main tokio crateC-bugCategory: This is a bug.E-help-wantedCall for participation: Help is requested to fix this issue.E-mediumCall for participation: Experience needed to fix: Medium / intermediateM-taskModule: tokio/task

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions