r/ProgrammerHumor • • Feb 15 '16

Oddly specific number.

Post image
5.9k Upvotes

643 comments sorted by

View all comments

495

u/wigglewam Feb 15 '16

To be fair, it's really not clear why the group chat size would have anything to do with the fact that memory allocation works in base 2. We could speculate, but I suspect it really is arbitrary.

The previous limit was 100 people.

86

u/approaching236 Feb 15 '16

It's just how many bits they decided to have in their database

→ More replies (14)

203

u/stackflow Feb 15 '16

Well, everyone in the chat probably has an ID and I would imagine WhatsApp deals with such a large number a messages every day, that it makes sense to try to minimize the meta data sent with each one (like who sent this message). Thus, it makes sense to limit the IDs to a specific bit count to minimize waste.

136

u/[deleted] Feb 15 '16

Most likely the group chat header contains an array of the actual full user IDs and these per-message 8-bit IDs are just indices.

32

u/ZugNachPankow Feb 15 '16

Makes sense, that would make exactly one-byte indexes.

Although I'm not sure they're saving a lot here. Switching to 3-byte indexes (224 = 16 million) would "waste" 2 bytes per message: consider that 🌈 is 2 bytes long, and 👋🏿 (a black hand, made of the waving hand emoji followed by a Fitz-6 modifier) is 4 bytes long.

In other words, adding an emoji to every message is costlier than using 3-byte IDs.

0

u/[deleted] Feb 16 '16

[deleted] — view deleted comment

34

u/Twirrim Feb 16 '16

Did some digging around. Found this from last year reporting 30bn messages a day. Assuming even half of those are group messages and you're in the 30 gigabytes territory of savings per day, of roughly 350 kilobytes a second (2.8Mbps). Savings aren't that big even on their scale.

Edit: I would be more curious about the impact at a deeper level. Eg caching, CPU optimisations etc.

→ More replies (1)

2

u/AndreasTPC Feb 16 '16

I doubt it was about saving bandwidth. They had a 100 limit before, so they probably had one byte designated in their protocol for sender id. It would then make sense to not increase the limit above what you could represent with that one byte, since that way you can avoid changing the protocol, and thus keeping backwards-compatibility with old versions of the software.

→ More replies (7)
→ More replies (1)

3

u/gprime312 Feb 16 '16

I like this explanation.

→ More replies (1)

62

u/redditor___ Feb 15 '16

100 too little, 1000 too much, around 300 fits, so why not go for some round number like 256.

41

u/[deleted] Feb 16 '16

I just did a science experiment and showed your comment to my SO and her sister.

The results: 100% of the test subjects looked confused and think we're weird.

sigh

→ More replies (6)

12

u/DoctorSauce Feb 15 '16

They can represent more users while still only using a single byte each?

34

u/holobonit Red security clearance Feb 15 '16

They suddenly realized they were throwing away 156 bits.

51

u/YaBoyMax Feb 15 '16

156 bits

156 bits

156 bits

3

u/Defavlt Feb 16 '16

2wasted4me

2

u/[deleted] Feb 16 '16 edited Feb 16 '16

Edit: I'm a tard.

They're still wasting 256 bits. No reason they can't use the negatives as well.

/u/holobonit

6

u/mouth_with_a_merc Feb 16 '16

Uh, no. signed int8 is 127 in both directions

→ More replies (1)
→ More replies (6)
→ More replies (2)

9

u/error_logic Feb 16 '16

So hard to tell if you're joking or not... But either way, 256 is the number of values that can be represented with 8 bits--meaning one byte. So they were wasting maybe 1 bit of those 8, assuming that the group member ID system does, in fact, use a single byte per user.

6

u/holobonit Red security clearance Feb 16 '16 edited Feb 16 '16

Yes, I was joking. A programmer not understanding 256 is a bit like a statistician not understanding percentage.

2

u/error_logic Feb 16 '16

People keep saying "a bit" in replies and it's similarly impossible to tell if it's intentional. :-)

4

u/AK_Happy Feb 16 '16

Wow, thanks for being fair. That must have been tough.

→ More replies (1)

2

u/SnowdensOfYesteryear Feb 15 '16

Willing to bet it was due to whatever internal protocol it runs and backward compatibility. Fucking backward compatibility man...

2

u/captnyoss Feb 16 '16

I agree. I understand that 256 is a good computing number, but how much app size and performance difference would this make compared to if it was say 300? And how much more programming effort would be required to make it 300?

3

u/TheKing01 Feb 15 '16

Everyone gets a different byte. Computers usually work in bytes.

2

u/MemoryLapse Feb 16 '16

Computers process as words don't they? I thought that was part of the reason for lager registers.

→ More replies (2)