r1sc / Open76

Interstate '76 engine reimplementation
GNU General Public License v3.0
52 stars 3 forks source link

Startup Time Improvements #12

Closed JJJohan closed 5 years ago

JJJohan commented 5 years ago

At risk of 'premature optimisation', I wanted to try and speed up the load times a bit since the original game seems to start up quite quickly.

I've made sure to leave the internals of the virtual file system hidden from the rest of the system. The only thing that did get changed in a few of the file parsers was the replacement of BinaryReader instances with a custom FastBinaryReader implementation. The Bwd2Reader also uses this internally now.

This has sped up load times by around 50-70% (at least on my machine), although it feels more like 30% in the editor due to the editor overhead. While this means a difference of at most maybe a second or two in multiplayer missions, this has a more noticeable impact on larger single player missions.

I've not experienced any issues loading assets after the changes (well - not more than before anyway)

Before: before

After (at the expense of around 30MB extra memory): after

No I did not use 'deep profiling' in the 'before' screenshot to cheat 😜.

Unfortunately I didn't do a good job of separating out the commits from other branches.. Once the other two pull requests are in you'll find there's not many files changed.

r1sc commented 5 years ago

I'm just gonna take your word for it and merge it. You're working really fast here and I don't want to stand in your way, go go go! 🥇

r1sc commented 5 years ago

Damn this broke loading of geometry and textures for me. I have the retail version, did you change anything that could have affected meshes and textures?

image

JJJohan commented 5 years ago

Whoops. I've noticed there's some subtle differences between the retail version and the Gog-release (presumably the retail version with a number of patches).

Fortunately I do have both, so I'll take a look when I get home why that's happening.

At least there's no errors right 😝.