Bugs, threading and performance

posted by Jeff | Friday, September 21, 2007, 1:57 AM | comments: 0

This is nerdy. Look away if you can't stand it.

It's late. I'm gonna regret staying up this late, but I got into a code monkey groove and didn't want to stop.

I banged out the thread subscription feature for the forum app tonight. That's two features this week. Rock on. For the most part these came so easy to me, I suppose because I've written similar pieces before, but also because the underlying design of the app is better than it ever was. It's still not great, but definitely better.

When I started over back in, shit, some time last year, one of the things I did early on was write an e-mail queue. Nothing really used it up until now, since if the app fails to send you mail when you register, that's bad and you have to know it right away. But when you're sending out 10,000 messages, or thread subscription update notes, those have to happen asynchronously. The queue was supposed to do that.

On a small scale test, it seems to work. Perhaps I'll try it out later this weekend on the full-blown CB database. The subscription bit is less code than it ever was before, and it will only notify you once even if a dozen replies were posted. The next notification comes after you've looked at the topic. Much sexier. Of course, it's sending you e-mail when you reply yourself, which is an obvious bug.

I did run into a race condition bug though, because the mailer thread was not locking, and because the next mail could be sent before the previous was done, it might send the same message twice. Duh.

I found a serious performance issue too, and it's one that plagues the existing CoasterBuzz too. The dupe post and flood guard check is super slow, on the order of several seconds. On one hand, I could add another index to the Posts table, but I think another index would just cause more harm than good on a busy forum. I think my solution will simply be to update the user record with the ID of the last post, since both the posts and users are already indexed by ID.

I'm pretty excited about how that app is coming together, and I haven't even added anything substantially new yet. But wow does it perform better overall. Now if I could just get it done this year!


Comments

No comments yet.


Post your comment: