Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple async wrapper doubles the size of a future #72454

Closed
jimblandy opened this issue May 22, 2020 · 1 comment
Closed

Simple async wrapper doubles the size of a future #72454

jimblandy opened this issue May 22, 2020 · 1 comment
Labels
A-async-await C-bug I-heavy T-compiler

Comments

@jimblandy
Copy link
Contributor

@jimblandy jimblandy commented May 22, 2020

I'm using the following wrapper function:

pub async fn log_error<F>(future: F)
where
    F: Future<Output = Result<(), Box<dyn Error + Send + Sync + 'static>>>
{
    if let Err(err) = future.await {
        print_error(err);
    }
}

Using std::mem::size_of_val, the size of any future returned by this function is a bit more than twice the size of the future passed to it. This is a pretty severe penalty for a simple helper function.

@jimblandy jimblandy added the C-bug label May 22, 2020
@LeSeulArtichaut LeSeulArtichaut added the I-heavy label May 22, 2020
@jonas-schievink jonas-schievink added A-async-await T-compiler labels May 22, 2020
@jonas-schievink
Copy link
Member

@jonas-schievink jonas-schievink commented May 22, 2020

Duplicate of #62958

@jonas-schievink jonas-schievink marked this as a duplicate of #62958 May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await C-bug I-heavy T-compiler
Projects
None yet
Development

No branches or pull requests

3 participants