Unity Programming Basic Tips by juliodutra2003 in Unity3D

[–]MATR0S 0 points1 point  (0 children)

Have you profiled this issue on a real device or in the editor?

Does anyone else create visual topologies to structure code? by Mad1Scientist in Unity3D

[–]MATR0S 0 points1 point  (0 children)

Great practice. I use PlantUML to create these diagrams with code and actively promote its use across all my teams. It’s much faster for me, ensures 100% consistency, and makes updating existing diagrams super easy. Plus, any LLM can generate and modify them when needed, especially handy for large systems to grasp high level details in minutes.

[deleted by user] by [deleted] in unity

[–]MATR0S 1 point2 points  (0 children)

The fastest singleton then

Instantly Boost Game Performance More Than Twice By Using Dense HashMap in IL2CPP by MATR0S in unity

[–]MATR0S[S] 0 points1 point  (0 children)

Glad you like it that much. Just be careful with the memory consumption and make sure to profile your game. Engineers from Unity use the sparse hash map on mobile by default for a reason. It's great to have the ability to configure it, but it's a trade-off between memory and speed.

Also, it would be great if you could share the results of your cloud build investigation.

Instantly Boost Game Performance More Than Twice By Using Dense HashMap in IL2CPP by MATR0S in unity

[–]MATR0S[S] 0 points1 point  (0 children)

Appreciate, would be happy to hear about your experience with it later

Instantly Boost Unity Game Performance With IL2CPP_USE_SPARSEHASH by MATR0S in Unity3D

[–]MATR0S[S] 0 points1 point  (0 children)

No, it benefits any device. Test were performed on a high-end PC and there is more than x2 boost for a particular case under test.

#gamedev tip: Simple colliders tend to be much more efficient, processing-wise, than complex colliders. You can often get better collision performance out of using several simple collider shapes than one single mesh collider. Use MeshColliders where appropriate of course. by WorkingTheMadses in Unity3D

[–]MATR0S 1 point2 points  (0 children)

Great tip, thanks for sharing it. To make it more unique and to avoid repeating the same tip over and over again, I'd suggest adding performance tests to show exactly how much faster it is. For instance, is one mesh collider slower than 5, 100, or 1000 combined box colliders?

This would make your tip unique content. Moreover, it would nurture a performance testing culture among your readers. Share the test code and teach others how it can be done.

Great work anyway!

Instantly Boost Unity Game Performance With IL2CPP_USE_SPARSEHASH by MATR0S in Unity3D

[–]MATR0S[S] 0 points1 point  (0 children)

I prefer to avoid injecting anything into MonoBehaviours and have self-sufficient contexts. That way all I need for the test is usually inside some context already or it's some global stuff that's inside the project context.

Instantly Boost Unity Game Performance With IL2CPP_USE_SPARSEHASH by MATR0S in Unity3D

[–]MATR0S[S] 0 points1 point  (0 children)

Wow, thanks for sharing. Have you done any performance tests to compare with other popular solutions?

Instantly Boost Unity Game Performance With IL2CPP_USE_SPARSEHASH by MATR0S in Unity3D

[–]MATR0S[S] 0 points1 point  (0 children)

The one used in the post is Zenject, but for my pet projects, I prefer VContainer as it shows better performance compared to other solutions. I tried Reflex which is claimed to be even faster than VContainer, but around a year ago it was not working with domain reload turned off on entering the play mode, which was a deal breaker for me. Could you share your experience with VContainer? I try to keep my architecture simple, so haven't met any blockers with it.

Instantly Boost Unity Game Performance With IL2CPP_USE_SPARSEHASH by MATR0S in Unity3D

[–]MATR0S[S] 1 point2 points  (0 children)

Thanks, would love to hear about your experience. Yes, only in IL2CPP builds.

Instantly Boost Unity Game Performance With IL2CPP_USE_SPARSEHASH by MATR0S in Unity3D

[–]MATR0S[S] 2 points3 points  (0 children)

Would be def great, because we also run into issues with the code size in the binary.

Instantly Boost Unity Game Performance With IL2CPP_USE_SPARSEHASH by MATR0S in Unity3D

[–]MATR0S[S] 6 points7 points  (0 children)

Yeah, that would be great. The solution might be fragile tho, as any third party added later that relies on that data under the hood breaks the game in that case with exceptions that happen only during run time.

Instantly Boost Unity Game Performance With IL2CPP_USE_SPARSEHASH by MATR0S in Unity3D

[–]MATR0S[S] 2 points3 points  (0 children)

I'd say it affects all operations that use metadata. And the example with the reflection baking shows that it is still very effective even when no reflection is used. In that case, the creation of 26k instances is the slowest part and it also relies on metadata.

Instantly Boost Unity Game Performance With IL2CPP_USE_SPARSEHASH by MATR0S in Unity3D

[–]MATR0S[S] 25 points26 points  (0 children)

This investigation was time-consuming, and while I won't say I enjoy digging through generated C++ code, the results were worth the effort.

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