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

Avoid unnecessary async state machine generation #9871

Closed
hez2010 opened this issue Aug 31, 2022 · 5 comments · Fixed by #10853
Closed

Avoid unnecessary async state machine generation #9871

hez2010 opened this issue Aug 31, 2022 · 5 comments · Fixed by #10853
Assignees
Labels
good first issue Good issue for new contributors to get started with

Comments

@hez2010
Copy link
Member

hez2010 commented Aug 31, 2022

We have plenty of code like below:

async IAsyncOperation<T> Foo()
{
    return await AsyncInfo.Run(async () => 
    {
        // no await in the body at all
        return foo;
    });
}

which doesn't actually await anything in an async method. Instead, we should rewrite them to

IAsyncOperation<T> Foo()
{
    return Task.FromResult(foo).AsAsyncOperation();
}

This can avoid unnecessary async state machine be generated to reduce GC pressure.

@hez2010 hez2010 added codebase quality good first issue Good issue for new contributors to get started with labels Aug 31, 2022
@hez2010 hez2010 changed the title Remove unnecessary async state machine generation Avoid unnecessary async state machine generation Aug 31, 2022
@QuaintMako
Copy link
Contributor

Linking it the performance issues maybe? Anyone taking up that issue may want to dive deeper into optimization.

@Josh65-2201 Josh65-2201 moved this to 🆕 New in Files task board Sep 8, 2022
@Josh65-2201 Josh65-2201 moved this from 🆕 New to 🔖 Ready to build in Files task board Sep 8, 2022
@yaira2 yaira2 moved this from 🔖 Ready to build to 🆕 New in Files task board Sep 8, 2022
@Josh65-2201 Josh65-2201 moved this from 🆕 New to 📋 Planning stage in Files task board Sep 8, 2022
@QuaintMako
Copy link
Contributor

I believe there is no longer any return await AsyncInfo.Run methods inside the codebase.

Does this issue also concerns any return AsyncInfo.Run that does not have any await in its instructions?

@itsWindows11
Copy link
Contributor

itsWindows11 commented Apr 7, 2023

There are still stuff which could be changed in the codebase related to this, can this issue be reopened again?

@hez2010 hez2010 reopened this Apr 7, 2023
@github-project-automation github-project-automation bot moved this from ✅ Done to 🆕 New in Files task board Apr 7, 2023
@Josh65-2201 Josh65-2201 moved this from 🆕 New to 🏗 In progress in Files task board Apr 7, 2023
@hez2010
Copy link
Member Author

hez2010 commented May 9, 2023

Can I assume this issue has been resolved?

@itsWindows11
Copy link
Contributor

It should be fully resolved after merging the PR, no problem.

@hez2010 hez2010 closed this as completed May 9, 2023
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Files task board May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good issue for new contributors to get started with
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants