Rockstar is one of the biggest game developers on the planet and has some of the most famous and profitable games out there. One of the popular and profitable games is GTA Online. While the game was available for seven years and is still very popular. One of the things that many players complain about is that the game loads very slowly regardless of how powerful the hardware it is being played on.
newly, For the programmer T0st passes some use Creative programming techniques To reduce loading times by 70 percent. T0st was sitting in a six-minute download for GTA Online on a mid-range gaming PC and opening the task manager, where he discovered something interesting. After the one-minute mark, the programmer said that his computer’s CPU usage had skyrocketed while storage and network usage was nearly non-existent.
T0st realized the long load times weren’t due to Rockstar’s servers or data being read from a drive. There was something running directly on the processor that needed a great deal of processing power to complete while using only one thread. Then T0st turned into a series of programming and debugging tools which revealed two important problems.
The first significant problem was that the game was reading a text file of all purchasable items in the game, for a total of 63,000 items. It counted each character in a 10MB text file for every 63,000 element which meant a lot of wasted processor time. Another issue was that while preparing to read the data, the game recorded data associated with that item, such as name, price, category, stats, and hash for that item that uniquely identified it. This process occurred 63,000 times.
Loading time increases every time more items are loaded into the game. T0st estimated that the game was making up nearly 2 billion checks consuming massive amounts of processor time. To alleviate the problems, the programmer wrote code to overwrite some of the game’s functions to solve the problem of reading the item.
I have created a basic cache to calculate the length of the item list once it can return the same value without performing the calculation again whenever the length is requested by the code in the game. This trick reduced the number of times it took to process the check from 63,000 to one. The Custom code It also skips checking for duplicate items that cut close to two billion checks that wouldn’t have had to happen, reducing download time from about six minutes to under two minutes.