[C#] Asynchronous processing and async/await
A great overview of how async/await works, from the differences between async and multithreading programming to explaining how async is compiled and operates under the hood. It's an excellent resource for interview preparation.
The content is in Japanese, but it's by the already legendary Annulus Games, and auto-translation does a good job.
https://annulusgames.com/blog/async-await/
#async #interview
A great overview of how async/await works, from the differences between async and multithreading programming to explaining how async is compiled and operates under the hood. It's an excellent resource for interview preparation.
The content is in Japanese, but it's by the already legendary Annulus Games, and auto-translation does a good job.
https://annulusgames.com/blog/async-await/
#async #interview
Annulus Games
【C#】非同期処理とasync/await - Annulus Games
今回の記事はasync/awaitについて。 C#に限らず、現在では多くのプログラミング言語が非同期処理を扱う
👍10🔥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
ECS Galaxy Sample: a project showing a large-scale simulation of several teams of spaceships fighting for the control of planets. This is a fully-automated simulation, but players can spectate using different camera modes. Players can also bring up a "Settings" menu during play to tweak some simulation parameters in realtime.
This sample aims to strike a balance between being simple and lightweight enough to be easy to learn from, and involving enough non-trivial ECS game code (AI, spatial queries, event-based logic, different unit/building types and roles, etc...) to make an interesting showcase.
https://github.com/Unity-Technologies/ECSGalaxySample
#ecs #dots #sample
This sample aims to strike a balance between being simple and lightweight enough to be easy to learn from, and involving enough non-trivial ECS game code (AI, spatial queries, event-based logic, different unit/building types and roles, etc...) to make an interesting showcase.
https://github.com/Unity-Technologies/ECSGalaxySample
#ecs #dots #sample
GitHub
GitHub - Unity-Technologies/ECSGalaxySample: ECS sample demonstrating an automated simulation of teams of spaceships fighting for…
ECS sample demonstrating an automated simulation of teams of spaceships fighting for the control of planets - Unity-Technologies/ECSGalaxySample
👍11🔥7
Chunk's Change Version
A detailed post on how .WithChangeFilter<T>() works in Entities
https://gametorrahod.com/change-version/
#dots #ecs
A detailed post on how .WithChangeFilter<T>() works in Entities
Then, there is a per-chunk number called ✏️ change version. How the chunk is considered "changed" in order to update this number is rather crude : Instantly when a query is executed related to that component and it has write permission. Then, chunks returned for that query will all get their ✏️ change version updated
It does not check whether system actually "change" the component's value with its work using the query. It just see the write dependency and thought the system "probably" changed that for all the matched chunks.
It is per chunk. There are other entities in the chunk that are not actually changed and still get iterated. Your logic must not be destructive to these entities. Try treating changed filter as optimization rather than branching logic, always imagine if the changed filter is removed, everything must still work like before but with worse performance
https://gametorrahod.com/change-version/
#dots #ecs
Game Torrahod
Chunk's Change Version
DOTS comes with a per-chunk versioning and a related filter feature. This feature can optimize processing the data only when it mattered.
👍3
List Add is way slower (almost 3 times) in
dotnet/runtime
This is an interesting discussion and investigation into why performance significantly drops on one of the platforms after optimization in net9.0. I always love reading how engineers solve complex problems. It's fascinating to see what changes under the hood can cause such big differences in performance and how they track down the issue.
https://github.com/dotnet/runtime/issues/101437
#performance
net9.0 preview 3 than with net8.0dotnet/runtime
This is an interesting discussion and investigation into why performance significantly drops on one of the platforms after optimization in net9.0. I always love reading how engineers solve complex problems. It's fascinating to see what changes under the hood can cause such big differences in performance and how they track down the issue.
https://github.com/dotnet/runtime/issues/101437
#performance
GitHub
List Add is way slower (almost 3 times) in `net9.0 preview 3` than with `net8.0` · Issue #101437 · dotnet/runtime
With the latest preview 3 (net9) there seems to be a major performance regression on MacOS 14.4 (M2 Pro) with lists. Given that they are one of the most used types, it should receive special treatm...
👍6🔥2
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, noscripts, 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, noscripts, 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
Unity Shader Variants Optimisation and Troubleshooting
When using shaders from the asset store it might become challenging to control shader variants leading to increased build size and time to prewarm it. It's a good post to bookmark and get back to it during your project check ups.
https://dev.to/attiliohimeki/unity-shader-variants-optimisation-and-troubleshooting-28ci
#optimization #shader #shadervariants
When using shaders from the asset store it might become challenging to control shader variants leading to increased build size and time to prewarm it. It's a good post to bookmark and get back to it during your project check ups.
https://dev.to/attiliohimeki/unity-shader-variants-optimisation-and-troubleshooting-28ci
#optimization #shader #shadervariants
DEV Community
Unity Shader Variants Optimisation and Troubleshooting
Note: This blogpost is also available on Unity's official blog:...
👍5🔥5
CPU performance optimization guide - part 1 - CPU performance optimization guide
A great example of how to profile CPU performance at the lowest level. From my experience, you very rarely need to dive this deep in your daily work. However, if a method is on the hot path and invoked many times per frame, and all low-hanging fruit optimizations are done, then you definitely need this post bookmarked for future reference
https://gpuopen.com/learn/cpu-performance-guide/cpu-performance-guide-part1/
#profiling #cpu
A great example of how to profile CPU performance at the lowest level. From my experience, you very rarely need to dive this deep in your daily work. However, if a method is on the hot path and invoked many times per frame, and all low-hanging fruit optimizations are done, then you definitely need this post bookmarked for future reference
https://gpuopen.com/learn/cpu-performance-guide/cpu-performance-guide-part1/
#profiling #cpu
Gpuopen
CPU performance optimization guide - part 1 - AMD GPUOpen
This series of blogs will walk readers through the analysis of the problems encountered in actual projects, thus helping them to better understand the CPU performance optimization of programs.
🔥4👍2
Introducing our new e-book: Unity’s Data-Oriented Technology Stack (DOTS) for advanced developers
Here's an overview of DOTS. Many people think DOTS is just ECS, but there are multiple packages and tools under this umbrella.
Of course, ECS is a big part of DOTS, which is why half of the book is about it, but you might be using DOTS without even knowing it, as some packages are jobified, and use burst/native collections under the hood.
https://blog.unity.com/engine-platform/new-ebook-understanding-unity-dots
#dots #book
Here's an overview of DOTS. Many people think DOTS is just ECS, but there are multiple packages and tools under this umbrella.
Of course, ECS is a big part of DOTS, which is why half of the book is about it, but you might be using DOTS without even knowing it, as some packages are jobified, and use burst/native collections under the hood.
https://blog.unity.com/engine-platform/new-ebook-understanding-unity-dots
#dots #book
Unity
Introducing our new e-book: Unity’s Data-Oriented Technology Stack (DOTS) for advanced developers
Unlock Unity DOTS secrets with this free e-book, perfect for advanced devs.
👍6🔥2
ECS Programming Patterns from Official Packages
A list of advice how to perform common operations in unity.entities with examples from the entities package internals.
I also have personal notes with tips from the Hot Path Show that I found interesting, and they are pretty similar to what is shared in that post, e.g. tricks how to create new entities with the set of components without allocating a managed array of types and without adding components one by one which is very inefficient in the archetypes ECS implementation. This show is usually around 2 hours so it takes time to gather all these tips and sit through the whole video, so not everyone watches it completely. Put a 💯 reaction if you'd like me to publish it in a similar form to the post with top tips from Unite.
https://gametorrahod.com/ecs-patterns/
#dots #ecs
A list of advice how to perform common operations in unity.entities with examples from the entities package internals.
I also have personal notes with tips from the Hot Path Show that I found interesting, and they are pretty similar to what is shared in that post, e.g. tricks how to create new entities with the set of components without allocating a managed array of types and without adding components one by one which is very inefficient in the archetypes ECS implementation. This show is usually around 2 hours so it takes time to gather all these tips and sit through the whole video, so not everyone watches it completely. Put a 💯 reaction if you'd like me to publish it in a similar form to the post with top tips from Unite.
https://gametorrahod.com/ecs-patterns/
#dots #ecs
Game Torrahod
ECS Programming Patterns from Official Packages
We can learn interesting programming patterns from Unity's own packages that references Unity.Entities.
👍6💯5🔥1
.NET 9: Array vs Dictionary lookup performance in C#
I wanted to revisit my old post about the performance of lookup operations in dictionaries and arrays to see how all the performance improvements in newer .NET versions affect old benchmarks. TL;DR: The benchmark shows that dictionary lookups are around 2 times faster in .NET 9 compared to Framework 4.8. This means there is now less sense to use arrays to speed up lookups in small collections.
This does not apply to Unity yet, though they promise CoreCLR integration, so it might become useful someday
https://gamedev.center/net-9-array-vs-dictionary-lookup-performance-in-c/
#performance #lookup
I wanted to revisit my old post about the performance of lookup operations in dictionaries and arrays to see how all the performance improvements in newer .NET versions affect old benchmarks. TL;DR: The benchmark shows that dictionary lookups are around 2 times faster in .NET 9 compared to Framework 4.8. This means there is now less sense to use arrays to speed up lookups in small collections.
This does not apply to Unity yet, though they promise CoreCLR integration, so it might become useful someday
https://gamedev.center/net-9-array-vs-dictionary-lookup-performance-in-c/
#performance #lookup
👍6🔥1
When Your Game Is Bad But Your Optimisation Is Genius
3 simple optimisations that you can use to make your game run up to 10 times quicker.
Not a Unity video, but still can be easily applied to a Unity game. I have done similar optimizations to the terrain a long time ago in my own mobile game and got a significant boost.
https://www.youtube.com/watch?v=5zlfJW2VGLM
Repo: https://github.com/vercidium-patreon/glvertexid
#optimisation #terrain
3 simple optimisations that you can use to make your game run up to 10 times quicker.
Not a Unity video, but still can be easily applied to a Unity game. I have done similar optimizations to the terrain a long time ago in my own mobile game and got a significant boost.
https://www.youtube.com/watch?v=5zlfJW2VGLM
Repo: https://github.com/vercidium-patreon/glvertexid
#optimisation #terrain
YouTube
When Your Game Is Bad But Your Optimisation Is Genius
The source code and demos are available here: https://patreon.com/vercidium
An extra heightmap renderer is available here: https://github.com/vercidium-patreon/glvertexid
I spent the past 6 years creating a game engine, and I've been shocked at the things…
An extra heightmap renderer is available here: https://github.com/vercidium-patreon/glvertexid
I spent the past 6 years creating a game engine, and I've been shocked at the things…
👍12🔥2
Unity 2D Radiance Cascade Demo
This repository provides a basic implementation of a global illumination technique based on the concept of Radiance Cascades, as described in the paper Radiance Cascades: A Novel Approach to Calculating Global Illumination.
The illumination algorithm is applied as a post-processing effect on the main camera.
The repository includes two versions of the algorithm:
3D Texture Implementation: For easy understanding of the technique.
2D Texture Implementation: For greater portability across different platforms.
I have tested it with different resolutions, and the highest one has put my high-end GPU to work taking 22 ms per frame. Would be interesting to check it in a real project and play around with values to find an optimal compromise.
https://github.com/ZY4N/Unity-2D-Radiance-Cascade-Demo
#computeshader #raytracing #lighting
This repository provides a basic implementation of a global illumination technique based on the concept of Radiance Cascades, as described in the paper Radiance Cascades: A Novel Approach to Calculating Global Illumination.
The illumination algorithm is applied as a post-processing effect on the main camera.
The repository includes two versions of the algorithm:
3D Texture Implementation: For easy understanding of the technique.
2D Texture Implementation: For greater portability across different platforms.
I have tested it with different resolutions, and the highest one has put my high-end GPU to work taking 22 ms per frame. Would be interesting to check it in a real project and play around with values to find an optimal compromise.
https://github.com/ZY4N/Unity-2D-Radiance-Cascade-Demo
#computeshader #raytracing #lighting
🔥5👍1
Parsing JSON Really Quickly: Lessons Learned
1. No branching
2. Don't process byte by byte, use SIMD
3. Avoid memory allocations
4. Measure the performance (CI performance tests)
How simdjson is made that parses gigabytes of JSON per second. There are also a few performance tricks related to parsing.
And there is a very interesting comment under the video:
Which is even more true nowadays with a wider adoption of e-cores and p-cores in modern CPUs.
https://www.youtube.com/watch?v=wlvKAT7SZIQ
#performance
1. No branching
2. Don't process byte by byte, use SIMD
3. Avoid memory allocations
4. Measure the performance (CI performance tests)
How simdjson is made that parses gigabytes of JSON per second. There are also a few performance tricks related to parsing.
And there is a very interesting comment under the video:
43:37 "cause you're assuming that the person running your program is not switching the CPU under you". The audience might be laughing, but this actually is sometimes a case, even in consumer hardware. Non-US Samsung Galaxy S9 has a heterogenous CPU, with some cores supporting the atomic increment instruction LDADDAL and others not, and with Linux kernel modified by Samsung to report that all cores support that instruction. Your program would crash after being rescheduled to another core.
Which is even more true nowadays with a wider adoption of e-cores and p-cores in modern CPUs.
https://www.youtube.com/watch?v=wlvKAT7SZIQ
#performance
👍10🔥1
Everyday Unity
Unity 2D Radiance Cascade Demo This repository provides a basic implementation of a global illumination technique based on the concept of Radiance Cascades, as described in the paper Radiance Cascades: A Novel Approach to Calculating Global Illumination.…
Exploring a New Approach to Realistic Lighting: Radiance Cascades
The video explaining the theory behind a novel lighting approach. I also shared an open source implementation in Unity a while ago.
https://www.youtube.com/watch?v=3so7xdZHKxw
#lighting #radiancecascades
The video explaining the theory behind a novel lighting approach. I also shared an open source implementation in Unity a while ago.
https://www.youtube.com/watch?v=3so7xdZHKxw
#lighting #radiancecascades
YouTube
Exploring a New Approach to Realistic Lighting: Radiance Cascades
Radiance Cascades are an innovative solution to global illumination from the devs of Path of Exile 2. Let's explore and implement their approach.
Gamedev Courses: https://simondev.io
Support me on Patreon: https://www.patreon.com/simondevyt
Follow me on:…
Gamedev Courses: https://simondev.io
Support me on Patreon: https://www.patreon.com/simondevyt
Follow me on:…
🔥3👍1
A genshin-like post processing render feature, based on URP.
https://github.com/kaze-mio/UnityGenshinPostProcessing
#renderfeature #urp #postproccess
https://github.com/kaze-mio/UnityGenshinPostProcessing
#renderfeature #urp #postproccess
👍6🔥3
SanderMertens/ecs-faq: Frequently asked questions about Entity Component Systems
A good starting point to dive into ECS. There is a strong emphasis on the performance of ECS, and while it is mentioned, it is not stated clearly that ECS is not always about performance. Primarily, it is an architectural approach. With the right design — both in terms of framework and game design — it can significantly benefit performance, but this is not guaranteed by default.
https://github.com/SanderMertens/ecs-faq
#ecs
A good starting point to dive into ECS. There is a strong emphasis on the performance of ECS, and while it is mentioned, it is not stated clearly that ECS is not always about performance. Primarily, it is an architectural approach. With the right design — both in terms of framework and game design — it can significantly benefit performance, but this is not guaranteed by default.
https://github.com/SanderMertens/ecs-faq
#ecs
GitHub
GitHub - SanderMertens/ecs-faq: Frequently asked questions about Entity Component Systems
Frequently asked questions about Entity Component Systems - SanderMertens/ecs-faq
🔥4👍3
Which collection interface to use?
Tl;dr:
https://enterprisecraftsmanship.com/posts/which-collection-interface-to-use/
#design #api
Tl;dr:
Use the most generic types possible for arguments,
Use the most specific types possible for return values
Adhere to the following guideline.
Use IEnumerable for arguments as the most generic type possible.
Use IReadOnlyList for return values as the most specific type possible.
IQueryable is a leaky abstraction because it requires you to know which LINQ expressions the ORM can understand.
IList and Array aren’t suitable because they are mutable.
Keep in mind that some implementations of IEnumerable are also leaky abstractions
https://enterprisecraftsmanship.com/posts/which-collection-interface-to-use/
#design #api
Enterprise Craftsmanship
Which collection interface to use?
Let’s talk about when to use which collection type and why.
🔥3👍2👎1
Choosing the right network model for your multiplayer game
A good starting point, with references for in-depth investigation, to help you choose the right network model for your game by going over the list of questions the author provides and high level denoscriptions
https://mas-bandwidth.com/choosing-the-right-network-model-for-your-multiplayer-game/
#netcode
A good starting point, with references for in-depth investigation, to help you choose the right network model for your game by going over the list of questions the author provides and high level denoscriptions
https://mas-bandwidth.com/choosing-the-right-network-model-for-your-multiplayer-game/
#netcode
Más Bandwidth
Choosing the right network model for your multiplayer game
Don't fuck it up. Pick the correct one for your game.
🔥5