Thursday, 4 June 2009

Getting going quicker

Much as I'd like to, I can't deny that Moviestorm does take a while to start up and get itself sorted out before you can actually do anything with it. I can tell how frustrating this is from the swearing around the office as people go get a cuppa or even nip out for a haircut while waiting for Moviestorm to load. This isn't so much due to the engine, but to to the huge amount of data that Moviestorm has to load to tell it what costumes, props, animations, etc are available, how to use them, and a whole load more besides.

Much of the reason that Moviestorm is slow is the enormous pile of little files that it has to scan. Individual files are convenient for the artists to generate and easy for us to work with, but not nearly so convenient for the operating system to load. Not to be an Apple fan-boy here, but Windows is particularly bad at scanning directories and reading in lots of squitty little files. Each file only takes a few milliseconds to open up and peer into, but when you have literally thousands of them, it all adds up to quite a horrendous load. But it doesn't have to be this way, and it's changing. What I'm doing is to take a leaf out of most games and designed some new "pack" formats for our AddOns. This bundles up loads of files together, and hugely reduces the overhead of opening files.

For example, one of the big delays in starting up Moviestorm was reading in all the metadata for characters and props (descriptors, templates, etc). Since this involved scanning the file system to find them and then parsing each file, this could take quite a while (easily a minute or more with a lot of AddOns loaded). The metadata are now all published in a single file that can be scanned for content really fast and then loaded on demand. As a result, this phase of the start-up process has been drastically reduced, and now typically only 5-10 seconds!

Meshes used to be painfully slow to load, but now all the meshes in an AddOn are packed into a single file and in the same format that OpenGL needs to send directly to the GPU. This makes loading characters and props much, much faster.

As well as looking at getting the data into Moviestorm faster, I've also been investigating the start-up process and what gets loaded when. Some of the stuff that Moviestorm does in the start-up phase isn't actually needed until later (typically, not until we get on set). So those bits of the process have been hived off onto worker threads, carrying on in the background and which will only cause a pause if it hasn't finished by the time it's needed.

The upshot of all this so far is that Moviestorm now gets to the first screen within about 5 seconds, and most of that time is just loading the binary, setting up OpenGL and other unavoidable bits of work. The main pause is now when you start a new movie or load a movie, but even then, you should get on set within about 30 seconds.

I haven't finished this job yet, so hopefully we'll shave a few more seconds off here and starting Moviestorm should become a real slick experience, comparable with starting World of Warcraft, Fallout 3 or anything from Steam. However, you'll notice the difference right away.

4 comments:

AngriBuddhist said...

This is fantastic. Nice job Dave. Not that it's that important, but, does any of this improve the load time of the Modshop?

Dave said...

Most of my improvements don't help the Modshop as I've been focussing on loading published addons fast whereas the Modshop needs to see the raw files. However Conor is planning some significant improvements in building the asset tree more lazily.

Iain said...

Well on the face of it, this is terrific news. But... I use that load time to reflect on the day that's been, to think about my hopes and dreams for the future, and often to watch a movie (Slumdog next).

What will become of my life if Moviestorm goes all "efficient"?!

蕭敬騰alex said...
This comment has been removed by a blog administrator.