r/programming • • Dec 09 '13

Reddit’s empire is founded on a flawed algorithm

http://technotes.iangreenleaf.com/posts/2013-12-09-reddits-empire-is-built-on-a-flawed-algorithm.html
2.9k Upvotes

503 comments sorted by

View all comments

2

u/not_sloane Dec 10 '13

The big question is what happened on Thu Dec 8 07:46:43 UTC 2005?

bash for the curious:

date -d @1134028003

3

u/deviantpdx Dec 10 '13 edited Dec 10 '13

It was a few months after the founding. My guess is thats about the time this algorithm was implemented.
EDIT: The site was rewritten in Python that month, which further lends to some kind of code deployment coinciding with that time.

3

u/not_sloane Dec 10 '13

You inspired me to look at the git-blame of that file.

That particular line was written on 2010-06-15, which is 5 years after the date we have here. It must have been copied over from some legacy file which has since been lost. I wonder what Github's KeyserSosa knew. I think that's the same as /u/KeyserSosa. Maybe he can explain it?

7

u/KeyserSosa Dec 10 '13

Two things here:

  1. The github repository is not the original reddit repository. We actually switched to git from mercurial a few months before we open sourced reddit (IIRC) from mercurial, and before that were using subversion.
  2. Even if we had the full commit history, one of optimizations was to move a lot of the heavily used code from python to cython (hence the .pyx) and so you'd have to track down a now-mythical sort.py.

That said, the blame won't tell you much. The underlying sort algorithms didn't change often (they required a massive and terrifying database and cache migration), and when it did, we never changed that constant since it was just an offset. Only differences matter for the sort.

As for the mystery of the datetime, this might help. That datetime is indeed several months after the founding, and right about the time we were finishing up rewriting reddit in python and were experimenting with the hot algo.

2

u/hyperhopper Dec 10 '13

Since you are on reddit staff, would you like to shed any light on why reddit refuses to change this?

3

u/KeyserSosa Dec 10 '13

I'm a former admin (left in '10), but some version of this post has been coming up about once or twice a year since we open sourced, and /u/ketralnis covered the high points pretty well the last time.