Monday, January 30, 2012

Improving performance and memory usage

Improving performance and memory usage has been planned for a very long time,
as I believe (especially considering limited resources) that features/functionality and bug-fixes take a much greater priority.

However, performance as well as usability are two things that do sell the product to the user, and make it easy and fun to use.

Both Performance and Usability are on the menu right now, and while both will take a while to properly improve, I have already made great progress in regard to performance.

First a couple of things on Performance and Memory usage:
  • SU is written in a managed language (well two actually; .NET (C#) and IronRuby).
    This gives a lot of programmer comfort, but at the same time often results in lower performance, and higher memory usage (or slower return of free memory), compared to unmanaged languages like C++ or C.
  • SU uses .NET WPF UI which is vector based, has to realtime render the UI on screen (like a game), and generally is less optimized than legacy frameworks like Windows Forms.
  • SU's database back-end is based on SQLite (considered slow, and useful only for basic applications), and suffers from several issues caused by experimental IronRuby implementation.
  • IronRuby's experimental nature poses several complications that require workarounds, e.g doing things not the optimal way.
  • (over)Optimization generally complicates the development process and can limit a developer's creativity and progress
  • Performance is only important where it makes a real difference. E.g waiting 10ms or 1ms on an action to complete is not even noticeable by a human.
    But of course if you do 1000 of those actions, suddenly it's 1 second or 10 seconds; a very noticeable difference, but if it actually matters is depending on the performed action, and user's expectation.
I prefer programmer comfortability, and I prefer the Ruby and .NET (C#) languages, as well as the WPF UI framework,
So going for a leaner programming language, or even low-level like C++ and C, is not a realistic option for me.

That said, there are several ways to improve the performance and memory usage:
  • Replace the limited SQLite database back-end by something better.
  • Improved Code (obviously).
    Better, faster code that accomplishes (basically) the same thing in a shorter amount of time (using less resources)
  • Move more data, and processing over to the server-side
Last weekend I have started with replacing the limited SQLite database back-end, with a custom, imo better solution: Serializing the objects and marshalling them from and to disk.

The result is that we're freed from the SQLite limitations, and the limitations of the IronRuby database driver, and all the issues that came forth from that, as well as the countless workarounds that I had to implement for this.

Which in turn gives us a great return value on Performance and Memory usage:
  • Startup time decreased by 2x up to as much as 10x
  • Sync with SU portal time decreased by 2x up to as much as 5x
  • Sync with Gamespy time decreased by 2x up to as much as 5x
Also the changes make it possible to switch to a different back-end more easily in the future, e.g a .NET ORM etc.

Coming days I will be finishing the implementation and a new test version should become available probably by next weekend.
I feel this is already a significant improvement, and there will be even more improvements possible in the future, through the other mentioned means.

After Performance,  Usability will become the topic of coming months... stay tuned!

For those interested in what WPF is and what the difference is to Windows Forms, have a look here.

Thursday, January 5, 2012

Six Updater 2.9pre4 released

Small Six Updater v2.9 update:

New version released with support for Min and Max game version or build constraints on Mods.

For instance, there's now @JayArma2Lib that still supports the older game versions, and the new @JayArma2Lib_new which supports the newer game versions.
Depending on your currently active game version (determined by Beta if beta is enabled), the correct version of JayArma2Lib will be loaded.

A couple of more issues were solved:

More Six Updater v2.9 news to come soon.