
By Fanis Mahmalat · · Updated
The Six-Minute Loading Screen That Was Secretly an O(n²) Bug
For years, GTA Online was infamous for brutal loading times — often five to six minutes just to get into a session. In 2021, a modder going by t0st got curious enough to actually profile it, and found the cause wasn't networking or disk I/O. It was a single-threaded JSON parser doing something almost comically inefficient.
Before you can join a session, GTA Online loads its net shop catalog: about 10MB of JSON describing roughly 63,000 purchasable items. t0st found two separate problems in how the game read that file. First, its parser was built on sscanf, and most sscanf implementations call strlen on their input — so reading each value meant measuring a 10MB string all over again. Second, after parsing each item, the game scanned every item stored so far to detect duplicates before inserting it. That check scaled quadratically: double the catalog, and the work roughly quadruples, reaching about 1.98 billion comparisons at 63,000 items. It was also pointless, because every item in the catalog was unique. Years of new items had grown that file, so code that was probably fine at launch had become the dominant cost of joining a session.
The fix itself wasn't exotic. t0st's proof of concept, built entirely client-side with no access to Rockstar's source, cached the string's length so strlen stopped rescanning it, and inserted items directly instead of running the duplicate check. On t0st's machine, loading fell from about six minutes to 1 minute 50 seconds, a cut of roughly 70%. The parser was the bigger culprit: patching it alone brought the load down to 2 minutes 50 seconds, while patching only the duplicate check reached 4 minutes 30 seconds. Rockstar eventually shipped an official update that resolved the problem.
At 63,000 items, checking each new item against all the earlier ones adds up to about 1.98 billion comparisons. On t0st's machine, the game loaded in about 6 minutes unpatched, 4 minutes 30 seconds with only the duplicate check patched, 2 minutes 50 seconds with only the parser patched, and 1 minute 50 seconds with both patched.
What makes this worth knowing as a backend or full-stack developer isn't the GTA trivia — it's how invisible this class of bug is from the inside. Nobody at Rockstar set out to write an O(n²) parser; it's almost certainly code that was correct and fast when the data was small, and nobody revisited the algorithm as the data grew by orders of magnitude over years of live updates. That's a very normal way for performance bugs to form: not a bad decision at the time, but a reasonable one that stopped being reasonable as scale changed underneath it, with no single commit that "caused" it.
The practical takeaway scales down easily: when something that used to feel instant has quietly gotten slow, profile it before assuming it's infrastructure. A JSON parse, a config reload, a "just loop through and check" validation step — these are exactly the places where a small, forgotten loop ends up owning your latency budget as your own data grows.
Sources: How I cut GTA Online loading times by 70% · Hackers Succeeded in Reducing Load Time in Grand Theft Auto: Online by 70% · Hey Rockstar, GTA Online Has A Bad CPU Bottleneck That Slows Loading But There's A Fix
