Skip to content

join! doubles the size of the joined futures #1473

@Matthias247

Description

@Matthias247

I spent some time in investigating sizes of async functions, and discovered that the usage of join! lead to a doubling of the required size for a future.

After looking into the associated code, I think the move/copy of the joined futures is the issue:

$(
    // Move future into a local so that it is pinned in one place and
    // is no longer accessible by the end user.
    let mut $fut = $crate::future::maybe_done($fut);
)*

While this seems harmless, these operations add up, and every composition layer can double the future size. And moving futures in the 10kB+ range is costly and wasting memory.

Maybe there are other ways to do this too. E.g. requiring already pinned futures and polling these in-place? With an extra-layer that stack-pins futures that are not yet pinned?

There are probably also a few other combinators which inhibit the same behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions