Live data from Hacker News

Chess.com stopped working on 32bit iPads because 2^31 games have been played

chess.com

111–120 of 338 posts

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#111

Reminds me of the havoc that was caused when Twitter tweet IDs rolled over. Resulting in every third party developer to update their apps (and at the time there were a lot of those). Twitter saw it coming and forced the issue. By saying that at a certain date and time they would manually jump the ID numbers rather than wait for it to happen at some unpredictable time.

They didn't roll over, they exceeded 2^53-1 which is the max Number which doesn't truncate when treated as an integer in js. The solution was to treat it as a string.

(Or we're thinking of different events, I apologize if so)

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#112
post #60

Earlier quoted context omitted.

2 billion is a very large number that was probably not envisioned as reachable in the near future - as a programmer I'd argue this is a pretty easy mistake to make, and that while (slightly) embarrassing, its a good learning moment. It's also really awesome that you're here, and that you guys were so honest about the nature of the bug - this is really something that should be encouraged.

Maybe we should start a blog about all of the interesting bugs and challenges we encounter. It certainly is white-knuckle pretty often when running at scale. The number of devices, connections, features... I'm aging prematurely :P

A few articles would definitely be appreciated. Might even help with recruiting fresh blood.

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#113
post #46

Earlier quoted context omitted.

Similar to how much effort goes into dealing with things like dangerous strains of bird flu, only to have people complain about how much money was spent on "nothing" when an outbreak doesn't occur.

This is a whole class of problem - I wonder if there's a name for it. More examples include: talking about welfare being unnecessary because no one is starving. Or people on medications stopping because they feel better (while still on them).

For a pop-culture name, I'd call it the Head & Shoulders Problem, after those old shampoo commercials:

"You use Head & Shoulders? But you don't have dandruff!" "Exactly!"

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#114
post #73
post #65

Earlier quoted context omitted.

C/C++ is notoriously head-ache inducing on this point. Yes, all the CPU archs you'd reasonably expect to encounter today behave this way. However, because the language standard says signed overflow is undefined, compilers are free to assume that it will never happen, and make optimizations that you'd think would be unsafe, but are technically permissible. [1] [1] https://stackoverflow.com/questions/18195715/why-is-un…

Well that's interesting. I was not aware of any compilers doing this. I wonder if there's a switch in gcc/llvm/msvc/etc to turn this specific behavior off.

Basically all C and C++ compilers do this.

They do it, so they can simplify things like "x < x+1" to "true".

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#115
post #56

Earlier quoted context omitted.

Nope. Definitely not goofy. My dad was a programmer in the early days. The machines he started on in the 1960s had 8 KB of RAM. Saving a byte then is the equivalent today of saving 1 MB on an 8 GB machine. Multiply that times, say, the thousands of customer orders you're trying to process and the goofy thing would be burning a lot of additional RAM because it might help somebody 35 years later. Who among us is writin…

Last time this came up, I ran the numbers and the cost of the RAM saved per date stored was hundreds of dollars. Not per computer, or per program, but per date . Comparing total memory sizes doesn't tell the whole story, because RAM for a whole machine is so much cheaper now. Spending that much money on storing "19" just so your code keeps working in the unlikely event that it's still in use 3+ decades into the futur…

The interesting thing about this from an engineering point of view is, you quietly pass a threshold where the clever hack which was worthwhile becomes literally more trouble than it is worth. When that happens is a multivariate problem that we couldn't truly predict at the time of the code's creation. (and when it happens, there might not even be anyone on the payroll thinking about it)

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#116
post #73

Earlier quoted context omitted.

Well that's interesting. I was not aware of any compilers doing this. I wonder if there's a switch in gcc/llvm/msvc/etc to turn this specific behavior off.

https://linux.die.net/man/1/gcc -- Search for `-fstrict-overflow`. And note how it says The -fstrict-overflow option is enabled at levels -O2, -O3, -Os. In other words, basically every program that you're using is compiled with that option enabled. (Release builds typically use -O2, sometimes even -O3.)

-fstrict-overflow is the opposite of what the parent comment was asking about. You want -fwrapv or -fno-strict-overflow.

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#117
eBay (almost) had this problem and I cannot find any articles about it online. They were rapidly approaching 2^31-1 auctions. So they switched to a larger integer, the switchover went badly, and they were mostly down for 4 days, if my memory serves. This would be like 10+ years ago I think.

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#118
post #86

Earlier quoted context omitted.

Yes - I understand HOW it happened, just not sure WHY. Meaning, I'm not sure what the developer was thinking, and at this point, I'm not going to track down exactly who it was and point fingers. I think everyone has learned enough through this highly interesting bug. It certainly was interesting to see the slack room exploding with theories and debugging. A new iOS client has been submitted to Apple (hurry plz!!!), a…

It's most likely for efficiency and performance reason. 64-bit doubles the storage requirement of 32-bit and would have impact on database's utilization of memory, querying window size, cache, and storage. Edit: 32 bits worth of games played means about 4 billion games. 4 billion X 4 bytes for 32-bit = 16GB just for the 32-bit ID's. 64-bit ID's would need 32GB for the 4 billion games. I guess memory and storage weren…

It also could've been just the person picking an int over a long. Is ints vs. longs the first place to look for optimizing efficiency/performance?

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#119

Earlier quoted context omitted.

It's very reasonable. This way they overflow into invalid values instead of zero.

Assuming you're working in a language that defines signed integer overflow. Depending on the language, you can result in undefined behavior, instead. For that reason, I'd go with an unsigned counter, with the first million IDs being invalid or reserved for future use. That way, you get well-defined overflow into an invalid region.

That's not going to work because you're expecting every client to ban ID's that are too small.

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#120
post #99

Earlier quoted context omitted.

The naive, 9 years in the past me once was like "int will last us forever! and it'll save us some space!", only to have to change it to bigint a few months later

Also see: IPv4 vs IPv6. Remember, these fancy computing devices were built for the rich and the government, not for the average joe, noone thought computing would be this easily accessible.

Except that isn't a great example because with Nat, ip4 can get us oodles of devices still.

Can't really use NAT on a primary key...

Post reply on HN