Author Topic: AI War stressing Unity  (Read 2814 times)

Offline TechSY730

  • Core Member Mark V
  • *****
  • Posts: 4,570
AI War stressing Unity
« on: October 18, 2010, 11:15:41 pm »
After reading over many of the bug reports and your posts on the Unity forums, it seems that AI War is actually uncovering some fundamental performance and API limitations in both Unity and Mono 2.6, issues that don't seem like they have been encountered before in other development projects.
Do you think there is any reason why AI War is so unique? I'm guessing that it has something to do with the fact that AI war uses a HUGE number of small objects, rather than a medium number of small-medium sized objects like most other programs.
Also, I hate to even think about this, but if these performance and API limitations won't be able to be fixed until the next major release of Unity, will you have to find and port to another engine again?
Note that some of these issues are not small or ignorable; the stutter per 11 seconds and the crash on going to locked screen (64-bit only) are both big enough to hold back a commercial release, and the both seem to be fundamental problems with Unity and Mono 2.6, meaning you are stuck with them in this engine.

Sorry for the long post, but these are rather technical questions. (Yes, I am a CS major, how could you tell  :P)

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
Re: AI War stressing Unity
« Reply #1 on: October 18, 2010, 11:20:59 pm »
We're going live with a public release in a week, and we're definitely not changing platforms anytime soon.

The maximum number of fundamental in-game objects that unity natively seems to support comfortably is around 10k or so. Maybe it can do more, but with 10k it was getting pretty slow.  We have 10x that or more, generally, so we had to adapt the engine quite a lot.  I don't think you've been following as close as you think, as most of the issues you allude to were long-since resolved.  The stutter was 8 seconds a week ago, then 26 seconds before the weekend, and now it's something infinitesimal. 

Additionally, the crash on going to the lock screen is annoying and unfortunate, and we do have a bug report with unity open about that, but it would be crazy to delay a commercial release for something like that.  The odds of someone running into that are pretty low.

In short: all is well, the few hiccups that remain are pretty minor or unusual-to-trigger.
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline TechSY730

  • Core Member Mark V
  • *****
  • Posts: 4,570
Re: AI War stressing Unity
« Reply #2 on: October 18, 2010, 11:28:20 pm »
Okay thanks. I guess I was over reacting. And my suggestion to port to another platform was not really serious.  ;)

Good to know you got the stuttering fixed. How did you manage to "wrestle" the garbage collector into submission?

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: AI War stressing Unity
« Reply #3 on: October 18, 2010, 11:29:04 pm »
Almost all of these problems have been encountered by other projects using the Unity engine, and the Mono-related ones have been encountered by projects using Mono.  Why do you think Mono 2.8 has an experimental new garbage collector that's orders of magnitude better? ;)

I'm guessing that it has something to do with the fact that AI war uses a HUGE number of small objects, rather than a medium number of small-medium sized objects like most other programs.
That is one of the challenges, yes, and we had to convert away from actually using their "GameObject" (I may have the name wrong) class for the actual sprite entities and drop down to a more primitive insert-point for their rendering pipeline (using DrawMesh now).  That said, the performance is not way worse than SlimDX, we're just dealing with a new engine after having worked out tons of efficiency tricks on SlimDX, so there's a learning curve we'll be climbing as we move forward.

Quote
Also, I hate to even think about this, but if these performance and API limitations won't be able to be fixed until the next major release of Unity, will you have to find and port to another engine again?
The problems are not nearly that bad.

Quote
Note that some of these issues are not small or ignorable; the stutter per 11 seconds
Are you still seeing the stutter per 11 seconds?  We got the transient memory allocation way down and it doesn't invoke the GC nearly as often.

Quote
and the crash on going to locked screen (64-bit only)
This is the biggest one left, and there are a few semi-solutions but basically yea, if you play on a 64-bit OS and play multiplayer the required functionality is not compatible with the ctrl+alt+del menu.  Single-player does not strictly require that the app run in the background (which is the problem we're having), though changing it just for that could lead to other problems.  I have a couple other ideas that may be able to "fix" this by simply getting the cursor position an entirely different way, etc.

Quote
are both big enough to hold back a commercial release
The stutter would have been if we had not been able to do anything about it, but we have.  And the ctrl+alt+del crash on 64-bit systems is not enough to hold back the release.

Quote
and the both seem to be fundamental problems with Unity and Mono 2.6, meaning you are stuck with them in this engine.
The GC thing is pretty fundamental, but it is workaround-able by simply making the game heap-static during most of the execution.  That's not easy, and it's taken many hours to get where we are, but it is doable.  The Ctrl+Alt+Del thing is not a fundamental problem with Unity in that all they have to do is make OnApplicationPause fire properly while Application.runInBackground == true, and we can simply stop checking for input while the app doesn't have focus and there will be no crashes.  Whether they actually will fix that I do not know, but while I was initially very skeptical of using a 3rd party engine I have found that the folks at Unity conduct business with both integrity and competence.

In short, the situation is not so dire as you think ;)  One lesson to learn in CS is that there is very nearly always a way to get around something, you just have to rethink the assumptions, requirements, and end-conditions, etc.

Edit: ninja'd by Chris, as usual
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
Re: AI War stressing Unity
« Reply #4 on: October 18, 2010, 11:32:08 pm »
Edit: ninja'd by Chris, as usual

You were more thorough, though. :)
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!