GTA Online remains a popular game seven years after launch, thanks to the steady influx of new content, but one thing Rockstar seems unable to improve is the game’s famously long load times. Over the weekend, an enterprising developer called t0st finally discovered why GTA Online takes so long to load even on machines with fast processors and storage such as the PlayStation 5 and PC and fixed those issues, reducing his load times by 70 per cent.
A hacker who goes by T0st looked into what might be causing his six-minute load times. After dumping the process stack, he discovered two bottlenecks that maxed out a single CPU thread. A poorly written routine was inefficiently parsing a 10MB JSON file containing over 63,000 items
As it turns out, the JSON file housed items purchasable through in-game shops (not to be confused with microtransactions). The routine reads each entry in the file and then stores it in an array. With each pass, it rechecks the entire array for duplicates before inserting the new item. As can be imagined, this process gets longer and longer as the array grows.
To fix the problem, T0st created a DLL that eliminates the two bottlenecks. The first fix “caches” long string lengths.
“If it’s called again within the string’s range, [it will] return [the] cached value,” T0st writes.
Since this fix eliminates repeat entries, the duplicate check is no longer necessary. So the second part of the DLL simply inserts the values into the array.
With both fixes in place, GTA Online loads way faster. On t0st’s PC, avoiding the duplicate items check cuts the load time from six minutes to four-and-a-half minutes, and adding in the item loading fix as well brings this down further, to just one minute and 50 seconds. That’s a 69.4 per cent reduction in load times, which is absolutely incredible given that it required modification of only two functions.