Hacker improves GTA Online load times by 70 percent with a simple DLL

Cal Jeffrey

Posts: 2,866   +746
Staff member
When devs fail, DIY: Gaming mods are a dime a dozen, especially for Grand Theft Auto Online. But occasionally, someone comes along with one that is so good and yet so basic that you wonder why the developer didn't do the same thing in a patch. One hacker has shown a fix for load times that is so simple you'll wonder why Rockstar didn't take care of it years ago.

Without a doubt, Grand Theft Auto Online's load times are atrocious. A non-scientific poll conducted on Reddit last summer revealed that most were waiting three to six minutes for the game to start and more than 35 percent of players had load times longer than six minutes. In the worst-case scenarios, wait times were over 15 minutes.

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.

The results of these two patches are pretty remarkable. With only the duplication check fix installed, load time was modestly reduced from six minutes to 4.5 minutes. The JSON parser was much more effective, lowering the wait to two minutes, 50 seconds, and implementing both patches into the DLL improved load time by about 70 percent (or 1m 50s).

Results may vary depending on rig configuration, but the optimizations should improve loading speeds significantly for any setup.

T0st posted the proof of concept to GitHub if you're interested, though he warns that injecting it while online might get you suspended. His writeup on how he found and fixed the problem is a pretty good read, too. He hopes that Rockstar will get wind of his PoC and issue an official patch, which is not an unreasonable ask for the studio's seven-year-old cash cow.

"If this somehow reaches Rockstar: the problems shouldn't take more than a day for a single dev to solve," he writes. "Please do something about it."

Yes. Please do.

Permalink to story.

 

terzaerian

Posts: 662   +926
Rockstar is the Apple of video game developers; they enjoy this reputation for quality that's really unearned and baseless and based on marketing. It'd be nice if lawmakers were scrutinizing them for this sort of thing instead of "muh violent vidya games"
 

Experimentongod

Posts: 324   +165
I stopped logging in GTA V to get the $200k weekly reward from Amazon Prime Gaming due to the atrocious load times. I don't understand why they don't fix it, it was obvious that something weird was going on in their code.
 

ikesmasher

Posts: 3,087   +1,478
Original blog post fascinating. That is some REALLY bad code design, like really bad. Amazing work finding and fixing it without source, but that should have been caught and fixed before release...let alone linger for almost a decade knowing that people literally don't play that game because of its load times. I don't think it would be completely unreasonable to say they've missed out on tens (more?) of millions of dollars because of this.

They literally already have a unique hash for each object...but they check every single item in the array. Hash tables/maps are like, sophmore (junior?) CS major topics...an intern would have caught this.
Edit: oh god I just realized I sound like someone on stack overflow what have I become
 

Irata

Posts: 1,305   +2,086
Great job. Shows what some clever thinking and attention to detail can do. And how using simple logic can greatly improve things.

Here‘s hoping misplaced pride on the part of Rockstar Games won‘t keep them from applying the fix.
 

terzaerian

Posts: 662   +926
They literally already have a unique hash for each object...but they check every single item in the array. Hash tables/maps are like, sophmore (junior?) CS major topics...an intern would have caught this.
Edit: oh god I just realized I sound like someone on stack overflow what have I become
It's symptomatic of Rockstar's lack of care and attention to detail for every non-PS platform. Their devs were dragged, I'm sure, kicking and screaming into making a PC port and shitty anti-cheat is one way they get back at that community for forcing the issue.
 

Hollow

Posts: 29   +12
It's funny to see that some people believe that fixing and publishing a patch for a game shouldn't take more than a day.
 

Dimitriid

Posts: 298   +518
I had the misfortune of trying to play GTA Online for a while. On top of all of the loading (SSD never helped at all and now we know why) the usual experience for a PC player was to log in, see somebody exploding you in the most blatantly cheaty ways or putting millions in money in front of you to then report you for cheating and getting you banned or just just ridiculous wall hacking, teleporting, etc. It's like a modern circus show to even try to share room with people using trainers for the PC version.

You can just use firewall rules and process time out to get yourself into a solo online lobby but at that point, why should you bother playing online if you have to be by yourself? Invite only for friends might be a bit of a novelty for new players but after a while most of the newer content is on public lobbies only and those are the wild west of cheaters so hard pass.

The one exception is people's unofficial private servers. Many of those have actually fun things to do and such and are actually somewhat moderated at times so you can have a reasonable and fun experience and in theory they shouldn't interfere with the official online side if you don't want to get banned but well, there's also just mods for offline or other online games anyway.
 

terzaerian

Posts: 662   +926
It's funny to see that some people believe that fixing and publishing a patch for a game shouldn't take more than a day.
In amateur hour developer Rockstar's case, I don't see why it shouldn't. They put clearly unvetted garbage code like this out for their flagship game, after all.

I had the misfortune of trying to play GTA Online for a while. On top of all of the loading (SSD never helped at all and now we know why) the usual experience for a PC player was to log in, see somebody exploding you in the most blatantly cheaty ways or putting millions in money in front of you to then report you for cheating and getting you banned or just just ridiculous wall hacking, teleporting, etc. It's like a modern circus show to even try to share room with people using trainers for the PC version.

You can just use firewall rules and process time out to get yourself into a solo online lobby but at that point, why should you bother playing online if you have to be by yourself? Invite only for friends might be a bit of a novelty for new players but after a while most of the newer content is on public lobbies only and those are the wild west of cheaters so hard pass.

The one exception is people's unofficial private servers. Many of those have actually fun things to do and such and are actually somewhat moderated at times so you can have a reasonable and fun experience and in theory they shouldn't interfere with the official online side if you don't want to get banned but well, there's also just mods for offline or other online games anyway.
Doubly so when your reward for pointing out these issues is to have some knuckle-dragging console players on Reddit gloat "LOL PC IS FOR CHEATERS".
 

m4a4

Posts: 2,252   +2,374
TechSpot Elite
Certainly is an oversight by Rockstar. Easy thing to profile and have a more senior programmer look at. And definitely should've happened years ago.

That said, I tried playing the game last year when it was free on the EGS. The loading times alone had me not wanting to play (not that the gameplay was all that appealing)...
 

terzaerian

Posts: 662   +926
The code was most likely fine before the array got so big which is why nobody noticed it until now.
I can't find any hard confirmation in news articles but back in 2013 the game size was 72 gb. Today it's a bit over 100. This was unacceptable code in 2013 and it's sure as hell unacceptable now, and I'm tired of Rockstar constantly being excused for making the worst ports in the industry to the PC and then blaming the PC for the problems they inflicted on the port through either indifferent laziness or malicious laziness.

This is the most profitable entertainment product ever produced in human history. There is no excuse for this.
 

terzaerian

Posts: 662   +926
To REALLY put the bow on this, imagine GTA Online came out in a world where cloud gaming was the only option. Nobody would ever be able to figure out that Rockstar put this bad code in because it would be completely obfuscated and hidden away on locked up cloud servers.

And people think I'm just some kind of crank conspiracy theorist.
 

Puiu

Posts: 4,419   +3,228
TechSpot Elite
I can't find any hard confirmation in news articles but back in 2013 the game size was 72 gb. Today it's a bit over 100. This was unacceptable code in 2013 and it's sure as hell unacceptable now, and I'm tired of Rockstar constantly being excused for making the worst ports in the industry to the PC and then blaming the PC for the problems they inflicted on the port through either indifferent laziness or malicious laziness.

This is the most profitable entertainment product ever produced in human history. There is no excuse for this.
The size of the game is irrelevant. An array won't use up gigabytes, the bottleneck is not that. Death marches to release a game always leads to such situations. Programmers literally have no time to make good code so you just write something that works in the moment. The developer's brief most likely never included the fact that the array will ever reach such a huge size.

What is unacceptable is that they didn't find the problem once the load times started getting weirdly long and tried to fix it.
 

terzaerian

Posts: 662   +926
Death marches to release a game always leads to such situations.
Which would be relevant if their PC release was under the gun, but it wasn't. They dawdled for 2 years after the console release to finally come out for PC. And they still botched the launch with numerous systemic issues (besides the loading issue, detailed by Dimitriid above) that have remained basically unresolved from then through today.

It's a crying shame that Volition decided to augur in the best competing franchise to GTA's trash heap, because now the latter remains basically the only credible example of the genre.
 
Last edited:

amghwk

Posts: 1,003   +897
It's like a slap on the developers' faces. Something the developers should have strived to do in the first place - to improve load times, amongst other optimizations.
 

terzaerian

Posts: 662   +926
This is the only way to play GTA V online there you will actually find adults in the servers, I watch a few twitch streamers doing RP and those servers have mods and are pleasant to play on.
The one time I dipped my toes into FiveM, the server had some kind of essay-form written application, which I failed because I didn't know what a couple slash commands specific to that server did. I imagine there are some more casual servers out there but some of them need to chill out.