Search Unity

We recently shared our roadmap plans for 2021. Now we invite you inside Unity to meet some of the teams working towards these goals. In this second post of our new series, we meet the Performance Optimization team.

Our Unity 2021 roadmap explains our priorities for next year. We’re committed to updating production-ready features and delivering key new features based on what you have told us you’re missing from Unity. But we’re equally determined to improve workflows and your overall quality of life when working in the Editor.

This post is the second of a series that aims to give you a glimpse behind the scenes. You’ll meet some of the teams working on those initiatives, get to know what drives them, and see the progress they’re making. In this blog post, we’re meeting with team lead Lyndon Homewood and senior software engineer Richard Kettlewell from the performance optimization team to learn more about their focus and plans for next year.

Understanding performance: More than speed

Performance is not just the speed of executing at runtime. High performance translates into loading speeds, power consumption on the device, and iteration times for you as a creator working in the editor. Bad performance can take a user out of an immersive experience when slow frames cause visual stuttering or excessive CPU activity drains the battery on your mobile device. As a Unity creator, performance impacts what you can build by setting technical limits on your creative ambitions. It affects how smooth the workflow is in the Editor and your ability to be in flow and be as productive as possible.

About two years ago, Unity formed a dedicated optimization team to focus on performance as a feature in its own right. I got the chance to meet with Lyndon, who leads the growing Performance Optimization team, to learn more about their work.

Internal champions of performance

The team’s mission is simple: to improve the performance of the Unity Editor workflows for creators and optimize the engine systems across the wide range of Unity platforms. This is consistent with our 2021 product commitment to provide you with the most efficient workflows and ensure the features you rely on throughout your production are as performant as possible. 

“Performance is an important recurring issue for our users,” explains Lyndon. “It’s tied to the experience of developing Unity day in and day out. We believe it should be treated as a feature in its own right.” It’s this idea that ultimately led to the formation of a dedicated optimization team.

As the internal champions of performance, the team collaborates across R&D. They increase awareness and knowledge of profiling and optimizing, and share their best practice across Unity. They work closely with the profiling team, whose tools are essential to meeting their goals. Another key partner is the Quality of Life taskforce, introduced in the first post of this series. The Quality of Life team works on improving workflows for the creators, which naturally includes performance considerations. 

Most of the team members are senior engineers who have several years of experience in game systems or game engine development, as does Lyndon, who has been with Unity for three years now. He also comes with ten years of experience with in-house tech.

Understanding the problems of creating games and the tech that solves them is key. The team members are obsessed with performance and often have to dive through multiple layers to get as close as possible to the hardware in the codebase in their search for performance improvements. They work with other Unity engineers to learn and analyze existing systems, to identify how best to update them to use the hardware more efficiently.

Optimization issues come to the attention of the team via multiple avenues. Being a small team, they cannot monitor everything, but they keep an eye on the forums and social channels, and the community and product teams help funnel issues to them. The highest priority goes to issues with the greatest impact on the most users. 

The performance team – top: Kim, Lyndon, Richard; middle: Stine, John, Alex; bottom: Amandine, Vicky.

Performance optimization should not be an afterthought

A common piece of advice for new game developers is to profile often and do it proactively throughout the development process. If you’re about to ship, it’s a little late to be looking at your project’s performance. In 2020 alone, the team made several impressive improvements giving 100x speed increases in some targeted areas. 

Does this indicate an initial poor design? Not according to Lyndon. “Some systems or individual functions were implemented several years ago when content demands were lower. Those systems performed reasonably for the requirements at the time, but as hardware improves and content volumes increase there is a need to revisit the underlying algorithms to scale up in a more performant way.”

Often, system scalability can be measured using Big O notation. For a system algorithm with O(n^2) complexity, you may not notice the significance of the impact until n (the volume of content) is large. Sometimes a small container change can optimize an algorithm (hopefully to O(1)) for some significant gains.

“Software development is a living process, continuously striving to maximize value for users. As the use of the Unity engine expanded into new spaces and different industries with much larger scale of content than ever before, and as the content pushes the boundaries of what’s possible, the opportunity to discover performance improvements is ongoing.”

A great example of this is the Prefabs workflow improvements to Unity 2018. Lyndon’s team approached the problem through the user workflows where nesting and variants were designed to give creators greater flexibility and increase their productivity when working in large-scale scenes. “Now when those workflows were refined and made robust, we had the opportunity to do a second pass to ensure they also perform at a massive scale.” The team sped up Nested Prefab operations by up to 250x. 

What’s already available in 2020.2 beta

Some of the team’s recent achievements have already been highlighted on the blog. Those new performance improvements are available in Unity 2020.2 (available as beta at the time of writing).

In addition to optimizing the Nested Prefab operation, RegisterScriptedImporters have been sped up by up to 800x and 2D Texture loading was optimized to avoid some hitches that occurred when loading larger textures. 

Another example is the Camera.main scripting function, which used to be costly to call. Previously, calling Camera.main caused Unity to search through a list of all tagged GameObjects. First Unity built a list of all the GameObjects with the MainCamera tag; then Unity performed a second pass over the temporary list, looking for the first active GameObject that also contained a Camera component.

“This is an example of an old part of Unity that was written when projects had maybe a few hundred GameObjects, but it didn’t scale well in modern projects with many thousands of GameObjects.”

Richard, a senior software engineer on the team, explains how this particular performance bottleneck was solved by storing the objects tagged as MainCameras in a dedicated list when they are created. This simple change means that the Camera.main function now looks only at GameObjects with the MainCamera tag, because all other tagged objects are already filtered out.

“Many hundreds of milliseconds vanished to nothing,” as demonstrated in a Spotlight Team customer project (shown below). 

Before:

After:

Optimizing Camera.main

What to expect in 2021

The Performance Optimization team is growing. Lyndon and Richard are currently looking for three new teammates to join the team. “You have to be passionate about squeezing out every bit of performance and able to drill down to the implications of specific hardware on performance.”

While understanding high-performance code and how it maps to low-level hardware is paramount, it is also highly beneficial to have a background as a game developer or working on in-house game engines, to better understand the requirements of real-time game systems. So if you have a passion for high-performance software development, consider applying for one of the open vacancies.

Everyone’s work at Unity R&D touches performance to some degree, and this team has the opportunity to collaborate with all of them to sharpen their focus. In the near future, the optimization team anticipates working closely with the asset pipeline team on import and deploy cycles. 

Next year we can look forward to Asynchronous Unload support coming to the Asset Bundle API. The unload process used to happen synchronously, but allowing asynchronous unloading will minimize hitching when unloading. This is a great example of a feature that works that was revisited and refactored for optimal performance.  

The team has leveraged some community-created test projects in the test process and will make even more of these in 2021. See for example the performance test project from Peter77 (aka QA Jesus), one of our most valued beta testers. 

In addition to optimization of the core platform, where the user base is largest, in 2021 more attention will be paid to console platforms and legacy systems to ensure Unity is future-proofed for the next generation of hardware. 

What improvements would you like?

Although this team is dedicated to performance improvements as a feature in its own right, the optimization work is happening across all of Unity’s teams.

Are there specific performance improvements you would like to see to make your quality of life better in the Editor? Let our teams know in the comments or in the forums

Want another peek behind the scenes?

This is the second of several dev diaries we’ve planned to introduce you to some of the people working on future versions of Unity and give you a glimpse of their inspiration and drive. The first post covered a key team that operates under the codename “Quality of Life” – if you missed it, you can check it out here.

Tell us in the comments below if you would like us to cover any specific teams and feature areas in future blog posts.

20 replies on “The road to 2021: The Performance Optimization team”

Lol
I give Unity one more year and it will start to break appart and start to devaluate. Really I don’t see any reason to keep using Unity. There’s nothing new, nothing ground breaking. Introducing more crap that no one needs and more bugs that breaks projects.

I think optimization in the editor – not just build – is really really important, it’s really good to see work done in that direction :)) I know UIElements is faster than IMGUI for more complex things like node graphs, which is super duper fantastic.

How about making the standard shader parameters _EmissionColor and _Color instanced by default. That way the one material can have many variations without invoking multiple batches.

SRP Batcher tries to batch anything with the same shader – not material – together, if you’re lucky enough to be able to use URP/HDRP, that’s an option. Otherwise I’d advise making your own standard shader. It’s pretty helpful, since you can add whatever features you need! :)

Yes, right, but…

-Unity runtime is still a pretty outdated mono version. Not CoreCLR and not even the newest version of mono with performance improvements.
-Burst is really good, but what good does it make when most of the time the mere act of *scheduling* jobs is much more expensive than jobs themselves? And why make the job scheduling on main-thread? Do you believe that the general developer with Unity won’t be able to debug it if errors appear?
-Likewise, why so many checks for threadIndex == 0 in many classes provided by Unity? You not only waste performance with them, but you lock out developers to do certain optimizations (why do we even need TransformAccessArray?). Are you sure that the general user won’t be able to adequately debug apparent issues?
-Why does Unity first load all the queued scenes and only then activate them? Not even asset integration happens during scenes loading! (https://forum.unity.com/threads/scene-loading-best-practicies.921548/) Considering how many small, granular scenes a modern project can have, that seems like an obvious target for improvement (https://youtu.be/6lRzXqfMXRo?t=444).

I’m sorry, I’m just a bit concerned that many (if not most) performance woes are tied directly to making the engine easy/aggressively safe to use at the expense of said performance and/or opportunities to improving it.

Faster project build time in HDRP is welcomed. More performance when using many VFX graphs.
Question: when will 2020.2 be released, out of beta?

Could you implement a performance anomaly detection system that would automatically alert developers to areas of their games that are slower than average or performance bottlenecks. In theory with enough data and coverage you could build up a database of problems and solutions that could inform the developers and even autofit the problem.

Important optimization areas that I believe the team(s) should focus on:
– HDRP: very difficult to reach 120+ fps in HDRP in simple scenes whereas URP easily goes 300-400+ fps on same hardware. Even when deactivating volumetrics/refraction/subsurface/etc and other expensive stuff
– UI: perhaps the real solution to performance issues in UnityUI is using UiToolkit instead? Would be cool to hear more about UIToolkit
– Import, platform switching & build times
– Diagnostic Tools that can help any inexperienced user understand obvious ways to improve build sizes, memory usage, etc…
– A proper sample project that demonstrates good workflows for streaming of open worlds

> – Diagnostic Tools that can help any inexperienced user understand obvious ways to improve build sizes, memory usage, etc…

Hi there, I work on the UI of the Memory Profiler package. We’re aware of the general need for better Asset Profiling and will continue to improve the UX and workflows regarding Memory Profiling, but I am curious if there are any specific needs you have in mind here.

Been using Unity since 4.0 as an Environment artist – We need Mesh to terrain blending for HDRP.

https://www.youtube.com/watch?v=d_at-NawTbY – This guy nailed the visual look, the height map blending is extremely realistic and the lighting between the surface normals is perfectly clean

That the only thing we environment artists needs to start actually contributing to forums, groups and art portfolios that feature outdoor/organic.

Almost all other engines support this, its time for us to finally, hopefully, eventually show what Unity can do without it looking last-last gen.

Thank you, I hope you will consider this. Great work guys!

Deixe uma resposta

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *