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.
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).
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.