2022-06-23
4576
#unity
James LaFritz
120597
Jun 23, 2022 â‹… 16 min read

Performance in Unity: async, await, and Tasks vs. coroutines, C# Job System, and burst compiler

James LaFritz I have been using the Unity Game Engine since 2015 and programming in C# since 2006. I started off as a hobbyist and developed it into a career with GameDevHQ. You can find me at GameDevHQ, GitHub, or my blog.

Recent posts:

Radix Ui Adoption Guide Overview Examples And Alternatives

Radix UI adoption guide: Overview, examples, and alternatives

Radix UI is quickly rising in popularity and has become an excellent go-to solution for building modern design systems and websites.

Nefe Emadamerho-Atori
Apr 25, 2024 â‹… 11 min read
Understanding The Css Revert Layer Keyword, Part Of Css Cascade Layers

Understanding the CSS revert-layer keyword

In this article, we’ll explore CSS cascade layers — and, specifically, the revert-layer keyword — to help you refine your styling strategy.

Chimezie Innocent
Apr 24, 2024 â‹… 6 min read
Exploring Nushell, A Rust Powered, Cross Platform Shell

Exploring Nushell, a Rust-powered, cross-platform shell

Nushell is a modern, performant, extensible shell built with Rust. Explore its pros, cons, and how to install and get started with it.

Oduah Chigozie
Apr 23, 2024 â‹… 6 min read
Exploring Zed, A Newly Open Source Code Editor Written In Rust

Exploring Zed, an open source code editor written in Rust

The Zed code editor sets itself apart with its lightning-fast performance and cutting-edge collaborative features.

Nefe Emadamerho-Atori
Apr 22, 2024 â‹… 7 min read
View all posts

4 Replies to "Performance in Unity: <code>async</code>, <code>await</code>, and <code>Tasks</code> vs. coroutines, C# Job System, and burst compiler"

  1. “Next, we start the task t1.wait. Lastly, we wait for the task to complete with t1.wait.”
    Am I missing something here, or is the point that we start the task and wait for it to complete in a single statement?

  2. It should have been t1.run to start the task and t1.wait to wait for it to complete. You can do it in one line with await t1.Run or using the factory method. The point is to show different ways if starting and waiting for tasks to complete.

    Typically you want to start all of the tasks. So they are all running in parallel, then you wait for a specific task to complete before moving on to other things, it really depends on what you are trying to accomplish.

    You might want to run one task and wait for it to complete before starting other task if they depend on things from the first task.

  3. Typically it’s not tasks run on the caller’s thread it’s that they synchronize back to the caller’s thread. Are you saying Unity is forcing Tasks to run on the main thread or that because you’re not using ConfigureAwait they’re synchronized to the Unity’s main thread by default?

  4. The parameter passed to the method version is 50,000, but to the async and coroutine versions it is 5,000. Yeah, that’s going to impact the testing.

Leave a Reply