0
foundry-logo-news

News & Updates

2020-08-16

Foundry Dev Blog #3 - Performance Challenges

Performance Challenges [Technical]

Another week has passend and the overall game performance has increased, however not by a lot and this brings me to today's blog post: Performance Challenges!

I took a deeper delve into the internals of Unity and it's IL2CPP compiler. What I found was both surprising and underwhelming: The generated C++ source code is a lot worse than I imagined it to be. It is full of weird pitfalls, that - at least in my opinion - should be made much clearer by the Unity team. Even very simple methods generate a lot of overhead unless you evade certain patterns like static variables (one of the easier things to avoid). I won't go much into technical details as I don't think that it would be very interesting, nor am I an expert on the issue. Luckily I was able to find a blog that is written by an expert about those topics. I recommend to check it out in case you're interested in IL2CPP and other Unity-internal things (very technical, probably only for other developers). The gained insight was really helpful on one hand but showed me on the other hand that getting IL2CPP to produce the quality code our project needs is going to be painful. What surprised me was how slow even custom non-Unity-related logic gets and that almost every method call generates a very large overhead, even with all safety features disabled.

That means that we need to shift our design philosophy a bit and that we need to avoid IL2CPP as much as possible for performance critical things by moving it to our custom native library. As I don't want to pin the project to a certain Unity version right now, there is no other option since the IL2CPP compiler could change at any time and it might ruin all the tedious patterns we implemented just to cater to it.

Therefore our current priority is to move as much simulation code to our native C++ codebase. P/Invoke calls come with an overhead as well, but it's negligible. It's not a perfect solution as maintaining two projects is not great for productivity, but it's our only bet at the moment. For the long run we will look into other ways of getting where we'd like to, but for now we want to provide a good Early Access performance and we want to reach that point as quickly as possible. Again I cannot give you any fix ETA, but we still hope to make it for a "this summer" release.

Additionally to the changes above there is room to improve some of the game algorithms in general, we are concurrently working on that too.

‍More Playtesting

Overall the changes will be pretty large, therefore we're going to need another round of testing afterwards before we can finally release it. In case you're interested to play-test a mostly untested game version (you have to expect bugs and maybe crashes) you can apply on our Discord and get in touch. We're always looking for help and feedback.

‍Preparing The Release

We plan to provide more insight on the launch strategy with the blog post next week. We're currently working out the last details on where to sell the game and how we plan to grow, also preparing shop site(s) and doing all the PR things necessary.

-mrmcd