Developer limits loading time in GTA Online by almost 70 percent with own code

Spread the love

A developer has succeeded by loading GTA Online 69.4 percent faster with modified code. This has been achieved by simplifying the process of how the system reads and processes the in-game items. The game is notorious for its long loading times.

The developer named T0ST writes that while he uses an outdated computer with an AMD FX-8350 CPU and an Nvidia GeForce GTX 1070, in combination with DDR3 RAM, it took six times longer to load GTA Online than the story mode. . That story mode took 70 seconds to complete, while the loading time for the online mode took six minutes. According to the developer and others, this difference should logically not be that big. Its outdated Bulldozer CPU may not have high single thread performance, which could be part of the explanation, but there was more to it.

He found the problem by opening the task manager in Windows. It turned out that during the first minute, the common elements that are used for both the story and online modes are loaded. After that, a process appeared to start that drastically increased the use of a single core of its cpu for more than four minutes, while there was hardly any use of the storage, the network, the gpu or the working memory. The developer says it is strange that only the CPU was used.

In the end, he came to the conclusion that there are two bugs or problems in the code. First, the game reads all the items in the game in a 10MB JSON text file. It contains 63,000 entries. That is a list of all items that can be purchased in the game, which, according to the developer, should not immediately include microtransactions. After reading each of the 63,000 items, each character in that entire text file is recounted, that is 63,000 times. Secondly, for the preparation of the imported item data, data such as the name and price of the item, and a hash of the item are loaded. Every time GTA Online saves an item, it checks the entire list one by one, comparing the item’s hash to see if it’s in the list. Basically, the hash value of the stored item is compared to the hashes of any other item that has already been stored before. This can lead to (63000^2+63000)/2 checks, or 1,984,531,500 pieces. GTA Online does this to make sure there are no duplicate entries in the final list, to prevent hackers.

According to the developer, this process is a drain on the CPU and is not even necessary, because the list of hashes is empty before the JSON file is loaded. In addition, all items in this file are unique, so according to T0ST it is not necessary to check whether or not they are in the list. In addition, he points out that there is even a function available to insert the items directly.

Based on his own code, it appears possible to reduce the loading time from six minutes to one minute and fifty seconds. Its own code calculates the length of the list of items only once, which already saves a considerable amount of calculation. In addition, he skips checking the hashes, because in his view there is no reason to check for duplicate items. This means that the almost two billion checks are no longer relevant, so that the processor can finish loading much faster.

The developer makes it clear that his own code is a proof of concept and that using it and thus modifying GTA Online may lead to the suspension of player accounts.

You might also like