GTA Online. Infamous for loading times that feel like an eternity. Even returning to the game years after its release to dive into the newer heists, the shock remains: loading times are still agonizingly slow, just as they were 7 years ago. For anyone trying to jump into Gta On Online, the wait can be excruciating.
It was time to investigate. Time to understand why getting into gta on online takes so long and if anything could be done about it.
Reconnaissance
First, a quick search to see if anyone had already tackled this notorious problem. The results were a mix of anecdotal theories. Some claimed the game’s complexity justified the long waits. Others pointed fingers at the peer-to-peer network architecture. There were even elaborate workarounds suggesting loading into story mode first, then a solo session. A few mods promised to skip the Rockstar logo video at startup, offering a meager 10-30 seconds of saved time.
Meanwhile, back on my PC…
Benchmark Testing
Story mode load time: | ~1m 10s |
Online mode load time: | ~6m flat |
Startup menu: | Disabled, time from R* logo to in-game |
CPU: | AMD FX-8350 |
SSD: | KINGSTON SA400S37120G |
RAM: | 2x Kingston 8192 MB (DDR3-1337) 99U5471 |
GPU: | NVIDIA GeForce GTX 1070 |
Okay, my setup isn’t cutting-edge, but why does online mode take six times longer to load than story mode? The story-to-online loading trick didn’t show any measurable improvement, echoing the experiences of other players. Even if it worked, the difference would be negligible against the overall wait.
Community Confirmation
If online polls are to be believed, this isn’t just my problem. A significant majority – over 80% – of gta on online players are mildly to severely annoyed by the loading times. Seven years, Rockstar! It’s a widespread issue impacting the gta on online experience for countless players.
Looking around, I found benchmarks from players with high-end gaming PCs who managed online load times of around 2 minutes. Two minutes! That would be a dream. It seemed hardware played a role, but something still felt off.
Why did even their story mode take nearly a minute to load? And why was their jump from story to online only adding a minute, while mine added five? Yes, their hardware was superior, but surely not five times better. The discrepancy hinted at something deeper than just hardware limitations affecting gta on online load times.
Resource Monitoring
Armed with the powerful Task Manager, I started monitoring resource usage during loading.
After about a minute of loading resources common to both story and online modes (comparable to high-end PCs), GTA Online decided to max out a single CPU core on my machine for a full four minutes. And that was pretty much it.
Disk usage? Almost zero. Network usage? A blip at the start, then practically nothing except for loading those rotating info banners. GPU usage? Zero. Memory usage? Flatlined.
What was it doing? Was my PC secretly mining cryptocurrency while I waited to play gta on online? No, this felt like a code problem. Really bad code.
Single-Thread Bottleneck
My aging AMD CPU, with its 8 cores, is still capable, but it’s from a bygone era. Back then, AMD’s single-thread performance lagged significantly behind Intel’s. This single-core bottleneck could explain some of the load time difference, possibly a large part of it.
But the type of bottleneck was surprising. I expected heavy disk reads for loading assets or intense network activity for session negotiation in the P2P network. Instead, it was purely CPU-bound. This screamed bug, not just hardware limitation, impacting the gta on online startup process.
Profiling for Insights
Profilers are invaluable for pinpointing CPU bottlenecks. Ideally, they instrument source code for precise analysis. But source code access? Not an option. And microsecond accuracy wasn’t crucial; I had a 4-minute bottleneck to investigate.
Stack sampling became the tool of choice for this closed-source investigation. By periodically dumping the process’s stack and instruction pointer, a call tree could be built to statistically analyze CPU activity. Luke Stackwalker, a somewhat outdated but effective Windows profiler, fit the bill. This tool, though in need of some love and updates, proved essential for understanding the gta on online loading mystery.
Luke typically groups identical functions, but lacking debugging symbols, I had to manually identify nearby addresses to infer function calls. The analysis revealed not one, but two distinct bottlenecks!
Delving Deeper with Reverse Engineering
Armed with a legitimate copy of an industry-standard disassembler (and a touch of financial pain), I began reverse-engineering GTA Online.
The initial disassembly was a mess. Most instructions were replaced with gibberish, a clear sign of anti-reverse engineering protection aimed at pirates, cheaters, and modders. However, such measures rarely deter determined individuals.
The game employed obfuscation or encryption. To bypass this, I needed to dump the game’s memory during the loading process. The instructions had to be de-obfuscated before execution. Process Dump, a handy tool for this purpose, came to the rescue, along with other similar utilities.
Problem 1: The strlen
Saga
Disassembling the de-obfuscated memory dump revealed a surprising label: strlen
! Following the call stack upwards, vscan_fn
appeared, and further up, the familiar sscanf
.
It was parsing something. But what? Stepping through the code with x64dbg revealed it: JSON! GTA Online was parsing a massive 10 megabytes of JSON data, containing around 63,000 item entries.
...,
{
"key": "WP_WCT_TINT_21_t2_v9_n2",
"price": 45000,
"statName": "CHAR_KIT_FM_PURCHASE20",
"storageType": "BITFIELD",
"bitShift": 7,
"bitSize": 1,
"category": ["CATEGORY_WEAPON_MOD"]
},
...
This data appeared to be for a “net shop catalog,” likely containing details of every purchasable item and upgrade in gta on online.
10MB of JSON isn’t huge. And while sscanf
might not be the most efficient parser, could it really be that slow?
Apparently, yes. Many sscanf
implementations, surprisingly, rely on strlen
. While perhaps not immediately obvious to the original developer, this reliance on strlen
for parsing such a large JSON file was proving to be a significant performance drain in gta on online‘s loading process.
Problem 2: The Hash Array Misstep
The second bottleneck was located right next to the first in the code. Both were even called within the same if
statement.
The second issue emerged after parsing each item. It was being stored in an array (or a similar list structure). Each entry looked something like this:
struct {
uint64_t *hash;
item_t *item;
} entry;
But before insertion, the code iterated through the entire array, comparing item hashes to check for duplicates. With approximately 63,000 entries, this resulted in a staggering (n^2+n)/2 = (63000^2+63000)/2 = 1,984,531,500
comparisons. Most of these checks were utterly pointless. They were using hashes, but not leveraging the efficiency of a hash map.
This “hash-array-list-thing,” as I dubbed it, was empty before loading the JSON. And all items in the JSON were unique! There was no need to check for duplicates at all. A function existed for direct insertion. Why wasn’t it being used? It was a baffling design choice impacting gta on online performance.
Proof of Concept Patch
Theory is good, but proof is better. To demonstrate the impact of these bottlenecks, I decided to create a Proof of Concept (PoC) patch.
The plan: write a DLL, inject it into GTA Online, hook the problematic functions, and observe the results.
Replacing the JSON parser was too complex for a quick PoC. Replacing sscanf
with a strlen
-free alternative was more feasible, but there was an even simpler approach for the strlen
issue:
- Hook
strlen
. - Detect the long JSON string.
- “Cache” its start and length.
- For subsequent
strlen
calls within the JSON range, return the cached length.
This strlen_cacher
function was implemented:
size_t strlen_cacher(char* str)
{
static char* start;
static char* end;
size_t len;
const size_t cap = 20000;
// if we have a "cached" string and current pointer is within it
if (start && str >= start && str < end) {
// calculate the new strlen
len = end - str;
// if we're near the end, unload self
// we don't want to mess something else up
if (len < 2000) MH_DisableHook((LPVOID)strlen_addr);
// super-fast return!
return len;
}
// count the actual length
// we need at least one measurement of the large JSON
// or normal strlen for other strings
len = builtin_strlen(str);
// if it was the really long string
// save it's start and end addresses
if (len > cap) {
start = str;
end = str + len;
}
// slow, boring return
return len;
}
For the hash array problem, the solution was simpler: skip the duplicate checks entirely and directly insert items, knowing they were unique.
The netcat_insert_dedupe_hooked
function achieved this:
char __fastcall netcat_insert_dedupe_hooked(uint64_t catalog, uint64_t* key, uint64_t* item)
{
// didn't bother reversing the structure
uint64_t not_a_hashmap = catalog + 88;
// no idea what this does, but repeat what the original did
if (!(*(uint8_t(__fastcall**)(uint64_t*))(*item + 48))(item))
return 0;
// insert directly
netcat_insert_direct(not_a_hashmap, key, &item);
// remove hooks when the last item's hash is hit
// and unload the .dll, we are done here :)
if (*key == 0x7FFFD6BE) {
MH_DisableHook((LPVOID)netcat_insert_dedupe_addr);
unload();
}
return 1;
}
The full PoC source code is available on GitHub.
Performance Results
Did the patches make a difference in gta on online loading times?
Original online mode load time: | ~6m flat |
Duplication check patch only: | 4m 30s |
JSON parser patch only: | 2m 50s |
Both issues patched: | 1m 50s |
Load time improvement: | ~69.4% |
Absolutely! The results were dramatic. The combined patches reduced gta on online loading times by almost 70% on my system.
While these specific bottlenecks might not be the only cause of slow loading for everyone, they represent a significant performance drain. It’s astonishing that these issues have persisted for so many years in gta on online.
tl;dr: GTA Online Loading Time Bottlenecks
- Single-thread CPU bottleneck during GTA Online startup.
- GTA Online struggles to parse a 10MB JSON file.
- The JSON parser implementation is inefficient and uses
strlen
excessively. - A slow item de-duplication routine further exacerbates the problem.
Rockstar Games: Please Fix This
To Rockstar Games: these issues are relatively straightforward to resolve. A single developer could likely fix them in a day. Please prioritize addressing these bottlenecks to improve the gta on online experience for millions of players.
Consider switching to a hash map for item de-duplication or skipping the check entirely during startup for a quick win. For the JSON parsing, replacing the library with a more performant one is highly recommended. These changes would significantly reduce gta on online loading times.
Thank you.
Small Update: Viral Response
The response to this investigation has been far greater than anticipated! Reaching the top of Hacker News and spreading rapidly across the internet – thank you for the overwhelming interest and support!
I’ll continue writing if further interesting findings emerge, but something of this scale is unlikely soon – a lot of luck was involved.
Regarding suggestions to spam Rockstar Support with this post: please refrain from doing so. They are likely aware of it by now. Social media channels are a more appropriate avenue for continued discussion.
For those who suggested a donation link – thank you for the kind offers to buy me a beer! A donation link has been added to the footer.
Thank you again for reading and for all the incredible support.
Update 2021-03-15: Rockstar Confirms Fix and Bounty
- Received confirmation from Rockstar Games that a fix is incoming.
- Awarded a $10,000 bounty through their HackerOne program as an exception (typically for security vulnerabilities).
- Navigating the complexities of a W8 form.
- Requested technical details about the fix, but none could be shared.
- Will benchmark again on my same setup once the update is live. Confidence is high that Rockstar’s engineers will deliver a significant improvement to gta on online loading times.
Update 2021-03-16: The Update is Live!
Rockstar released the update! Downloaded and ran the first test – same hardware, same measurement method – from Rockstar logo to fully online.
Fully fixed! t0st approves! gta on online loading times are now lightning fast.
Thank you again for all the virtual coffees, and immense gratitude to Rockstar Games for investigating and resolving this issue, and for the generous bounty!