4 ms·
Well, that's embarrassing. I can't even imagine the level of shame I would feel if I had written the offending code. But, you know, premature optimization yadd
by luckystarr 6y ago
Well, that's embarrassing. I can't even imagine the level of shame I would feel if I had written the offending code.
But, you know, premature optimization yadda yadda.
- whatever1 6y agoProbably this was written under a very strict release deadline and it worked ok at the time (less items for microtransactions). The problem lies with the management that never picked up the issue once it became a big problem. Pretty sure that any developer in R* is capable of optimizing this parser.
- nine_k 6y agoAs they say, a lot of classified stuff and closed-source code remains classified and closed not because it contains important secrets, but because those who hold the lock feel too ashamed and embarrassed to show the contents.
- rcxdude 6y agoIt's the kind of thing that's very easy to accidentally write, it's not that shameful. What's shameful is not investigating the load times at all, since the problem is so easy to see when any measurement is done.
- luckystarr 6y agoIf 63k entries with 10MB of actual data takes minutes to process on a current computer I'd consider that shameful. 10MB is less than the cache in modern CPUs. How can this take minutes(!).
- rcxdude 6y agoIt's easy to write because it doesn't run noticably slowly on smaller data, and it's easy to accidently introduce quadratic behaviour in some systems. Obviously if someone tested this on 10MB of JSON and saw it took minutes and thought that was reasonable, that's a bit ridiculous, but I doubt at the time the code was written anyone expected it to be fed such a large JSON object.
- Cakez0r 6y agoIt's not a premature optimisation to use a hashset instead of a list though!
- ufo 6y agoThe bug is more devious than that. The code looks linear at a glance and the culprit is that sscanf is actually O(N) on the length of the string. How many people would expect that?
- gridspy 6y agoI imagine there is a senior programmer working for another game company. They are currently kicking themselves about the poorly performing and rushed loading code they wrote while still working at R*. But there is nothing they can do about it now, since they have moved on.