Hacker News new | past | comments | ask | show | jobs | submit login

Better still, increment hotness by 2^(dt/λ) where dt is the time since the site was launched (epoch), and λ the halflife of an upvote. No worker process needed.

Doubles will go to infinity after a few years, but you can either reset the epoch at that time, or store the significand and the exponent seperately.




I agree partways with what you're saying; the normal fears of losing precision in your floats don't really apply because you're always adding the smallest numbers first. On the other hand, your worker process is still in my view a worker process, processing every article by multiplying its hotness by 1.77e-220, and resetting t0. I mean, I believe it's a single SQL query, so it probably shouldn't impact site performance too much even for databases as large as Hacker News, so I'm not so worried about the sudden inconsistency while the worker is doing its thing -- but it's still a dedicated thing-on-the-side which has to be scheduled e.g. via cron job, and which you'd have to audit every once in a while to make sure that it did its job successfully and didn't accidentally get pushed out of sync by, say, server reboots.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: