Lurker News

Comments (699) 110 threads

Earlier comments
trollied6 replies#
Wow. I always assumed that profiling would be part of the pre-release test processes for AAA games...
paulryanrogers1 reply#
Could it be that MMO players are just more accustomed to long load times? (Lack of loading patience is one of the reasons I don't play SWOTOR.)
josephg#
When I used to play world of Warcraft, it never took more than 30 seconds or so to load. It got much faster over the years - when I was playing a few years ago it was more like 5 seconds from character selection to being in the world.

Nothing like the 6 minutes people are talking about for GTA. That’s ridiculous.

jimbob451 reply#
Same. I wonder if the dev didn’t bother to fix it because they assumed profiling would identify it as a non-issue.
bombcar#
I wonder if the list was much shorter at release and wasn’t super slow on Developement systems.
IgorPartola3 replies#
More importantly how do you release a game that takes 6 minutes to load? This is why mobile gaming has the advantage. In those 6 minutes I could have played a round of a game that’s quite satisfying and put it down already. This just seems sloppy.
Aerroon#
I've actually opened a game with long loading times and alt tabbed out, because I knew it would take a while. I booted up another game to play a little bit until the first game finishes loading. 3 hours later I was done playing and realized that I was supposed to play game #1.
superjan1 reply#
It’s quite possible that there were way less items in the store on launch, or during testing. Then it could easily be overlooked. Of course no excuse to not fix it later.
IgorPartola#
OK but how come even without the store it took more than 20-30 seconds? This was a beefy computer 7 years ago.
bluedino#
It was only one minute at first. As the game had content added, it got longer and longer and nobody cared.
gbl08ma1 reply#
I had heard about this giant JSON from friends in the GTA V modding community. OP's idea of what it is used for is right. My guess is that this JSON was quite smaller when the game released and has been increasing in size as they add more and more items to sell in-game. Additionally, I speculate that most of the people with the knowledge to do this sort of profiling moved on to work on other Rockstar titles, and the "secondary team(s)" maintaining GTA Online throughout most of its lifespan either didn't notice the problem, since it's something that has become worse slowly over the years, or don't have enough bandwidth to focus on it and fix it.

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 :)

wruza#
are aware of it and are saving up

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)

Negitivefrags#
When it was released the game didn't have all the microtransactions so it probably took no time at all to process the JSON even with this issue.

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.

yread#
Could be that at release the JSON was just 200kb with 1000 entries or something and this quadratic "algorithm" wasn't the slowest part of the process
animal5311 reply#
I played the game on PS3 and PC. The loading time at launch for PS3 (and later for PC, albeit on SSD) wasn't great, but it also wasn't nearly this terrible.

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.

dijit#
It's never been "good", I played since 2013, Xbox 360 and later repurchased the game for PS4, the online load times were not just annoying they outright broke the game for me. To be having fun and then have a many minute delay while being pinned to the screen (because after loading from a mission you're never in a safe place).

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

ufo1 reply#
The part that puzzles me the most was this comment about sscanf:

> 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?

JdeBP6 replies#
I think that the author hasn't checked them all. Even this isn't checking them all.

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()?

wnoise2 replies#
Wow. Thanks for looking.

> 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.))

JdeBP1 reply#
You've missed what happens in __uflow() when __toread() does not return EOF. (And yes, that does mean occasional memchr() of single characters and repeated memchr()s of the same memory block.)

Continue this thread — 1 reply

gnubison1 reply#
> 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.

Continue this thread — 1 reply

ufo1 reply#
Oh dear... that's one of the biggest footguns I've ever seen in all my years of working with C.
pja#
It is! Not mentioned anywhere in the manpages either & there’s no a priori reason for sscanf() to need to call strlen() on the input string, so most programmers would never expect it to.

Pretty sure I would have made this error in the same situation, no question.

JdeBP1 reply#
Addendum: There are C library implementations that definitely do not work this way. It is possible to implement a C library sscanf() that doesn't call strlen() first thing every time or memchr() over and over on the same block of memory.

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/...

pja#
OpenBSD is also doing the same thing. It seems almost universal, unless the libc author has specifically gone out of their way to do something different!
pdw#
> How much could life be improved if these implementations exported the way to set up these nonce FILE structures from a string

That's fmemopen. Not widespread, but at least part of POSIX these days.

thitcanh2 replies#
This is why people should use commonly-available packages instead of rolling their own version of whatever dumb algorithm they think they can write. This happens all the time. Bugs have been fixed by others, but everyone is too smart to use someone else’s code.
xyst#
seems more like a bad copy and paste situation to me. it's sort of what you get when you pay for the lowest bid for contractors.
mixologic1 reply#
Sometimes those commonly used packages end up being whatever dumb algorithm the author came up with, and nobody spends the time to verify if the package is worth it's popularity.
thitcanh#
Doubt that. Popularity comes with heaps of PRs, some useful some less.

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.

Load more comments