Brad Fitzpatrick (brad) wrote,
Brad Fitzpatrick
brad

6 degrees of separation

I implemented 6 degrees of separation tonight for LiveJournal. It took all of about an hour.

It looks like I started working on it 3 years ago once because when I went to type:

$ emacs dev/6d.pl

I expected to get a new file, but there was already something there! And I knew it was old code because it used the ancient LJ APIs (which no longer worked). An ls -l dev/6d.pl showed a date in Dec 2000! Crazy.

Anyway, memcache made it easy, and I've known how I'd implement it for the past 3 years apparently.... just never got back around to it.

Don't expect it on the live site anytime soon, but it'll probably get posted to lj_dev/lj_nifty for testing in a bit here.

Screenshot!
lj@mayor:~$ time dev/6d.pl brad elims | tail -2
returning via friend-of-friend intersection with friendof-friendof
PATH: (2)brad, (1635)revjim, (438547)babycola, (714565)dorsai, (1095875)elims,

real 0m1.201s
user 0m0.540s
sys 0m0.060s

Note: That's without prefetching certain memcache objects in big requests so there are a lot of unnecessary round-trips in there still. The time will come down. I'm also not caching any subpaths yet.

Also consider it takes 0.6 seconds just to invoke Perl loading the LJ libraries. So not bad.
Tags: perl, tech
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 4 comments