How I cut GTA Online loading times by 70%
nee.lv
nee.lv
Parsing JSON?! I thought it was some network game logic finding session magic. If this is true that's the biggest WTF I saw in the last few years and we've just finished 2020.
Stunning work just having binary at hand. But how could R* not do this? GTAV is so full of great engineering. But if it was a CPU bottleneck then who works there that wouldn't just be irked to try to nail it? I mean it seems like a natural thing to try to understand what's going on inside when time is much higher than expected even in the case where performance is not crucial. It was crucial here. Almost directly translates to profits. Unbelievable.
Some useful lessons might be:
- try to make test more like prod.
- actually measure performance and try to improve it
- it’s very easy to write accidentally quadratic code and the canonical example is this sort of triangular computation where you do some linear amount of work processing all the finished or remaining items on each item you process.
As I read the article, my guess was that it was some terrible synchronisation bug (eg download a bit of data -> hand off to two sub tasks in parallel -> each tries to take out the same lock on something (eg some shared data or worse, a hash bucket but your hash function is really bad so collisions are frequent) -> one process takes a while doing something, the other doesn’t take long but more data can’t be downloaded until it’s done -> the slow process consistently wins the race on some machines -> downloads get blocked and only 1 cpu is being used)
[0]: https://git.musl-libc.org/cgit/musl/tree/src/stdio/vfscanf.c
- if you do write a parser, do not use scanf (which is complex and subtle) for parsing, write a plain loop that dispatches on characters in a switch. But really, don't.
I don’t use my own json parser but I nearly do. If this were some custom format rather than json and the parser still used sscanf, the bug would still happen. So I think json is somewhat orthogonal to the matter.
I think part of the problem is that scanf has a very broad API and many features via its format string argument. I assume that's where the slowdown comes from here - scanf needs to implement a ton of features, some of which need the input length, and the implementor expected it to be run on short strings.
> The subtlety is that sscanf doesn’t do what you expect. I think that “don’t use library functions that don’t do what you expect” is impossible advice.
I don't know, at face value it seems reasonable to expect programmers to carefully check whether the library function they use does what they want it to do? How would you otherwise ever be sure what your program does?
There might be an issue that scanf doesn't document it's performance well. But using a more appropriate and tighter function (atoi?) would have avoided the issue as well.
Or, you know, don't implement your own parser. JSON is deceptively simple, but there's still enough subtlety to screw things up, qed.
I didn't get that impression. It sounded like the slowdown comes from the fact that someone expected sscanf to terminate when all directives were successfully matched, whereas it actually terminates when either (1) the input is exhausted; or (2) a directive fails. There is no expectation that you run sscanf on short strings; it works just as well on long ones. The expectation is that you're intentionally trying to read all of the input you have. (This expectation makes a little more sense for scanf than it does for sscanf.)
The scanf man page isn't very clear, but it looks to me like replacing `sscanf("%d", ...)` with `sscanf("%d\0", ...)` would solve the problem. "%d" will parse an integer and then dutifully read and discard the rest of the input. "%d\0" will parse an integer and immediately fail to match '\0', forcing a termination.
EDIT: on my xubuntu install, scanf("%d") does not clear STDIN when it's called, which conflicts with my interpretation here.
The root cause here isn't formatting or scanned items. It is C library implementations that implement the "s" versions of these functions by turning the input string into a nonce FILE object on every call, which requires an initial call to strlen() to set up the end of read buffer point. (C libraries do not have to work this way. Neither P.J. Plauger's Standard C library nor mine implement sscanf() this way. I haven't checked Borland's or Watcom's.)
See https://news.ycombinator.com/item?id=26298300 and indeed Roger Leigh six months ago at https://news.ycombinator.com/item?id=24460852 .
It looks like this approach is taken by the majority of sscanf() implementations!
I honestly would not personally have expected sscanf() to implicitly call strlen() on every call.
Every programmer I know thinks about performance of functions either by thinking about what the function is doing and guessing linear/constant, or by knowing what the data structure is and guessing (eg if you know you’re doing some insert operation on a binary tree, guess that it’s logarithmic), or by knowing that the performance is subtle (eg “you would guess that this is log but it needs to update some data on every node so it’s linear”). When you write your own library you can hopefully avoid having functions with subtle performance and make sure things are documented well (but then you also don’t think they should be writing their own library). When you use the C stdlib you’re a bit stuck. Maybe most of the functions there should just be banned from the codebase, but I would guess that would be hard.
What's the point of using standard formats if you're not taking advantage of off-the-shelf software for handling it?
This really rings truest to me: I find it hard to believe nobody ever plays their own game but I’d easily believe that the internal culture doesn’t encourage anyone to do something about it. It’s pretty easy to imagine a hostile dev-QA relationship or management keeping everyone busy enough that it’s been in the backlog since it’s not causing crashes. After all, if you cut “overhead” enough you might turn a $1B game into a $1.5B one, right?
But Rockstar essentially only have GTA and Red Dead to take care of, it's not like they're making an annual title or something :)
This reminds me that I used to do that all the time when programming with Matlab. I have stopped investigating performance bottlenecks after switching to Python. It is as if I traded performance profiling with unit testing in my switch from Matlab to Python.
I wonder if there are performance profilers which I could easily plug into PyCharm to do what I used to do with Matlab's default IDE (with a built-in profiler) and catch up with good programming practices. Or maybe PyCharm does that already and I was not curious enough to investigate.
It also comforts me into my decision of never using scanf, instead preferring manual parsing with strtok_r and strtol and friends. It's just not robust and flexible enough.
We all would have picked this game back up in a second if the load times were reduced. Although I must say even with the same results as this author, 2 minutes is still too long. But I'll bet that, given the source code, there are other opportunities to improve.
I assume there were different people working on the core game engine and mechanics VS loading. It could as well be some modular system, where someone just implemented the task "load items during online mode loading screen screen".
Many developers I have spoken to out there in the wild in my role as a consultant have wildly distorted mental models of performance, often many orders of magnitude incorrect.
They hear somewhere that "JSON is slow", which it is, but you and I know that it's not this slow. But "slow" can encompass something like 10 orders of magnitude, depending on context. Is it slow relative to a non-validating linear binary format? Yes. Is it minutes slow for a trivial amount of data? No. But in their mind... it is, and there's "nothing" that can be done about it.
Speaking of which: A HTTPS REST API call using JSON encoding between two PaaS web servers in Azure is about 3-10ms. A local function call is 3-10ns. In other words, a lightweight REST call is one million times slower than a local function call, yet many people assume that a distributed mesh microservices architecture has only "small overheads"! Nothing could be further from the truth.
Similarly, a disk read on a mechanical drive is hundreds of thousands of times slower than local memory, which is a thousand times slower than L1 cache.
With ratios like that being involved on a regular basis, it's no wonder that programmers make mistakes like this...
Everyone thinks the network is free... Until it isn't. Every bit move in a computer has a time cost, and yes, it's small... But... When you have processors as fast as what exist today, it seems a sin that we delegate so much functionality out to some other machine across a network boundary when the same work could be done locally. The reason why though?
Monetizability and trust. All trivial computation must be done on my services so they can be metered and charged for.
We're hamstringing the programs we run for the sole reason that we don't want to make tools. We want to make invoices.
I love your point that shipping a library (of code to locally execute) with a good API would outperform an online HTTPS API for almost all tasks.
So much to get from this.
Even if you don't have the source, you can make a change if you are annoyed enough.
If you don't like something, and the source code is out there, really go contribute.
Performance matters, know how to profile and if using an external dependency, then figure out their implementation details.
Algorithms & Data structures matter, often I see devs talking about how it doesn't matter much but the difference between using a hashmap vs array is evident.
Attentive code reviews matter, chances are they gave this to a junior dev/intern, and it worked with a small dataset and no one noticed.
Anyway, everyone just rolled their eyes and blamed the fact that the app was written in Java.
It ended up generating an XML file during that minute long startup....so we just saved the file to the network and loaded it on startup. If inventory changed, we’d re-generate the file once and be done with it.
Languages like Java get a lot of bad reputation for that because of popularity: not just that many people are hired into broken-by-design environments (or ones where they’re using some framework from a big consultancy or a vendor who makes most of their revenue from consulting services) but also because many people learn the language as their first language and often are deeply influenced by framework code without realizing the difference between widely used long-term reusable code and what most projects actually need and are staffed for. It’s easy to see the style of the Java standard frameworks or one of the major Apache projects and think that everyone is supposed to write code like that, forgetting that they have to support a greater number of far more diverse projects over a longer timeframe than your in-house business app nobody else works on. Broader experience helps moderate this but many places choose poor metrics and neglect career development.
I'm stealing this phrase.
The two performance flaws that exist are:
1. Old Java frameworks were not written with performance in mind
2. Your entire app is written in Java so you don't benefit from C++ libraries
The mindset of constantly considering the big-O category of the code you're writing and reviewing pays off big. And neglecting it costs big as well.
It's true that you don't just have one shot to get it right, but you can't afford to be littering the codebase with accidentally quadratic algorithms.
I fairly regularly encounter code that performed all right when it was written, then something went from X0 cases to X000 cases and now this bit of N^2 code is taking minutes when it should take milliseconds.
The obviously stupid, wasteful work is at heart an algorithmic problem. And it cropped up even in the simplest of data structures. A constant amount of wasteful work often isn't a problem even in tight loops. A linear amount of wasted work, per loop, absolutely is.
arr = []
while ...:
if something:
arr.append(foo)
...
if count(arr) == x:
stuff
...
changed to arr=[]
arr_size = 0
while ...:
if something:
arr.append(foo)
arr_size++;
...
if arr_size == x:
stuff
...
This is clearly optimization, but it's not premature. The original might just pass code review, but when it wrecks havoc, the amount of time it will cost will not be worth it, jira tickets, figuring out why the damn thing is slower, then having to recreate it in dev, fixing it, reopening another pull request, review, deploy, etc. Sometimes "optimizing prematurely" is the right thing to do if it doesn't cost much time to do or overly completely the initial solution. Of course, this depends on the language, some languages will track the length of the array so checking the size is o(1), but not all languages do, so checking the length can be expensive, knowing the implementation detail matters.Yes, that's a real issue. But we've been given two options:
- Does the correct thing, and will continue to do the correct thing regardless of future changes to the code. Will break if the use case changes, even if the code never does.
- Does the correct thing, but will probably break if changes are made to the code. Will work on any input.
It actually seems a lot more likely to me that the input given to the code might change than that the code itself might change. (That's particularly the case for the original post, where the code serves to read a configuration file, but it's true in general.)
Do you see a way to do this that doesn't involve rolling your own array-like or list-like data type and replacing all uses of ordinary types with the new one? (This is actually already the implementation of standard Python types, but if you're encountering the problem, it isn't the implementation of your types.)
Well, until you get flagged by the anti cheat and get your account and motherboard banned...
Heck, it might be against the EULA, which probably doesn't hold op legally, but is decent grounds for a ban.
I've logged in exactly twice. Load times like that may be worth it to a hardcore gamer, but I have no patience for it. There's no shortage of entertainment available to someone with a PC, a reasonable internet connection, and a modicum of disposable income. Waste my time and I'll go elsewhere for my entertainment.
I've seen this happen with some other games which are not the best optimised for PCs, but the fans will still defend the developers, just because they like the brand
And just thinking about the size of the game and popularity, to make it work at all, requires some skill. Which makes the OP even more unbelievable.
Even "rebels", who supposedly relish having fringe tastes, want other rebels to approve of their tastes.
The more strongly you stake your identity as "fan of X", the more social disapproval of X hurts.
This... this is GTA online. It's a cash cow designed to suck cash out of your pocket. Ads for things you can spend your money on are shown while "connecting", so if this delay wasn't introduced intentionally, it sure isn't a high priority fix. The code isn't part of the optimised, streamlined, interactive part of the game, it's part of the menu and loader system.
Most of these online games/services have so-called "whales" that contribute most if not all of the income the platform makes. If these whales are willing to spend the wads of cash they throw at the platform, they won't even care for another five minutes of ads. The amounts of cash some of these people spend is obscene; the millions Take Two profit from GTA every year are generally generated by only a tiny (usually a single number percentage) of the total player base.
In the end, I doubt they've lost much money on this. They might've even made some from the extra ads.
It's easy to forget that GTA5/GTA:O was originally a 360/PS3 game, getting a game of that scope running at all on a system with just 256MB of RAM and VRAM was an incredible achievement.
The A-Team developers who made that happen were probably moved over to Red Dead Redemption 2 though, with GTA5s long tail being handled by the B-Team.
GTA Online is a huge, enormously buggy and slow mess that will generally struggle to run at 80 fps on a top-of-the-line 2020 system (think 10900K at over 5 GHz with a 3090) and will almost never cross the 120 fps threshold no matter how fast your system is and how low the settings are.
I’m really confused as to why games are determining anything whatsoever based on the refresh rate of the screen.
Skyrim has this same problem and not being able to play over 60fps is the reason I haven’t touched the game in years.
Generally, a AAA console game will target 30hz or 60hz. Therefore the timing loop is built to serve updates at a steady pace of 30 or 60, with limiting if it goes faster. Many game engines also interpolate animations separately from the rest of the gameplay, allowing them to float at different refresh rates. Many game engines further will also decouple AI routine tick rates from physics to spread out the load. Many game engines now also interleave updates and kick off the next frame before the first is complete, using clever buffering and multithreaded job code. All told, timing in games is one of those hazard zones where the dependencies are both numerous and invisible.
When you bring this piece of intricate engineering over to PC and crank up the numbers, you hit edge cases. Things break. It's usually possible to rework the design to get better framerate independence, but doing do would be invasive - you'd be changing assumptions that are now baked into the content. It isn't just fixing one routine.
If you then try to run the simulation in parallel with the rendering (rather than between some frames) it is even more work, since inter-thread communication is hard.
This stuff might seem easy for very good programmers, however on a game you want to hire a wide range of programmer skill and "game-play programmers" tend to be weaker on the pure programming front (their skills lie elsewhere)
https://www.nexusmods.com/skyrimspecialedition/mods/34705 >Refresh rate uncap for exclusive fullscreen mode.
For example, my backend Java guys struggled heavily with JSON mappers. It took them forever to apply changes safely. My department consumes a lot of data from backend systems and we have to aggregate and transform them. Unfortunately the consumed structure changes often.
While a JSON mapper in our case in JAVA was sort of exceptionally hard to handle, a simple NodeJS layer in JavaScript did the job exceptionally easy and fast. So we used a small NodeJS layer to handle the mapping instead of doing this in Java.
Moral of the story: Sometimes there are better tools outside your view. And this seems to be many times the case for JSON. JSON means JavaScript Object Notation. It is still tough for OO languages to handle.
This is my observation.
Another reason why C styled null terminated strings suck. Use a class or structure and store both the string pointer and its length.
I have seen other programs where strlen was gobbling up 95% of execution time.
Edit: hah, I'm decades late to the party, here we go:
Most modern libraries replace C strings with a structure containing a 32-bit or larger length value (far more than were ever considered for length-prefixed strings), and often add another pointer, a reference count, and even a NUL to speed up conversion back to a C string. Memory is far larger now, such that if the addition of 3 (or 16, or more) bytes to each string is a real problem the software will have to be dealing with so many small strings that some other storage method will save even more memory (for instance there may be so many duplicates that a hash table will use less memory). Examples include the C++ Standard Template Library std::string...
From c++ class, std::string was easy enough to use everywhere, and just foo.c_str() when you needed to send it to a C library. But that may drags in a lot of assumptions about memory allocation and what not. Clearly, we don't want to allocate when taking 6 minutes to parse 10 megs of JSON! :)
I would have expected libc to take that use case in consideration and use a different algorithm when the string exceeds a certain size. Even if the GTA parser is not optimal, I would blame libc here. The worst part is that some machines may have an optimized libc and others don't, making the problem apparent only in some configuration.
I believe standard libraries should always have a reasonable worst case by default. It doesn't have to be perfectly optimized, but I think it is important to have the best reasonable complexity class, to avoid these kinds of problems. The best implementations usually have several algorithms for different cases. For example, a sort function may do insertion (n^2, good for small n) -> quicksort (avg. nlog(n), worst n^2, good overall) -> heapsort (guaranteed nlog(n), slower than quicksort except in edge cases). This way, you will never hit n^2 but not at the cost of slow algorithm for the most common cases.
The pseudo hash table is all GTA devs fault though.
That’s generally called “adaptive”. A famous example of that is timsort.
Your version has issues though: insertion sort is stable, which can dangerously mislead users.
I just felt like every time I logged in I went, "So what's the point here?".
Something tells me this "problem" was discovered long ago at Rockstar HQ, and quietly deemed not to be a problem worth solving.
Virtually nobody's willing to sit through 10 minutes of commercials straight.
Then again, that's what they do at movie theaters...
Luckily for them, churn is usually a different problem solved by a different part of the team/org with different priorities and insights.
It's funny to think that I would probably pay some amount to have GTA Online without these absurd loading times and without modders/hackers :D
Found that they get more purchases BECAUSE of the long loading time, despite bouncing other players (the ad theory and happy coincidence for them to have the ad placement slots from shitty engineering)
The engagement team was told bullshit by the engineering team about how impossible it is to fix that issue
Or they are just making enough not to care
the "engagement team" got fooled by longer session times
“Roll that out to everyone!”
Maybe set up a donation page? I’d be more than happy to send some beer money your way for your time spent on this!
(I also really like the design and presentation of the article; I'm running out of superlatives here.)
I loved the article. Are you planning to write any guides/tutorials about reverse engineering games? Seems like you have a lot of practical experience. I (and probably many other people) would be really excited if you started writing about how you do all these in detail with practical examples. I would even be glad to pay for such content.
Reverse Engineering Course: https://news.ycombinator.com/item?id=22061842
Reverse Engineering For Beginners: https://news.ycombinator.com/item?id=21640669
Introduction to reverse engineering for beginners: https://news.ycombinator.com/item?id=16104958
A lot of the reverse engineers I know seemingly have deep platform knowledge and can do things like cite Win32 docs from memory.
Both when looking at a particular problem, but also in sticking to RE in general for long enough to pick up the skills and tricks that make you quick. There are countless tricks you pick up that cleave off huge amounts of time that would otherwise be wasted.
It won't help you with PowerPC, but the chapter list is: x86 and x64, ARM, The Windows Kernel, Debugging and Automation, and Obfuscation.
The book was written in 2014, so it should be reasonably relevant for modern purposes, and especially so if digging into any software older than 2014.
Ahh. Modern software rocks.
Dumped it in to a very simple sqlite db:
$ du -hs gta.db
5.2M gta.db
Even 10MB is peanuts for most of their target audience. Stick it in an sqlite db punted across and they'd cut out all of the parsing time too.Down a little in the article and you'll see one of the real issues:
> But before it’s stored? It checks the entire array, one by one, comparing the hash of the item to see if it’s in the list or not. With ~63k entries that’s (n^2+n)/2 = (63000^2+63000)/2 = 1984531500 checks if my math is right. Most of them useless.
Time with only duplication check patch: 4m 30s
Time with only JSON parser patch: 2m 50sIt’s an irrelevant one. The json parser from the python stdlib parses a 10Mb json patterned after the sample in a few dozen ms. And it’s hardly a fast parser.
More than 3 GB/s are possible. Like you said 10 MB of JSON is a breeze.
There's a "but" though: you might end up getting banned from GTA Online altogether if this DLL injection is detected by some anti-cheat routine. The developers should really fix it on their end.
This means that anyone in your session can send you a weirdly-formed packet to crash your game. Most cheats have protections against this by just doing Rockstar's job and adding better validation around packet interpretation routines.
Using "cheats just to protect [your]selves" actually makes a lot of sense.
But, you know, premature optimization yadda yadda.
10MB is less than the cache in modern CPUs. How can this take minutes(!).
Another pet peeve of mine is Civ 6's loading time for a saved game is atrocious. I'm sure there's a O(n^2) loop in there somewhere.
Yeah I know it sounds stupid, but I suspect real Sherlock Holmes was inspired by a true story like this one too, and at least some contemporary detectives started to enjoy reading them.
The first hurdle is the technical skill required: there has always been closed source software, but these days the software is so much more complex, often even obfuscated, that the level of knowledge necessary to diagnose an issue and fix it has gone up significantly. It used to be that you could hold and entire program in your head and fix it by patching a couple bytes, but these days things have many, many libraries and you may have to do patching at much stranger boundaries (“function level but when the arguments are these values and the call stack is this”). And that’s not to say anything of increasing codesigning/DRM schemes that raise the bar for this kind of thing anyways.
The other thing I’ve been seeing is that the separation between the perceived skills of software authors and software users has increased, which I think has discouraged people from trying to make sense of the systems they use. Software authors are generally large, well funded teams, and together they can make “formidable” programs, which leads many to forget that code is written by individuals who write bugs like individuals. So even when you put in the work to find the bug there will be people who refuse to believe you know what you are doing on account of “how could you possibly know better than $GIANT_CORPORATION”.
If you’re looking for ways to improve this, as a user you should strive to understand how the things you use work and how you might respond to it not working–in my experience this is a perpetually undervalued skill. As a software author you should look to make your software introspectable, be that providing debug symbols or instructions on how users can diagnose issues. And from both sides, more debugging tools and stories like this one :)
Overwatch is another an incredibly popular game with obvious bugs (the matchmaking time) front and center. And gamers are quick to excuse it as some sort of incredibly sophisticated matchmaking - just like the gamers mentioned in OP.
It's easy to to say it's something about gamers / gaming / fandom - but I have a locked down laptop issued by my bigcorp which is unbelievably slow. I'd bet a dollar there's a bug in the enterprise management software that spins the CPU. A lot of software just sucks and people use it anyway.
I think it could be improved, but it doesn't strike me as being buggy.
(Overwatch itself, lots of bugs. Tons of bugs. If they have any automated tests for game mechanics I would be pretty surprised.)
I guess what they are probably doing is batching groups of games and then matching for the entire batch, to ensure nobody gets a "bad" match. What they've missed is that well - 5% of matches are bad baseline because somebody is being a jerk or quits or has an internet disconnect or smurfs or whatever other reasons. They could have picked an algorithm that gave fast matches 99% of the time at the cost of having bad matches 1% of the time and nobody would have noticed, because their baseline bad match rate is so high. Optimization from too narrow a perspective.
Honestly, the OW matches I get aren't any more balanced that the COD matches I used to get, and I got those in a minute, not 15.
(My experience shows this is the case; quickplay matches, with no grouping restrictions, are always more of a shitshow than ranked, which has some grouping restrictions.)
Similarly, an individual's performance variance makes a big difference that a mere arithmetic average can't account for. A 3900 player probably plays like a 4100 player when fresh and warmed up, but like a 3500 player when drunk, sleepy, and mad. The actual SR/MMR will converge to a time weighted average of those two states, but if you're in a 4100 game with that player when they're in their 3500 state, it's probably unwinnable. Maybe the matchmaker could attempt to predict this, but it would probably make people mad. Personally, I think that's the nature of a 12 person game composed of 12 randos. There is very little an algorithm can do to tune that (short of changing abilities/hitboxes/cooldowns of each player, which would make people mad).
Then there are people that abuse the matchmaker by exploiting uncertainty in their favor (creating a new account). Every time I have played in a 6 stack in ranked, we've always played against 6 brand new accounts that are clearly better than the matchmaker thinks they are, which sucks. (In quickplay, I generally have very good games in a 6 stack though.)
Overall, I hate to say this, but I think they're doing the best they can. I don't think there's enough data to make a good match 100% of the time, which is why people find 11 players and play "scrims" instead of ranked/quickplay. I don't know where you're able to see other groups and decide that they're a suitable match -- 90% of players have private profiles, and those that don't only play like 10 ranked games a season, so you can't really gauge how good or bad they are from public data.
(As for brits and aussies joining your west coast games... people VPN in to do that on purpose. Legend has it that west coast gamers are better than east coast gamers, so people all over the world VPN to the west coast and make it a self-fulfilling prophecy.)
I'm making the same point with regard to matchmaking. Overwatch has tried to optimize for good matches, ignoring all the issues you rightly describe above, and thinking about the tradeoff between time and good matches without regard to external events that impact matches like smurfs, uneven play, DCs, etc. They'd have been better off optimizing for fast matchmaking. It's bad engineering in plain sight, and gamers go out of their way to justify it.
I think there is some value in caring about that case. I started playing Overwatch with no FPS background (at 31!) and I never felt like I was in unwinnable games. All the players were as bad as me. (I still remember my first games when a D.va bomb would reliably get 6 kills.)
will r* fix it? maybe, especially since some person literally did half of the work for them. But given R* is a large company, this probably wont be fixed for a long time, and GTAO is probably being maintained by the lowest bid contractor group.
They probably have all of their full time assets working on the next iteration of GTA.
They've also made just an absolute assload of money from GTA:O in spite of the godawful load times. Why bother spending the money to fix it when people are happy to deal with it and keep giving you their own cash?
All of the work.
Is 1 min loading time even normal? Why did it take so long? I never played GTA Online so could someone explain?
https://hardcoregamer.com/2020/11/06/ps5-ssd-vs-ps4-hdd-load...
But most programs are somehow still really slow! And when you look into why, the reason is always something like this. The code was either written by juniors and never optimized because they don’t know how, or written by mids at the limit of their intelligence. And full of enough complex abstractions that nobody on the team can reason holistically about how the whole program works. Then things get slow at a macro level because fixing it feels hard.
Either way it’s all avoidable. The only thing that makes your old computer feel sluggish for everyday computing is that programmers got faster computers, and then got lazy, and then shipped you crappy software.
As they said at Zynga, move slow and fix your shit.
Nothing like the 6 minutes people are talking about for GTA. That’s ridiculous.
It's also possible they are very aware of it and are saving up this improvement for the next iteration of GTA Online, running on a newer version of their game engine :)
Still much better than e.g. Ubisoft which repainted safety borders from red to blue and removed shadows in TM2 Canyon few years after release, also breaking a lot of user tracks. (If you’re not sure why, it was before a new iteration of the game)
Then over time they slowly add data to the JSON and then this O(n^2) stuff starts to creep up and up, but the farther away from release you are, the less likely that the kind of engineers to who do optimisation and paying any attention.
They are all off working on the next game.
From a game programming perspective, I'm sure at launch there were very few extras to obtain, so this method ran fast and didn't raise any red flags.
But as time has worn on they've added a ton of extra items and it's become a real problem. What it does show is that probably most of their team are working on creating new things they can sell, vs testing and maintaining the codebase for the last N years.
Looking down on the ground through the clouds at the san Andreas's streets with that wispy air sound while waiting for those large thud noises which could come randomly will forever be etched into my memory as something which completely broke the fun I was having, especially when playing with friends and trying to do Heists later in the products life.
And because of this: getting people to play was really difficult, the combination of huge updates which took hours to download (PS4 has slow access to it's drive even if you upgrade to SSD) and the insanely long loading times once you have the patch culminated in many hours of lost gameplay.
I remember a quote from Steve Jobs which fits here: "Let's say you can shave 10 seconds off of the boot time. Multiply that by five million users and thats 50 million seconds, every single day. Over a year, that's probably dozens of lifetimes. So if you make it boot ten seconds faster, you've saved a dozen lives. That's really worth it, don't you think?"[0]
[0]: https://www.folklore.org/StoryView.py?story=Saving_Lives.txt
> To be fair I had no idea most sscanf implementations called strlen so I can’t blame the developer who wrote this.
Is this true? Is sscanf really O(N) on the size of the string? Why does it need to call strlen in the first place?
The MUSL C library' sscanf() does not do this, but does call memchr() on limited substrings of the input string as it refills its input buffer, so it's not entirely free of this behaviour.
* https://git.musl-libc.org/cgit/musl/tree/src/stdio/vsscanf.c
The sscanf() in Microsoft's C library does this because it all passes through a __stdio_common_vsscanf() function which uses length-counted rather than NUL-terminated strings internally.
* https://github.com/tpn/winsdk-10/blob/master/Include/10.0.16...
* https://github.com/huangqinjin/ucrt/blob/master/inc/corecrt_...
The GNU C library does something similar, using a FILE structure alongside a special "operations" table, with a _rawmemchr() in the initialization.
* https://github.com/bminor/glibc/blob/master/libio/strops.c#L...
* https://github.com/bminor/glibc/blob/master/libio/strfile.h#...
The FreeBSD C library does not use a separate "operations" table.
* https://github.com/freebsd/freebsd-src/blob/main/lib/libc/st...
A glib summary is that sscanf() in these implementations has to set up state on every call that fscanf() has the luxury of keeping around over multiple calls in the FILE structure. They're setting up special nonce FILE objects for each sscanf() call, and that involves finding out how long the input string is every time.
It is food for thought. How much could life be improved if these implementations exported the way to set up these nonce FILE structures from a string, and callers used fscanf() instead of sscanf()? How many applications are scanning long strings with lots of calls to sscanf()?
> limited substrings of the input string as it refills its input buffer,
As far as I can tell, that copying helper function set to the read member of the FILE* never actually gets called in this path. I see no references to f->read() or anything that would call it. All of the access goes through shgetc and shunget, shlim, and shcnt, which directly reference the buf, with no copying. The called functions __intscan() and __floatscan() do the same. __toread() is called but just ensures it is readable, and possibly resets some pointers.
Even if it did, that pretty much does make it entirely free of this behavior, though not of added overhead. That operations structure stuffed into the file buffer doesn't scan the entire string, only copying an at most fixed amount more than asked for (stopping if the string terminates earlier than that). That leaves it linear, just with some unfortunate overhead.
I do find the exceedingly common choice of funneling all the scanf variants through fscanf to be weird. But I guess if they already have one structure for indirecting input, it's easy to overload that. (And somehow _not_ have a general "string as a FILE" facility, and building on top of that. (Posix 2008 does have fmemopen(), but it's unsuitable, as it is buffer with specified size (which would need to be calculated, as in the MS case), rather than not worried about until a NUL byte is reached.))
With fmemopen(), you only need to calculate the length once at the start, right? And then you can use the stream instead.
Pretty sure I would have made this error in the same situation, no question.
Neither P.J. Plauger's nor my Standard C library (which I wrote in the 1990s and used for my 32-bit OS/2 programs) work this way. We both use simple callback functions that use "void*"s that are opaque to the common internals of *scanf() but that are cast to "FILE*" or "const char*" in the various callback functions.
OpenWatcom's C library does the same. Things don't get marshalled into nonce FILE objects on every call. Rather, the callback functions simply look at the next character to see whether it is NUL. They aren't even using memchr() calls to find a NUL in the first position of a string. (-:
* http://perforce.openwatcom.org:4000/@md=d&cd=//depot/V2/src/...
* https://groups.google.com/g/comp.lang.c/c/SPOnRZ3nEHk/m/dAoB...
That's fmemopen. Not widespread, but at least part of POSIX these days.
just wrap the string into a FILE, explicitly setting the buffer size to strlen(s), use fscanf the loop and fasten your seatbelts...
https://pubs.opengroup.org/onlinepubs/9699919799/functions/f...
If anyone used a JSON parser that took 4 minutes to parse a file you bet the author would know by the time the 100th user comes around.
I had a tiny barely-used detection library that didn’t detect it correctly in a new Edge browser update. Someone complained about it within the first month. The library has 20 stars and Edge has 500 users.
Edit: Correction, it was 9 days after the browser release.
Its now at least 4 month old.
So whats the problem? When you tab+alt out of fullscreen, to change your soundvolumen everytime you start the game, you have to rechange the graphics configuration as well.
I solved it by .net code i found on github which would run fur 5 minutes and would put the volumne up as soon as it ifinds the rdd2 process...
It's also the reason the DOM is so slow, in my view.
I remember spotting a lot of fast JSON parsers around, but again, there doesn't seem to be any popular, open, flexible, binary file format out there.
Meanwhile, games are always larger and larger, machine learning requires more and more data.
There is ALWAYS money, battery and silicon to be saved by improving performance.
I do not agree with the sibling comment saying that this problem only looks simple and that we are missing context.
This online gamemode alone made $1 billion in 2017 alone.
Tweaking two functions to go from a load time of 6 minutes to less than two minutes is something any developer worth their salt should be able to do in a codebase like this equipped with a good profiler.
Instead, someone with no source code managed to do this to an obfuscated executable loaded with anti-cheat measures.
The fact that this problem is caused by Rockstar's excessive microtransaction policy (the 10MB of JSON causing this bottleneck are all available microtransaction items) is the cherry on top.
(And yes, I might also still be salty because their parent company unjustly DMCA'd re3 (https://github.com/GTAmodding/re3), the reverse engineered version of GTA III and Vice City. A twenty-year-old game. Which wasn't even playable without purchasing the original game.)
If one really examined the accounting for GTAO, I would bet that most of the billions of dollars that were earned in micro transactions went to marketing, product research, and to middle management in the form of bonuses.
It's bait for the non-discerning customer who is more likely to empty their wallet for microtransactions because they have less experience with games so don't know what is normal :)
Everything is getting slower and slower, and nobody cares.
When I played the Atari 2600, I had to wait for the TV to warm up, but otherwise there were no games with anything approaching load times (with 128 bytes of RAM in the console, who would know). The NES didn't have much in the way of load times either, but you did have to fiddle with the cartridge slot. SNES and Genesis didn't usually load (Air Buster being a noticeable exception). CD based systems sure did like to load, but that's somewhat understandable. In the mean time, more and longer boot screens. The Switch uses a cartridge (or system flash/SD cards), but it likes to load forever too.
PC Gaming has had loading for longer, but it's been getting longer and longer.
Some arcade games have lengthy loading sequences, but only when you turn them on while they read their entire storage into RAM so they can be fast for the rest of the time they're on (which in arcades is usually all day).
It really depends. The latest crop of games I’ve played (Doom Eternal, Cyberpunk) loads way faster than games from a few years back (aforementioned GTA-V, Shadow Warrior 2…).
This is also on the same machine, so it’s not the hardware that makes it faster.
https://devblogs.microsoft.com/directx/directstorage-is-comi...
I think, but I’m not entirely sure, that Linux can do the peer to peer DMA trick. One nasty bit on any OS is that, if a portion of the data being read is cached, then some bookkeeping is needed to maintain coherence, and this adds overhead to IO. I wouldn’t be surprised if consoles had a specific hack to avoid this overhead for read-only game asset volumes.
With a sufficiently low overhead async API (ie. io_uring) you can saturate a very fast SSD with a single thread, but I'm not sure it would actually make sense for a game engine to do this when it could just as easily have multiple threads independently performing IO with most of it requiring no synchronization between cores/threads.
Also you're probably going to want to do multithreaded decompression anyway, and it'll be more efficient if you have the threads completing the reads do the decompression themselves. So in any case you probably want multiple threads handling the completion events.
"Hey we have this great new tech that makes things even faaster!!"
2 years later
"GTA 6 found to have double online load times, denies claims that game performs worse than GTA 5, tells people to upgrade their systems"
4 years later:
"Tech blogger reverses code, realizes someone managed to loop access between hard drive and gpu despite extremely common modern tech, gets 10x boost after spending a day fixing junk product"
Better technology just hasn't met its match from dumber management and more bureaucratic dev shops...
I can’t recall the name, but I had the hack and slash adventure game variant. The connector on the custom cartridge was fiddly and required a stout rubber band to reliably work.
>Everything is getting slower and slower, and nobody cares.
Yes, modern games are so inefficient and laggy nowadays. Once your game world reaches a certain size it becomes unplayable and that's just in single player. Once you add 10 players you start to hit performance limits very quickly.
GTA has achieved tremendous success both as an entertaining game and as a business. It's enjoyed by millions of people and generates billions in revenue. As per this article, it has startup problems (which don't seem to actually really hurt the overall product but I agree sound annoying) but the bigger picture is: it's a huge success.
So - Rockstar has nailed it. What exactly is your platform for analyzing/criticizing their processes or even having a shot of understanding what they are? What have you build that anyone uses? (not saying you haven't, but.. have you been involved with anything remotely close to that scale?)
And if not, whence he high horse?
I and most other customers would argue that 6 minute loading times are atrocious, and if there is an easy fix like this, it makes me lose a lot of respect for the developer who doesn’t fix it. It maybe would even make me avoid them in the future.
A reputation is built over years, but can be lost pretty much instantly. Companies have to continue serving their customers to enjoy ongoing success.
The fact that GTAO is so popular should make most HNers rethink what they know about the commercial necessity of optimization vs building a compelling product.
This really only goes to show how much you can get away with if you have an outstandingly popular product that has no direct competition. Chances are that your product is not that compelling, if it performs poorly, that will hurt adoption. It will never become outstandingly popular in the first place.
Maybe it got better in recent releases, I kind of stopped following after GTA4.
They're basically saying that GTAV's massive commercial success should grant it immunity to criticism.
For what it's worth, 10MB of JSON is not much. Duplicating the example entry from the article 63000 times (replacing `key` by a uuid4 for unicity) yields 11.5MB JSON.
Deserialising that JSON then inserting each entry in a dict (indexed by key) takes 450ms in Python.
But as Bruce Dawson oft notes, quadratic behaviour is the sweet spot because it's "fast enough to go into production, and slow enough to fall over once it gets there". Here odds are there were only dozens or hundreds of items during dev so nobody noticed it would become slow as balls beyond a few thousand items.
Plus load times are usually the one thing you start ignoring early on, just start the session, go take a coffee or a piss, and by the time you're back it's loaded. Especially after QA has notified of slow load times half a dozen times, the devs (with fast machines and possibly smaller development dataset) go "works fine", and QA just gives up.
The best algorithm for small, medium or a large size are not the same and generally behave poorly in the other cases. And what is small? Medium? Large?
The truth is that there is no one size fits all and assumptions need to be reviewed periodically and adapted accordingly. And they never are... Ask a DBA.
The problem is that when you double the amount of stuff in the JSON document, you quadruple (or more) the scanning penalty in both the string and the list.
Why quadruple? Because you end up scanning a list which is twice as long. You have to scan that list twice as many times. 2x2 = 4. The larger list no longer fits in the fast (cache) memory, among other issues. The cache issue alone can add another 10x (or more!) penalty.
Well, that is an abuse of the term, by people that sometimes don't actually know what that really means. Up to a point, quadratic IS faster than linear after all for example. Too many developer love too abuse the word blindly.
If it is badly tested with no data, it is badly tested with no data. Period. Not "quadratic".
> The problem is that when you double the amount of stuff in the JSON document, you quadruple (or more) the scanning penalty in both the string and the list.
My point was precisely it depends on the data and initial assumption are to be routinely revised. I was making a general point.
Maybe the guy was pinky-sworn that the JSON would hardly change and that the items were supposed to be ordered, sequential and no more than 101. For all you know it is even documented and nobody cared/remembered/checked when updating the JSON. But we don't know, obfuscated code don't comes with comments and context ...
Or, it is actually a real rookie mistake. It probably was, but we don't have all the facts.
There is absolutely no guarantee that a quadratic algorithm has to be faster than a linear algorithm for small N. It can be, in some situations for some algorithms, but the complexity class of the algorithm has nothing to do with that. A quadratic algorithm may well be slower than a linear algorithm for any N.
The only thing the complexity class tells us is that starting from some N the linear algorithm is faster than the quadratic algorithm. That N could be 0, it could be 100, or it could be 1 billion.
In my experience it's usually between 0~1000, but again, that depends. The complexity class makes no such guarantees. The complexity class tells us the general shape of the performance graph, but not exactly where the graphs will intersect: this depends on the constants.
> If it is badly tested with no data, it is badly tested with no data. Period. Not "quadratic".
It is both. The problem is that the algorithm has quadratic complexity. The fact that it was badly tested caused this fact to remain hidden while writing the code, and turn into a real problem later on.
The problem with this argument is that if the data size and constants are sufficiently small enough people don't care about whether the linear algorithm is slow. In the case of JSON parsing the constants are exactly the same no matter what string length algorithm you use. Thus when n is small you don't care since the overall loading time is short anyway. When n is big you benefit from faster loading times.
I honestly don't understand what goal you are trying to accomplish. By your logic it is more important to keep short loading times short and long loading times long rather than do the conventional engineering wisdom of lowering the average or median loading time which will sometimes decrease the duration of long loading screens at the expensive of increasing the duration of short loading screens.
Yes. That is literally the entirety of the issue: online loading takes 5mn because there are two accidentally quadratic loops which spin their wheel.
> The best algorithm for small, medium or a large size are not the same and generally behave poorly in the other cases.
“Behaves poorly” tends to have very different consequences: an algorithm for large sizes tends to have significant set up and thus constant overhead for small sizes. This is easy to notice and remediate.
A naive quadratic algorithm will blow up your production unless you dev with production data, and possibly even then (if production data keeps growing long after the initial development).
In GTA V, when I tried to enjoy multiplayer with my friends the abysmal load times were what killed it for me.
You actually have to load into the game world - which takes forever - before having a friend invite you to their multiplayer world - which takes forever, again.
So both a coffee, and a piss. Maybe they fixed that now?
It kind of baffles me that they haven't bothered to fix this trivial issue when the result is to cut 4 entire minutes of loading time.
I never learned the "other side" of this story, but a few years later the same dev team tried to recruit me at a CS contest, to which I politely declined.
More details: I was young, without credit card, and gaming on a mac. AA was free and mac compatible. For a while -- apparently mac ports of unreal engine games were approximately all done by a single very productive contractor and from what I understand the US Army, uhh, stopped paying him at some point. So he stopped releasing the mac ports. From my point of view, this meant that I could only play with other mac users and couldn't use any of the fancy new maps. Logs indicated that the compatibility problems with the new maps were not particularly deep, so I got to parsing the unreal map files and was able to restore compatibility by deleting the offending objects. I implemented texture decoding/encoding mostly for curiosity and because textures were well documented in the reverse engineering "literature." I imagined a workflow where someone would bulk export and re-import textures and aside from the texture names the one piece of metadata I needed was the format: RGBA (uncompressed) or DXT (compressed)? I realized that I could easily identify DXT compression from the image histogram, so I didn't need to store separate metadata. Nifty! But it didn't work. Lots of textures stored in uncompressed RGBA8888 "erroneously" round-tripped to DXT. After poring over my own code, I eventually realized that this was because on many of the textures someone had enabled DXT compression and then disabled it, dropping the texture quality to that of DXT while bloating the texture size to that of RGBA8888 (other textures were still stored as DXT, so compression itself was still working). I wrote a quick tool to add up the wasted space from storing DXT compressed textures in uncompressed RGB format and it came out to about half the total disk space, both before and after the top level installer's lossless compression. They could have re-enabled compression on most of the textures where they had disabled it without loss in quality, and if they had wanted a list of such textures I would have been able to provide it, but it didn't go down that way. When I shared what happened with my father, who had served, his reaction was "Now that's the Army I know!"
This could easily compete for the most expensive bug in history, up there with the Pentium Bug. It might have halved the revenue potential of a billion dollar franchise.
Reminds me on loading "G.I. Joe" (from Epyx) on the C64 with a 1541 floppy disk. However, the long loads came after every time you died and meant you also had to swap 4 disks.
To be fair to GTA V, I don't think my installation was on a SSD because it was 50GB or something at the time (now it's 95GB?), but that said when it released SSDs were not as cheap or widespread as they are now so that's their problem. The linked article shows the initial load to be much shorter which did not match my experience.
Which meant the game displayed "rewind to mark 500 and then hit play" and you had to do that to restart lolsob.
I suppose devs dont care about that as long as their QA allows it.
Call of Duty: Black Ops Cold War is around 200GB fully installed with all features (HD textures etc).
Some people have insinuated this is intentional to crowd out other games on console hard disks and make moving away from CoD have an opportunity cost. It's probably just laziness.
I haven't looked into it in the past but some prior offenders had a lot of space wasted from uncompressed multi-lingual audio. Instead of letting us choose a language it installs them all so you can switch in game, and uncompressed for saving the CPU for game logic. For CoD the optional HD texture pack is 38GB so that's still a lot unaccounted for.
It's not like decoding audio takes enough time on any modern multi-core processor to disrupt the game loop. It's not even on the radar.
Many 8bit Atari owners will have horror memories of aborted Tape loads. After over 20 years someone finally discovered a bug in original ATARI Tape loading ROM routine resulting in randomly corrupted loads, no amount of sitting motionless while the game loads would help in that case :)
Is that... the same problem? Is microtransaction data different in your friend's multiplayer world than it is in the normal online world?
Had been like that for nearly a year. A few minutes of work brought out client js file from 12MB to less then 1mb.
Is that a library? Or the string "Chuck Norris"?
I also had a customer discover a playboy center page at the end of a test we sent to them. One of the dev thought it'd be a nice reward. Things went very bad from him right after the phone call...
Had someone at work mention they needed to drop off a dog at grooming on the way to pick up Chinese.
I had to walk away for a bit, as I couldn’t hold it in, but didn’t know if that sort of humor would fly with that crowd.
It certainly caught my attention.
Most often I use unicode strings in unexpected alphabets (i.e. from languages that are not supported by our application and that are not used by the mother tongue of any developer from our team). This includes Chinese, Malayalam, Arabic and a few more. There was a time when I wanted to test the "wrong data" cases for some deserialising function, and I was part annoyed and part amusingly surprised to discover that doing Integer.parseInt("٤٣٠٤٦٧٢١") in Java does parse the arabic digits correctly even without specifying any locale.
I'm sure there are libraries to parse json in C++ or at least they should have built something internally if it's critical, instead they have someone less experienced build it and not stress test it?
There certainly are, but adding a library is much more difficult in C++ than pretty much any other language which seems to tempt people into hacky self-built parsing when they really ought to know better.
https://github.com/nlohmann/json
I know because I used it years ago in school.
One of the fastest libraries (https://github.com/miloyip/nativejson-benchmark#parsing-time) is also header-only and compares its speed to strlen.
The only thing most game companies do when it comes to external libraries is to copy the source code of it into their repo and never update it, ever.
OpenSSL is this way, it's a required installation for Playstation but debugging it is seriously hard, and perforce (the games industries version control of choice) can't handle external dependencies. Not to mention visual studio (the game industries IDE of choice..) can't handle debugging external libraries well either.
So, most game studios throw up the hands, say "fuck it" and practice a heavy amount of NIH.
[0] Despite it being an obvious anti-pattern that you aren't going to update dependencies that require copy/paste and manual merge reviews, so security problems should be obviously more rampant than in systems where updating a dependency to the latest security patch is a single install command line (or update button in a GUI), there still seems to be so many C++ devs that love to chime in to every HN thread on a package manager vulnerability that they don't have those vulnerabilities. They don't "have" dependencies to manage, no matter how many stale 0-Days they copied and pasted from outside projects, they don't count as "dependencies" because they are hidden who knows where in the source tree.
I really liked this article, but I am a bit surprised that this made it into production. I have seen a few instances of this type of slowdowns live for very long, but they tend to be in compile times or development workflow, not in the product itself.
I mean I can understand it, a lot of extensions don't need to be on the critical path.
But at the same time, I feel like Chrome could do things a lot better with extensions, such as better review policy and compiling them to wasm from the extensions store.
confirmed by Tampermonkey dev.
Might be, but this particular issue has been raised by thousands of players and ignored for *years*.
The only possible explanation is that management never made it a priority.
I could see this happening. A project/product manager thinking "We could spend $unknown hours looking for potential speedups, or we could spend $known hours implementing new features directly tied to revenue"
Which is kind of ironic since this fix would keep players playing for more time, increasing the chances that they spend more money.
I think we need a new vocabulary to cover situations like this one. It's not just that other issues took priority here, it's that this wasn't even entered into the list of things to give a crap about. It's something like digital squalor.
Boiling the frog, as it were. This class of problems is why I want way more charts on the projects I work on, especially after we hit production. I may not notice an extra 500ms a week, but I'm for damn sure going to notice the slope of a line on a 6 month chart.
Our customer portal loads 2 versions of React, Angular, Knockout and jQuery on the same page? Doesn't matter, it's printing billions of dollars.
Rockstar's money printer is so loud that they don't care about problems.
Same thing for Valve, their money printer is so loud that they barely bother to make games anymore and let the Steam client languish for years (how did they let Discord/Twitch happen?).
sharepoint is probably many non-engineer's very first exposure to actual version control with checkouts, checkins, version history, and merge.
Isn't the search issue more of a indexing engine problem though? Can you plug in other engines?
Like...I don't need it to notify me that I have new e-mail. I already have either Outlook or an Outlook tab running.
Sharepoint is a shining example of feature creep run wild.
Not sure that's a fair criticism.
Alyx was widely praised. Artifact... Wasn't. I don't know about Dota Overlords. And that's just the last couple of years.
They've also developed hardware like SteamLink, Steam Controller, some high-end VR gear...
They develop a LOT. They just don't release a while lot.
I agree there should be a lot more work and effort in the client. And they constantly fuck up handling their esports.
But I don't think "barely bother to make games anymore" isn't one of them.
Valve unlike most companies maintains their games for more than 10 years.
Just because they haven't released anything obvious to the casual observer like new single player titles that is easily marketed is only showing your ignorance of Valves entire catalog of games, and attitude to development.
Their chat system has been famously bad and mostly unchanged since the early 2010's, and only very recently was reworked into this.
Well, I'm using VoIPs basically for >decade everyday and voice quality was never something I cared about (I mean that all soft that I've used was somewhat decent in that matter)
the most important thing is - how to get all people on the same program? and I'm finding it not so realistic to get all friends to Steam
Nowadays, I find Steam Chat is a ghost town.
You can buy in-game currency for real world money tho: https://gta.fandom.com/wiki/Cash_Cards
Not 100% sure, never bought anything.
As for profiling, Windows Performance Toolkit is the best available no?
Unjustly, but legally. The people you should be salty at are the lawmakers.
Also
> I don’t think there’s any easier way out.
lmfao
[1]https://en.wikipedia.org/wiki/List_of_best-selling_video_gam...
I don't know, even though there is shooting in GTA I don't think I'd call it a shooter.
> Not official; the numbers were estimated following a Steam API data leak in July 2018, which gave player ownership estimates for games on the platform that have achievements.
However, games like PUBG and Fortnite are free-to-play (PUBG is only free on mobile?) so in terms of actual sales, you could say GTA is more successful. Still not sure I'd class it as an "online shooter", though.
We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.
Yet we should not pass up our opportunities in that critical 3%.
Given how incredibly successful it's been, it's conceivable the suits decided the opportunity cost of investing man-hours to fix the issue was too high, and that effort would be better spent elsewhere.
We're talking about an issue that has been loudly complained about for 7 years (and I am evidence that it makes people play the game much less often than they would like to) that some person without access to the source code was able to identify and fix relatively quickly, it would be surprising if it took an FTE 1 week to find this with access to the source code.
This is one of the most profitable games ever, they could hire an entire team to track this down for half a year and it wouldn't even be noticeable on their balance sheet. And I would bet money that it would have increased their active player base (which they care about because of the micro-transactions) in a noticeable way, as long as players were aware of the improvement so they would try it again.
For instance, everyone tells you not to optimize CPU time outside of hotspots, but with memory usage even a brief peak of memory usage in cold code is really bad for system performance because it'll kick everything else out of memory.
The next step is to optimize away from the cognitively optimal, but only when necessary. So yeah it’s really crazy this was ever a problem at all.
It's just a zero cost one, so if anybody appears complaining that you are caring to choose the correct data structure and that's premature (yeah, it once happened to me too), that person is just stupid. But not calling it an optimization will just add confusion and distrust.
Here the wrong data structure has been used in the first place.
Most of my optimization work is still done with pencil, paper and pocket calculator. Well, actually, most of the time you won't even need a calculator.
I don't think the anti-code-optimization dogma will go away, but good devs already know optimality is multi-dimensional and problem specific, and performance implications are always worth considering. Picking your battles is important, never fighting them nor knowing how is not the trick.
Still, people applying optimizations that sacrifice maintainability for very little gain or increase bugs are still doing a disservice. People who understand data flow and design systems from the get-go that are optimal are where it's at.
See, that's exactly why you're wrong. This wasn't a bad "design". If the fix required to rebuild the whole thing from scratch, then you would have a point and thinking about it "prematurely" would've been a good idea. In this case, both the fixes were bugs that could've been fixed after the game was finished without having to undo much of the work done.
The whole point of the saying is that you don't know what's gonna be a bottleneck until after. Yes by optimizing prematurely, you would've caught those two bugs early, but you would've also spent time analyzing a bunch of other things that didn't need to be analyzed. Whereas if you analyze it at the end once people complain about it being slow, you're only spending the minimum amount of time necessary on fixing the things that matter.
I think that we should also stop doing crash tests in cars. Just release the car to the public and analyze human crashes afterwards.
Premature optimization is about trying to optimize the micro (a given function), while you don't yet have the macro (the game itself). If the function accounts for 0.1% of the performance of the final game, it doesn't matter if you make it 5x faster since that will only make the game 0.08% faster. You could've spent that time optimizing a different function that accounts for 10% of the performance, and even optimizing that function by 5% would make the game 0.5% faster, which is more impactful.
That should be embarrassing for Rockstar but I don't think they would even notice.
Which makes the persisting loading issue all the weirder.
> Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered.
And he is explicitly advocating for optimizing the critical part:
> Yet we should not pass up our opportunities in that critical 3%.
And somehow, people have latched onto the catchphrase about "early optimization" that was taken out of context.
The reason for the misunderstanding is that the kinds of practices it actually talks about are uncommon today. People would often take stuff written in higher level languages and reimplement them in assembler or machine code. Which makes them more time-consuming to change/evolve.
It also isn't like it is hard to figure out which part of a piece of software that is taking up your runtime these days. All worthwhile languages have profilers, these are mostly free, so there is zero excuse for not knowing what to optimize. Heck, it isn't all that uncommon for people to run profiling in production.
Also, it isn't like you can't know ahead of time which bits need to be fast. Usually you have some idea so you will know what to benchmark. Long startup times probably won't kill you, but when they are so long that it becomes an UX issue, it wouldn't have killed them to have a look.
There's the answer right there. They figure it's making $1B/yr, leave it alone. Maintenance? That cuts into the billion. Everyone moved onto the next project.
When I played it wasn't uncommon to spend 30 minutes mostly looking at the loading screen while you were trying to set up a play session with a couple of friends.
If you're an adult with limited playtime it's just a complete dealbreaker. You can't just decide to have a quick 20minute play session if you know that you'll have to spend at least half of it looking at loading screens.
The duplicate checking on the other hand is a classic "accidentally quadratic" case that is obvious.
This oversight has cost them millions of dollars easy.
Probably ranks pretty highly up there in terms of damage to company financials, due to a lack of care.
I think you might be surprised by how few programmers even know what a profiler is, let alone how to run one.
I disagree. If there are no internal incentives for the people who know how to fix this to fix it, or if there's no path from them thinking fixing it could improve revenues to being assigned the ticket, things like this won't get fixed. I can fully believe the load times will result in fewer users and lower expenditure.
I think we'll see this happen with Facebook Messenger. Both the apps and the website have become slow and painful to use and get worse every month. I think we'll start to see engagement numbers dropping because of this.
The messenger website has been atrocious for me lately. On my high-powered desktop, it often lags a bit, and on my fairly high-end laptop, it's virtually unusable. I thought it must be something I changed in my setup, but it's oddly comforting to hear that I'm not the only one with such issues.
It's funny. That page says "A simple app that lets you text, video chat and stay close to people you care about." If it's so simple, then why does the browser version of the site take forever to load?
Like anything else, things will be as bad as the market allows. So I'd expect monopolies to do a worse and worse job of making good decisions and companies in competitive fields to do a better and better job over time. Thus the difference between TakeTwo and Facebook, and the need for lower cost of entry and greater competition in all economic endaevors where efficiency or good decision making is important.
In fact, I think the iOS app for FB Messenger did get a redesign due to problems and it’s rewritten from scratch? I remember being pleasantly surprised after the big update… It became lightweight, integrates well with iOS and supports platform features.
On the other hand, the desktop app or the website is a shitshow :-(
Is GTA online still attracts new users in droves? I doubt.
If the old users live with the loading time for years, they are likely to continue living with it. It would be nice if Rockstar fixes it, but I doubt it would be anything except a PR win.
Any sufficiently large institution, over time, will prioritise self-preservation over achieving their core mission. This is sociology 101. Once a company has enough users to make it hard or impossible to measure immediate performance, self-preservation is achieved with internal manoeuvering and selling to execs.
The HN discussion[1] was started by an article that provided numbers that seemed to suggest that Wikipedia's spending was slowly spiraling out of control.
What really stuck out is that Buffet said its the most important thing about Business and he didn't learn it in Business school. Same! I did an MBA and it was the biggest elephant in the room.
"if you’re not watchful, the process can become the thing. This can happen very easily in large organizations. The process becomes the proxy for the result you want. You stop looking at outcomes and just make sure you’re doing the process right"
After tangentially working on this for a long time I'd say that the core issue is so deeply ingrained in human psyche that it may not even be a matter of education (starts early), let alone organization (starts happening when everything else is "set in stone"). There's no organizational structure that fits the types of activities we humans tend to do these days and that can deliver low latency, consistent results at scale. We mitigate issues in one area by accentuating them in others.
You can have one large flat structure but the load on the single coordinating circuit (the manager) will compromise quality. You can split the thing in multiple, individually coordinated units but the added layer of coordination and latency will compromise performance.
Maybe some form of general purpose but not quite full AI, something that combines human like intelligence and engineering like consistency, might be able to do what humans are supposed to but without the variability of humans (which is both good and bad).
We don't really know what it is simply because we haven't introduced any "real" AI anywhere, let alone:
>> some form of general purpose but not quite full AI
Talking about efficiency as you scale up large organizations, it's inevitable that humans will introduce delays and variability in the work which cannot be eliminated because it's human nature, biologically and psychologically. Since humans can't change on a timescale that makes this discussion relevant, the only way for very large organizations (like large companies or governments) to operate just as efficiently as small ones is if they rely (quasi)exclusively on some AI that's as capable as top individuals at delivering results but with fewer of the drawbacks. Not only would it not operate as 100.000 distinct entities but as one or a few, it would also run consistently and predictably.
This doesn't happen because it would reduce the power of top decision makers and potentially impact profits. e.g. a customer might ask for a chronologically ordered timeline on Facebook, but that would harsh engagement metrics, revenue, etc. If stuff like this did happen more often though, you'd get products and services that more often achieve their stated aims.
Normally the response from management was "but will that increase our profits?", to which my answer was "eventually, yes"
In games the added reason to be slow is that game code is by definition some of the least mission critical code one could find (competes with 90% of the internet web code). Your Linux or Windows code might run a hospital's infrastructure or a rover on another planet. A game on the other hand can launch with bugs the size of your windshield, and can stay like that forever as long as people still pay. And people will pay because games are not unlike a drug for many people.
As such most game coding teams and coders are "trained" to cut every corner and skimp on every precaution. They're not needed beyond a very low baseline as far as software is concerned.
Look at the amount of bugs or cheats incredibly popular games like GTA or CoD have. These are billion dollar a year franchises that leave all this crap on the table despite all the money they make. They have all the resources needed, it's a conscious call to proceed like this, to hire teams that will never be qualified enough to deliver a high quality product and will be encouraged to cut corners on top of that.
Source: a long time ago I worked for a major game developer in a senior management role (unrelated to the dev activity) and left after feeling like "facepalm" for too long in every single SM meeting.
https://randomascii.wordpress.com/2021/02/16/arranging-invis...
I've seen plenty of interesting bugs, best I found personally was a compiler that was outputting files 1 byte at a time.
Games are riff with these sorts of bugs, but the volume of released games vs other types of software makes any sort of comparison unfair.
No comparison is entirely fair but I think your objection is unfounded. The quantity of games being released is irrelevant when we're talking about the quality of their code. Which is really bad for most big titles.
If anything the comparison was unfair in the other direction. Sure, an OS or browser have a lot of bugs. But if games and their code had a fraction of the scrutiny something like Windows gets you might just find out that 4 lines of code were written "by the book". It's something any honest game dev will confirm, game code is a stack of spaghetti code on top of more spaghetti code. The philosophy is that you can just go ahead with bad code because you can always fix it with a patch later on. Then you notice there's no widespread pushback from gamers (because unless it's an absolute bomb there won't be) and move on with the next round of "features", nobody has time for fixing bugs or combing the spaghetti.
One other problem is that eventually some people coming from the gaming industry will end up switching to other types of software development but will stick to the philosophy. I've done a lot of hiring over my career and of one thing I'm certain. Whenever someone came with most of their career in game development or most of the recent experience I asked for the CV to be put at the bottom of the stack. It was a lesson I learned the hard way.
Issues like the low criticality of game code, the "crunch" work style, the idea that you should just get it out there as quickly as possible, the lack of serious scrutiny into the matter, etc. all compound each other to create a coding (and coordination) style that's hard to shake off.
I should have clarified.
Doing an absolute numerical comparison in terms if "bad game code" to "bad B2C code" is unfair, because now days there is a lot more game dev code than B2C code (if we ignore the web, which is a rather lot of code to ignore I'll admit :) ).
All that said, most of the games on my phone run very well. Most of the games on my PC run very well. Do the massive over budget AAA titles have issues? Of course. Human organizations are really bad at creating large projects, we all know that social interaction overhead scales non-linearly with # of people, large projects get bogged down.
(Now throw in B2B software where the CTO makes the purchasing decisions and only people lower level in the company have to use it. All of a sudden enterprise software starts to suck as much as AAA games!)
> The philosophy is that you can just go ahead with bad code because you can always fix it with a patch later on.
Sure, for AAA games. But plenty of games that I play don't have those sorts of issues.
Meanwhile my Windows start menu only opens every other time I press the start menu button. This happened for years, then it was fixed for a bit, then a few patches later it started happening again.
The start menu on Windows should be the 2nd to last thing that breaks, right behind the mouse driver.
Without huge testing efforts, large software projects will collapse under its own weight. The type of software isn't material to the problem.
> One other problem is that eventually some people coming from the gaming industry will end up switching to other types of software development but will stick to the philosophy.
I've hired plenty of ex-game devs, I agree they have some holes in their skills. But I've also found out that if you sit them down they can write code that traditional software engineers couldn't manage. Spending too long in any one paradigm fixes ones mindset into that paradigm.
I also agree that the quality of code someone puts out is highly influenced by the environment they work in. But I've worked with plenty of ex game devs who take pride in writing correct code the first time around.
> Whenever someone came with most of their career in game development or most of the recent experience I asked for the CV to be put at the bottom of the stack.
That's a shame, because I wouldn't have accomplished some of the things I've done in my career if I hadn't hired a few game developers along the way! I've seen some stupid crazy stuff get pulled off, code that "shouldn't be able to exist", but did exist, and was rock solid reliable, all written by game developers.
People are people, and sure 9 out of 10 the person who bangs on kernels for a living is probably super careful about every line of code they write, but I'm not going to judge an entire field because the most bureaucratic outputs of that field are horrible.
That'd be like saying everyone who writes web apps is an incompetent developer because Jira is slow.
Or that all software developers are bad because, honestly, the majority of users only notice what we make when it breaks.
Well, we only hear about the small % of games that have huge problems, not the larger number of games that work just fine out of the box.
2. we can be reasonably sure people will buy newer GTA installments regardless of whether this bug is fixed or not.
but:
3. if there's still money to be made from microtransactions this is a huge issue and would absolutely be worthwhile, imo.
If it ever reached the point where it had to be an item in a priority list, it's already a failure. Some developer should have seen the quadratic behavior and fixed it. It's not the type of thing that should ever even be part of a prioritized backlog. It's a showstopper bug and it's visible for every developer.
This bug wouldn't present in the first couple years with the limited amount of DLC, so by the time it got ridiculous there wasn't anyone left with the confidence to profile the game and optimize it. A junior dev could fix this, but would probably assume that slow loads are a deep complex engine problem that they won't be able to fix.
Alternatively, management would declare that there's too much risk doing more technical engine work, and not sign off on any proposed "minor" optimizations because it's too risky.
GTA Online loading times have been infamous for a very long time. They were already unjustifiably bad when they released the game for PC, and at that point engine programmers would surely be involved.
I'd guess also that the next version of the base engine is in RDR2 or later and doesn't have these issues. But at the same time they likely wouldn't backport the changes for fear of cost overruns.
Likely it wasn't fixed precisely because it's such a cash cow. "It's making money, don't fuck with it".
Ohhh. Thank you for telling me about this. I just found a mirror and successfully built it for macOS. Runs so much better than the wine version. But I guess I'll never finish that RC helicopter mission anyway lol
Management: So, what can we do about the loading times?
Programmer(s): That's just how long it takes to load JSON. After all, the algorithm/function couldn't be more straightforward. Most of the complaints are probably coming from older hardware. And with new PC's and next-gen consoles it probably won't be noticeable at all.
Management: OK, guess that's that then. Sucks but nothing we can do.
Management had no idea of knowing whether this is true or not -- they have to trust what their devs tell them. And every time over the years someone asked "hey why is loading so slow?" they get told "yeah they looked into it when it was built, turns out there was no way to speed it up, so not worth looking into again."
And I'm guessing that while Rockstar's best devs are put on the really complex in-game performance stuff... their least experienced ones are put on stuff like... loading a game's JSON config from servers.
I've seen it personally in the past where the supposedly "easy" dev tasks are given to a separate team entirely, accountable to management directly, instead of accountable to the highly capable tech lead in charge of all the rest. I've got to assume that was basically the root cause here.
But I agree, this is incredibly embarrassing and unforgiveable. Whatever chain of accountability allowed this to happen... goddamn there's got to be one hell of an internal postmortem on this one.
Programmer: Loading times are really slow, I want to look into it next sprint.
Management: Feature X is higher priority, put it in the backlog and we'll get to it.
But I could be wrong. I've only worked with sites and apps not gaming.
I don't think you choose to become a manager at one of the world's top video game companies if you don't love video games.
Hell, I don't think one of the world's top video game companies would hire you as a manager if you didn't convince them, in interviews, that you understand and love their products by using them yourself.
Using your own company's products whenever possible is generally a pretty important part of being a manager.
Aside from being generally shameful, the real kicker was that this was a "website performance & reliability" company x__x
Many of us, after having run out of other crap to do, would sit around and wonder if the "B" grade network engineers were assigned to run the company LAN, or the ones we sent onsite were as incompetent.
Internal IT is almost invariably a cost center, the technicians providing the service you are selling to customers are working in a profit center. So, yeah, probably that plus be managed in a way which focussed on minimizing cost not maximizing internal customer satisfaction or other quality metrics.
In this case it was a JSON, but using .NET so Newtonsoft is at lease efficient. The issues were many cases of: * Converting string to lowercase to compare them as the keys were case insensitive. (I replaced with a StringComparison.OrderinalCaseInsensitve) * Reduntant Dictionary's * Using Dictionary<Key, Key> as a Set. replaced with HashSet.
The data wasn't meant to be that big, but when a big client was migrated it ended up with 200MB of JSON. (If there data was organised differently it would've been split accross many json blobs instead)
It would also be nice to handle it alls as UTF8 like System.Text.Json does. That would half all the strings saving a fair bit. (I mean the JSON blob it starts with is converted to UTF-16 because .NET)
Same thing happened with memory consumption. The problem was ignored until we regularly had background jobs using > 4 GB of memory, causing cascading failures of our EC2 instances and a whole bunch of strange behaviour as the OOM killer sniped random processes.
Programmer(s): Can we set aside some time to fix the long loading times?
Management: No, that won't earn us any money, focus on adding features
I work LiveOps and usually long loading times are something that we would take seriously, as it negatively impacts the reputation of the game.
It is both believable and - by virtue of the fact that, as you said, the series continues to be a cash cow - is apparently forgivable.
Here's the thing: the company has zero reasons to fix this, or other ostensibly egregious affronts like DRM, because gamers keep buying the product. There is literally no economic incentive to 'fix' it.
(Same thing for websites - they show you all the annoying popup signup sheets/survey questions the instant you load the page.)
Judging by the number of successful sequels the franchise has spawned, the answer is 'an insignificant number'.
The fact of the matter, and the point my comment was trying to make, is that the overwhelming majority of players do not sufficiently care about load times or other complaints to deter them from paying for the game. That is the reality of the situation.
I'd say especially since the ones who are most likely to be affected by these issues are working adults with limited playtime who won't want to sit in front of their monitor for 5 minutes waiting for the game to load and also happen to be people with disposable income to pour into a game.
"Unbelievable" and "unforgivable" eh? It's a greedy attitude. Instead of viewing GTA5 as a success that's brought a lot of people happiness, you view it as a money cow designed to extract every last bit of profit – and time, since this bug caused 70% longer loading times.
Perhaps it's both. But you, sitting here behind a keyboard with (correct me if I'm wrong) no gamedev experience, have no idea what it's like on a triple-A gamedev team with various priorities. The fact that the game works at all is a minor miracle, given the sheer complexity of the entire codebase.
The fact that someone was able to optimize the obfuscated executable is a wonderful thing. But they weren't a part of the team that shipped GTA 5. If they were, they certainly wouldn't have been able to spend their time on this.
It’s ok to recognize a thing as a business success but a technical failure. In fact many software projects are business successes despite awful and unforgivable quality compromises. You don’t get to whitewash it just because the thing prints money.
This is not small. This kind of incompetency if employed in a different sector such as security would lead to losing personal data of millions.
> “it’s a miracle software works at all”
This is not the case here. Please re-evaluate your calibration on this topic.
2. this kind of incompetence exists in all other sectors. That's why pentests are so crucial, and why they guard the security of millions.
3. we'll have to agree to disagree that it's a minor miracle. Having seen the complexity firsthand, it's quite amazing.
The complexity is in reverse engineering the binary. The developer has access to the full source code and the profiling tools I presume.
Another one is in Microsoft Flight Simulator, instead of downloading multiple archives, it downloads one, unzips it using a single CPU core and then downloads another one. MSFS 2020 takes a few hours to install and that's not just because of the internet connection, but this shitty installation code.
This is what you'd need to decide. And then afterwards, it might not print as much money as you think it will.
It's easy looking at it from the outside. Not so easy from the inside.
I'll meet you halfway though: they should have had profiling sessions that pointed to the JSON parsing code as the issue. I imagine that all of their profiling efforts were focused on the runtime performance, not the load time. Simply put, no one did that profiling, and I don't fault them for focusing on runtime performance (which is where the real money is, as Cyberpunk 2077 demonstrated by not having it, and subsequently having their PS4 orders yanked and refunded).
Once again - Control by Remedy ran on base PS4 at 10 frames per second, TEN frames. Critically acclaimed, reviewers loved it and didnt tend to mention TEN frames per second on base consoles, not pulled from the store.
Unfortunately this part often kills quality initiatives. Why fix bugs for your existing customers when you can deploy the engineering resources on a DLC or a sequel which will milk those customers for more? There is no more craftsmanship or pride in good work left in software.
"When you're a carpenter making a beautiful chest of drawers, you're not going to use a piece of plywood on the back, even though it faces the wall and nobody will see it. You'll know it's there, so you're going to use a beautiful piece of wood on the back. For you to sleep well at night, the aesthetic, the quality, has to be carried all the way through." -Steve Jobs
If this is a serious question, I'd say cut any of the new vehicles introduced in the last 2 years. None of them are nearly as impactful as this optimization. In fact, I am having issues imagine any individual feature at all that's as important as this fix.
Tweaking two functions to go from a load time of 6 minutes to less than two minutes is something any developer worth their salt should be able to do in a codebase like this equipped with a good profiler.
But, I fully agree with your assessment, for what it's worth.
But a manager shouldn't even have to do that, because in a well functioning team, if the dev leads come back with such a fix, they won't get punished for going off the reservation and would probably be doing this of their own initiative.
But if things like that get met with "why have you wasted time on this? we gave you the list of priorities and it does not include load times" then dev leads will make sure all developers time is filled with things which are prioritized.
Edit: grammar
How much would it have cost to fix this issue?
Is anyone saying that it is a game developers fault? I mean, what is that you think would prevent a game developer from fixing this?
Because I think, anyone even vaguely familiar with the software industry in general is going to come up with answers like:
1. It would not cost very much 2. No it isn't a developers fault, because it's clear that even an intern could fix this 3. Management isn't interested, or is too disorganized, or focussed on cynical extraction of every last bit of profit.
And from that perspective, it certainly does make it seem like a cynical cash cow.
I don't know many game developers, but I do know people in other parts of the software industry and professionals in general. And I think that they keep to themselves because they have first hand experience of how the industry works and understand it better than anyone. The probably sympathise with the right of the public to feel ripped off.
That said, I still paid for the game, I think it's fun. Apparently there is "no alternative" to this state of affairs.
Well, that's the nominal full retail price against which the various discounts are measured, sure, but I doubt that's what most people buying it these days pay except if they are getting something else with it. I'm pretty sure it's in the stack of things I've gotten free this year on Epic that's in my “I might check it out sometime” queue, it's $29.98 right now from Humble Bundle, etc.
It's actually only $30 and frequently goes on sale for $15. It hasn't been $60 (on Steam at least) since June 2018.
The problem is not that developers can't optimize things: you will find some developers capable of figuring this problem out anywhere. What makes this low hanging fruit so popular is the fact that we aren't measuring enough, and even when we do, we aren't necessarily prioritizing looking into things that are suspiciously slow.
In the case of this example, the issue is also client-side, so it's not as if it's costing CPU time to Rockstar, so it's unlikely you'll have someone who can claim their job description includes wondering if the load times are worth optimizing. When problems like this one get solved is because someone who is very annoyed by the problem and either convinces a developer to even look into the problem. Most of the time, the people that suffer, the people that get to decide how to allocate the time, and the people that are in a position to evaluate the root cause of the problem never even get to talk to each other. It's the price we often pay for specialization and organizations with poor communication.
Organizations where the people deciding what has to be done next, and where the company culture dictates that the way forward is to either complete more tickets faster, or find ways to be liked by your manager, are not going to be fostering the kind of thinking that solves a problem like this one, but that's a lot of what you find in many places. A developer with a full plate that is just working on the next feature isn't going to spend their time wondering about load times.
But instead we end up blaming the developers themselves, instead of the culture that they swim in.
This code looks like someone with almost no experience hacked it together but because they were an intern and likely Rockstar is a toxic place to work, it never gets prioritized to be fixed.
I think if managers prioritized cycle time, metri s more, they'd find that they are encouraging a lot of practices which lead to horrible efficiencies - "measure twice cut once" is a positive mantra which leads to more solid designs with less bugs.
Agile sort of addressed this problem but unfortunately only at small size scales. Iteration and story capacity got overprioritized over quality, customer engagement, and self-leading teams.
Plus things such as scaled agile suffer from the oxymoron of planning fast iteration - if you have a master plan you lose the ability to respond to change and iterate, or you allow iteration and you must accept if any team iterates the whole team must discard the plan...which at some point means you either accept high cycle times or you figure out a way to decouple functionality to the extent the planning becomes the standard fallacy of waterfall - wasting meeting time to go over a plan that isn't based on anything.
Ofc this is just a hypothesis, but I see the hesitation to change legacy code if it ain't broken as a wide spread mentality.
Load times measured in double digit minutes on a significant number of machines meets absolutely every reasonable definition of "broken".
> their parent company unjustly DMCA'd re3
Wow, this is EA games level scumbaggery... I don't think I'm gonna buy games from them again.
I'm impressed that gamecopyworld.com is still online, updated, and has the same UI that it did in 2003
which of course goes to show that at least from a business side, this issue is completely inconsequential and all resources should be used to push for more monetization (and thus adding to the problem by adding more items to the JSON file) rather than fixing this issue, because, clearly, people don't seem to mind 6 minutes loading time.
I'm being snarky here, yes, but honestly: once you make $1 billion per year with that issue present, do you really think this issue matters at all in reality? Do you think they could make $1+n billion a year with this fixed?
Having played the game, it's not surprising to me in the least.
I have never yet encountered another such 'wild-west' online experience.
It's the only game that is so un-modereated that i've ever played where the common reaction to meeting a hacker that is interested in griefing you is to call your hacker friend white-knight and ask him to boot the griefer-hacker from the lobby.
Reports do next to nothing -- and 'modders' have some very real power in-game, with most fights between 'modders' ending in one of them being booted to desktop by the other exploiting a CTD bug (which are usually chat text-parser based..)
On top of all this, Rockstar attempts to have an in-game economy , even selling money outright to players in the form of 'Shark Cards' for real-life currency , while 'modders' (hackers) easily dupe gold for anyone that may ask in a public lobby.
This isn't just all coincidence; the game lacks any kind of realistic checks/balances with the server for the sake of latency and interoperability -- but this results in every 13 year old passing around the Cheat Engine structs on game-cheating forums and acting like virtual gods while tossing legitimate players around lobbies like ragdolls -- meanwhile Rockstar continues releasing GTA Online content while ignoring playerbase pleas for supervision.
It's truly unique though -- an online battlefield where one can literally watch battles between the metaphorical white hat and black hat hackers; but it's a definite indicator of a poorly ran business when vigilante customers need to replace customer service.
Also, an aside, most 'mod-menus' -- the small applets put together using publicly available memory structs for game exploit -- most all have a 'quick connect' feature that allows hackers to join lobbies much faster than the GTA V client usually allows for. This feature has existed for years and years, and I believe it performs tricks similar to those listed in the article.
Interesting, back in the day the coolest CTD I did was to simply crank up the combo multiplier in S4 League to crash the game client on every player in the room except mine since that game was peer to peer and thus any form of hacking (teleportation, infinite melee range, instant kill, immortality, etc) was possible. The combo multiplier was set to 256 and thus every single particle was duplicated 256 times and this caused the game to crash.
Not surprised they didn't bother for 6 minutes when it takes us 10 years to fix a 30minutes locked startup.
And yet, no one cares, Those games (and GTA5) all sold millions of copies.
The only way this stuff gets fixed is if (a) some programmer takes pride in load times or (b) customers stop buying games with slow load times.
(b) never happens. If the game itself is good then people put up with the load times. If the game is bad and it has bad load times they'll point to the load times as a reason it's bad but the truth is it's the game itself that's bad because plenty of popular games have bad load times
Also, any game programmer loading and parsing text at runtime by definition, doesn't care about load times. If you want fast load times you setup your data so you can load it directly into memory, fix a few pointers and then use it where it is. If you have to parse text or even parse binary and move things around then you've already failed.
Six minutes is probably excessive, but having GTA take 1-2 minutes to load almost certainly makes people feel better about the money they spent on the game than if it loaded up in 5 seconds like some low-production 2D adventure game.
Given that it has been the most common criticism of the game since it launched, I don't think anyone views it as a sign of quality.
As things get more complex you're probably going to need to manually set some pointers after loading blobs of data and casting them.
It's just the standard way of dealing with binary files in C. I'm not sure what you'd need for search terms.
Agree. I found the slow behavior of sscanf while writing one of my first C programs during an internship^^ You literally just have to google "scanf slow" and find lots of information.
Bull. Shit.
There's plenty that can be done because there are parts of a process that don't deserve 15% of the overall budget. The fact that they are taking 1/6 of the time like 5 other things is a failure, not a hallmark of success. Finding 30% worth of improvements with this perspective is easy. 50% often just takes work, but post-discovery much of it is straightforward, if tedious.
My peers are lying with charts to get out of doing "grunt work" when there's a new feature they could be implementing. But performance is a feature.
So has that JSON always been 10mb or has it grown a lot over time?
Has the load time crept up since launch or has it gone down?
How it remained undetected for so long is really weird though. Surely they must've had a massive amount of complaints about the loading times. I completely stopped playing because of them. How could they not have investigated the root cause, atleast once, in six years?
But this seems pretty damn clean. And it’s egregious that no one at R* took a week to investigate and fix “correctly”.
Also the post where he mentions adding the branch with your fix is here: https://www.unknowncheats.me/forum/3078353-post937.html
For reference, I just ran a 10MB file through the JSON parser I use in Python and it finished in 0.047s (vs 190s)
I've had to revisit production code from time to time to discover my or my colleague assumptions about library functions were not actually true.
But for someone in the possession of the source code this looks like _minutes_ worth of profiling time! With a stellar technical accomplishment that GTA5 truly is, you would expect tons of really talented devs that could have traced this one down on their lunch break.
The fact that they didn't speaks volumes about organisational structure within R*. I think some higher up managers _really_ need some stern talking to!
It offends my taste as a software engineer and I always fix these.
Googling gave me this result, which sounds about right for what I remember. https://www.gfinityesports.com/grand-theft-auto/gta-online-h...
I’m not certain it’s still a valid workaround, and it’s not nearly as sophisticated as the OP method, but at least everyone can do it :)
Old time: 6 minutes (360 seconds). New time: 1 minute and 50 seconds (110 seconds). Speed-up calculated by article author: 1-110/360=0.694 (69.4% saved). Speed-up calculated by me: 360/110=3.27 (3 times faster).
Please calculate it the other way around. It makes great difference when you say you made something 10× faster than when you say you saved 90% of work even if both mean exactly the same thing.
Bruce Dawson has great article about this: https://randomascii.wordpress.com/2018/02/04/what-we-talk-ab...
Agreed however that this is 3x faster.
Can anyone recommend a youtube video where I can watch (not necessarily learn) people doing this sort of work? I'm in the mood for some vicarious hacking :-)
What's worth noting is that the city overview can hang for 20-30 minutes during connecting. At the same time, suspending the GTAV.exe for 20-30 seconds allows you to immediately throw the player into an empty public session. It is unlikely caused by slow parsing of json, more like the suspend causes udp timeout when connecting to the slow session hosts.
First, a disclaimer: I have no idea how much Rockstar employees are paid, nor how their workdays look like. I don't know what their team sizes are, where they worked before, or who manages who and in what fashion. I actually don't know anything about the Rockstar engineering organization at all.
I am also not a GTA player (or, more accurately, haven't been since San Andreas came out many moons ago). This is my perspective as someone who has worked for various organizations in his life ( SWE-centered ones but also other, more "traditional" ones too).
We're all familiar with technical debt - it's a well established concept by now. Reducing it is part of the normal workload for well-functioning organizations, and (good) tech leads think about it often.
What isn't talked about as often is the "organizational" debt. Some things are "verboten" - you don't touch them, you don't talk about them, and you run like hell if you're ever assigned to deal with them.
Every large enough company has (at least) one of those. It might be a critical service written in a language nobody in the team knows anymore. Maybe it's a central piece of infra that somebody wrote and then left, and it's seen patch after patch ever since. These are things that end your career at the company if the BLAME points to you after you attempted to fix them.
I have a gut feeling - not based on anything concrete, as I mentioned - that the loading part for GTA Online might be one of those things. If someone breaks the process that loads the game - that's a big deal. No one would be able to play. Money would be lost, and business-folk will come knocking.
So sure, there might be some mitigations in place - if some part fails to load they allow the game to load anyways, and then attempt to fix it mid-fly. It's not black and white. But it feels like one of those things, and so people might have just been running like hell from it for years and years. Teams change. Projects change hands. People leave, more people join. It's life in the industry.
I would be REALLY interested in learning how software orgs deal with these types of behemoths in their projects. I have yet to find someone who knows how to - methodically and repetitively - break these apart when they appear.
I ignore them until a big, big customer complains and threatens revenue, then I scream and scream until it gets fixed.
I wonder who t0st is. He lives in Moscow according to Twitter. This type of work is usually done to find vulnerability in code e.g. buffer overflows. Injecting a piece of code to program machine code is a technique used in system hacking or software piracy. I can bet t0st is working or has worked for FSB. Anyway, not that is matters... it is still fun to think about it
I did not ever consider inspecting obfuscated assembly and hooking functions to fix the problem myself. Very impressive work!
lots and lots of megawatts, not kilowatts
Don't think it's too popular, but the inspiration may be from elsewhere if you've seen it around.
I wonder if it might even be an incompatible OSS license?
I really enjoyed this article, but I do have a question about this part. Why would a single function be listed at mutliple addresses?
And going down the call tree, it's also not the start address, but the return address - so the place where in the previous function called this one.
Without debug symbols there's no way to tell if we're inside the same function block or not - it's all just addresses somewhere in the machine code.
Such silly mistakes causing such a huge delay for millions of gamers over 6 years.
Never tried consoles before, but figured the point was that it would be fast and hassle free.
GTA was fun, but after completing it I never load it, just to play for fun, because PS load times + GTA load times are too much.
Now I just play 20 year old games under wine on Linux.. that's less of a hassle, and I don't have to touch windows.
But honestly, on a large enough team with a large enough backlog much worse things slip through the cracks. Doesn't excuse this at all though.
Also kudos on the write up! Enjoyed reading it
I like the idea of fixing up some older, unsupported, games I have issues with but would like to upskill using some structured resources first (books/videos/guided projects).
Great work! This is the kind of wizard-magic I wish came naturally to me.
Then try debugging other programs.
I probably I picked up most of my reverse engineering skills practicing on crackmes and reading/watching other people's solutions on crackmes.de (now dead) but you can try your luck in the successor https://crackmes.one/
millions of players, billions of minutes wasted
when you scale things, every bit of optimizations IS MENDATORY!
#saveOurPlanet
* There’s a single thread CPU bottleneck while starting up GTA Online
* It turns out GTA struggles to parse a 10MB JSON file
* The JSON parser itself is poorly built / naive and
* After parsing there’s a slow item de-duplication routine
(Copied from the END of the article)
It bothers me that so many of us developers are annoyed by managers saying stupid stuff like "shouldn't be too hard" about things they don't understand, but then other developers walk into the same trap.
Yes, it looks simple at the surface. It most likely isn't. The problem is not that it looks simple, the problem is that you assume it is simple, probably because you don't have the full context.
I'm not saying it's impossible for this to be as easy as the author claims it to be. I'm just saying that it might not actually be that easy in reality, if you're on the inside.
Deploy one hacked version (with the dirty fix / hack for this case) to one group, deploy the standard version to another group, measure the ROI and the crash-rate.
If the results are similar, then you validate permanently the fix and live happily after.
6 minutes to 1 minutes 10 is massive, it will even bring new players to join the game (I don't like to play GTA Online, though it's a great game, just because of loading times).