Everyday Unity
Practical Optimizations This is a long video, but it's worth watching. The speaker is a great engineer who shares an example of optimization using DOD (Data-oriented design) in Kerbal Space Program 2. Obviously, this optimization technique is not suitableβ¦
The Art of Unity Optimization
A similar approach to the one I have shared above recently but on everyone's favorite rotating cubes sample. Still recommend to watch the previous video, but this one shorter and shows similar techniques to increase performance when you have many entities.
https://youtu.be/6mNj3M1il_c
#compute #jobsystem #dod #optimization
A similar approach to the one I have shared above recently but on everyone's favorite rotating cubes sample. Still recommend to watch the previous video, but this one shorter and shows similar techniques to increase performance when you have many entities.
https://youtu.be/6mNj3M1il_c
#compute #jobsystem #dod #optimization
π3
Unity-Textures-Hunter: Provides summary of all textures and atlases in Unity project
It makes an analysis of non-atlas textures to give some recommendations upon their compression settings.
It also helps to analyze all your atlases at once and highlights issues if their textures used in Resources and/or Addressables (which may lead to duplicated textures in build).
https://github.com/AlexeyPerov/Unity-Textures-Hunter
#editortools #optimization #texture
It makes an analysis of non-atlas textures to give some recommendations upon their compression settings.
It also helps to analyze all your atlases at once and highlights issues if their textures used in Resources and/or Addressables (which may lead to duplicated textures in build).
https://github.com/AlexeyPerov/Unity-Textures-Hunter
#editortools #optimization #texture
π7
The World's Smallest Hash Table
An example how you can optimize an algorithm knowing the details of your particular problem
https://orlp.net/blog/worlds-smallest-hash-table/
#optimization
An example how you can optimize an algorithm knowing the details of your particular problem
https://orlp.net/blog/worlds-smallest-hash-table/
#optimization
π4
Improving Burst Inspector search performance
Another example how standard methods might be a lot slower due to various reasons, for instance safety checks. And how own implementation may leverage some assumptions to provide performance gains.
But as usual, always profile.
https://blog.unity.com/engine-platform/improving-burst-inspector-search-performance
#optimization
Another example how standard methods might be a lot slower due to various reasons, for instance safety checks. And how own implementation may leverage some assumptions to provide performance gains.
But as usual, always profile.
https://blog.unity.com/engine-platform/improving-burst-inspector-search-performance
#optimization
Unity
Improving Burst Inspector search performance
Discover ways to use the Unity Profiler to investigate performance bottlenecks in your program and how to fix them.
π2
Optimize struct performances using StructLayout
I ran a simple benchmark that passes structs as an argument: one uses StructLayout.Sequential and another StructLayout.Auto.
I intentionally ordered fields in a way that makes them have padding.
And result is (the formatting in mobile clients sucks):
It can be avoided by using 'ref' parameter so no copying occurs. I've also thrown readonly structs to the test.
https://www.meziantou.net/optimize-struct-performances-using-structlayout.htm
#optimization #struct #layout #ref
I ran a simple benchmark that passes structs as an argument: one uses StructLayout.Sequential and another StructLayout.Auto.
I intentionally ordered fields in a way that makes them have padding.
And result is (the formatting in mobile clients sucks):
| Method | Mean | Ratio |
|------- |---------:|------:|
| Auto | 298.6 us | 1.00 |
| Seq | 359.0 us | 1.20 |
Obviously copying struct that is bigger due to the padding to pass it as an arg is slower. But this operation is so quick that it might be a problem only on a very hot path.It can be avoided by using 'ref' parameter so no copying occurs. I've also thrown readonly structs to the test.
| Method | Mean | Ratio |
|------------- |---------:|------:|
| Auto | 318.5 us | 1.00 |
| Seq | 398.7 us | 1.25 |
| AutoRef | 254.5 us | 0.80 |
| SeqRef | 299.7 us | 0.94 |
| AutoReadonly | 312.9 us | 0.98 |
| SeqReadonly | 390.5 us | 1.22 |
As you can see passing both structs by ref is definitely faster. But Auto is again faster than Sequential. While readonly structs don't have any performance benefits according to this benchmark. To make sure a defensive copy of a readonly struct is avoided, I've also added 'in' parameter to the arg and now we can see that structs are not copied anymore and performance is on par with the 'ref' parameter| Method | Mean | Ratio |
|--------------- |---------:|------:|
| Auto | 299.9 us | 1.00 |
| Seq | 369.1 us | 1.23 |
| AutoRef | 245.1 us | 0.82 |
| SeqRef | 305.7 us | 1.02 |
| AutoReadonly | 309.1 us | 1.03 |
| SeqReadonly | 369.6 us | 1.23 |
| AutoReadonlyIn | 255.4 us | 0.86 |
| SeqReadonlyIn | 303.4 us | 1.02 |
I performed all these benchmarks in .NET. It would be very interesting to look at it in Unity using IL2CPP, whether it affects performance in C++ or not.https://www.meziantou.net/optimize-struct-performances-using-structlayout.htm
#optimization #struct #layout #ref
Meziantou's blog
Optimize struct performances using StructLayout
A struct type is a value type that is typically used to encapsulate small groups of related variables. It is often used for interop with native DLL ([DllImport]). Structs are also used for performance reasons. Value types are allocated on the stack so itβ¦
π4
Premature Optimization
The main point which I also always repeat in my own blog posts: profile first. Optimization might not even be needed in the first place. And without the baseline you can't even tell whether changes improved the performance or not.
https://youtu.be/tKbV6BpH-C8
#optimization
The main point which I also always repeat in my own blog posts: profile first. Optimization might not even be needed in the first place. And without the baseline you can't even tell whether changes improved the performance or not.
https://youtu.be/tKbV6BpH-C8
#optimization
YouTube
Premature Optimization
When should you optimize your code?
Access to code examples, deleted scenes, song names and more at https://www.patreon.com/codeaesthetic
Access to code examples, deleted scenes, song names and more at https://www.patreon.com/codeaesthetic
π5
Updated 2022 LTS Best Practice Guides for optimizing games | Unity Blog
Two new books featuring optimization tips and tricks for mobile, consoles, and PC have been released. I've skimmed through both materials; all the tips have already been published in various resources. However, it's great to have them compiled in one place with navigation via the contents page. I highly recommend bookmarking these books.
https://blog.unity.com/engine-platform/updated-2022-lts-best-practice-guides
#optimization #book
Two new books featuring optimization tips and tricks for mobile, consoles, and PC have been released. I've skimmed through both materials; all the tips have already been published in various resources. However, it's great to have them compiled in one place with navigation via the contents page. I highly recommend bookmarking these books.
https://blog.unity.com/engine-platform/updated-2022-lts-best-practice-guides
#optimization #book
Unity
Updated 2022 LTS Best Practice Guides for optimizing games | Unity Blog
Our updated optimization guides include the latest updates from Unity 2022 LTS and provide you with useful tips and tactics to optimize your projects.
π7π₯1
ProjectAuditor: Project Auditor is an experimental static analysis tool for Unity Projects.
The tool made by Unity field engineers who help studios optimize their games.
Project Auditor is a static analysis tool that analyzes assets, settings, and scripts of the Unity project and produces a report containing: Code and Settings diagnostics, the last BuildReport, and assets information
https://github.com/Unity-Technologies/ProjectAuditor
#optimization #analysis #auditor
The tool made by Unity field engineers who help studios optimize their games.
Project Auditor is a static analysis tool that analyzes assets, settings, and scripts of the Unity project and produces a report containing: Code and Settings diagnostics, the last BuildReport, and assets information
https://github.com/Unity-Technologies/ProjectAuditor
#optimization #analysis #auditor
GitHub
GitHub - Unity-Technologies/ProjectAuditor: Attention! This repository is out-of-date and unsupported, please use the built-inβ¦
Attention! This repository is out-of-date and unsupported, please use the built-in package instead! Project Auditor is a static analysis tool for Unity Projects. - Unity-Technologies/ProjectAuditor
π8π₯2
Instantly Boost Unity Game Performance With IL2CPP_USE_SPARSEHASH
Finally, another post on my blog. This investigation was time-consuming, and while I won't say I enjoy digging through generated C++ code, the results were worth the effort. Hit the fire emoji if you like this type of content and want me to write more of it.
The metadata in IL2CPP generated for each type and used for tasks like virtual method invocation is barely covered online. Not even the Unity documentation provides sufficient information. More crucially, you won't find details online about how the metadata is stored in memory or the existence of the define IL2CPP_USE_SPARSEHASH. In this post, I dive into the internals available in the generated C++ code to learn more about it and how we can significantly boost the performance of some operations in our games using this knowledge.
Here is a lifehack to improve performance using a concrete example of dependency resolution at the app start for all DI enjoyers. Of course, this isn't free, but performance is always about compromise.
https://gamedev.center/instantly-boost-unity-game-performance-with-il2cpp_use_sparsehash/
I've also posted this on Reddit, so I would appreciate it if you upvote it for all the effort put into this: a reddit post
#il2cpp #performance #optimization #IL2CPP_USE_SPARSEHASH
Finally, another post on my blog. This investigation was time-consuming, and while I won't say I enjoy digging through generated C++ code, the results were worth the effort. Hit the fire emoji if you like this type of content and want me to write more of it.
The metadata in IL2CPP generated for each type and used for tasks like virtual method invocation is barely covered online. Not even the Unity documentation provides sufficient information. More crucially, you won't find details online about how the metadata is stored in memory or the existence of the define IL2CPP_USE_SPARSEHASH. In this post, I dive into the internals available in the generated C++ code to learn more about it and how we can significantly boost the performance of some operations in our games using this knowledge.
Here is a lifehack to improve performance using a concrete example of dependency resolution at the app start for all DI enjoyers. Of course, this isn't free, but performance is always about compromise.
https://gamedev.center/instantly-boost-unity-game-performance-with-il2cpp_use_sparsehash/
I've also posted this on Reddit, so I would appreciate it if you upvote it for all the effort put into this: a reddit post
#il2cpp #performance #optimization #IL2CPP_USE_SPARSEHASH
gamedev.center
Boost Unity Game Performance With IL2CPP_USE_SPARSEHASH
Dive into IL2CPP internals & learn how to use IL2CPP_USE_SPARSEHASH to make your games faster. Unlock over 2x performance boost for operations that use metadata
π₯25π4π―1
10 Unity Audio Optimisation Tips
There are a few posts covering audio optimization available. While it's true that this topic is usually overlooked since assets, scripts, and rendering optimizations yield more significant performance gains, it's great to have such posts bookmarked, as they list a lot of high-quality tips. Moreover, now you know that sounds might also cripple performance.
https://gamedevbeginner.com/unity-audio-optimisation-tips/
#audio #optimization
There are a few posts covering audio optimization available. While it's true that this topic is usually overlooked since assets, scripts, and rendering optimizations yield more significant performance gains, it's great to have such posts bookmarked, as they list a lot of high-quality tips. Moreover, now you know that sounds might also cripple performance.
https://gamedevbeginner.com/unity-audio-optimisation-tips/
#audio #optimization
Game Dev Beginner
10 Unity Audio Optimisation Tips
Learn the right way to optimise audio in your Unity projects with my 10 most useful audio optimisation tipsβ¦
π4π₯2