It has been seven years since GTA Online launched and while the game makes a serious amount of cash for Rockstar, the game has an obscenely long load time. Regardless of the machine, be it a high-end PC or a PS5, getting into GTA Online takes minutes. If you look on Reddit, there are so many half-baked theories trying to explain why the loads take so long. Besides blaming bad PCs, internet speeds, NAT settings and mods, they point out how advanced the game is, or the game trying to put friends together or how there is a problem with your copy of the game.
It turns out someone at Rockstar just used a pretty daft way to process information and one external programmer, without access to source code or assets, was able to cobble together something that drops load times by 70%.
t0st’s blog post on how they did it is fascinating as he tries to work out what the problem is using various highly advanced tools, like MS Paint and Windows Task Manager. After a minute of loading, CPU load ramps up, while disk, GPU and network drop off. So it turns out that it isn’t the online part that is slowing things down. Worse yet, all of that CPU time is just a single thread working something out.
t0st digs deeper, looking at the running program’s stack and found two bottlenecks. They then disassemble and process dump to get to the problem. The game was reading through a text file of every purchasable item, which is 63,000 items in a 10MB text file. Every time it reads a single item, the CPU has to count ever character in this long list again. That is a lot of extra work for nothing.
Then to make it worse, the game records both the data associated with each item in the list, and a hash of that item. Each time an item from the list is stored, it checks the hash value against every other item that has been stored. With 63,000 items, this means close to 2 billion checks are being done, all by a single thread of your GPU. The reason for all this? To make sure there are no duplicates in the list. Yes, the list that starts empty and just loads everything in once.
t0st made two fixes, one that counts the length of the list of items once, and just feeds that answer to the code whenever it asks, instead of doing a recount. Then another fix that avoids the hash check completely, skipping those two billion checks.
Using both of these fixes changes the load time of GTA Online from six minutes to one minute and 50 seconds. If you play GTA Online, just think how much time you have wasted just looking at load screens that seem pretty unnecessary.
Rockstar, please fix your seven-year-old game that you make so much money off of.