Site icon Nick Bradbury

Stupid Optimizations

One of my priorities for the next FeedDemon has been to fine-tune the “Popular Topics” feature so it’s much faster than it currently is. If you’re subscribed to a lot of feeds that talk about the same topics, it can take several seconds for FeedDemon to build the popular topics page – not painfully slow, but slow enough that you might not use the feature all the time.

And that to me is a problem. See, I’ve been pretty busy for the past couple of weeks and haven’t had time to catch up with my feeds, so I’ve been marking them all read and relying on the popular topics page (along with a few watches) to bring me the latest buzz. It’s been a very useful feature to me lately, so I hate that it’s not as fast as it should be.

I spent several hours ripping through the code and tweaking performance, but it still wasn’t fast enough. I was about to chuck it all and take a different approach when it dawned on me that the problem could be outside the code that builds the popular topics – and sure enough, after profiling the entire codebase I discovered that a crappy routine I wrote long ago which compares two URLs was bogging things down (side note: my routine was pretty bad, but not as bad as the one Dare Obasanjo blogged about).

I spent a few minutes rewriting that routine, and it made an enormous difference. After the initial building of the link database (which occurs the first time you use this feature), displaying the popular topics page now takes less than a second. And changing the filter to show popular topics from today, yesterday, etc., is virtually instantaneous.

When things like this happen, I’m torn between being excited and pummeling myself. I’m pleased that I was able to speed it up, but I’m embarrassed that the performance problem was caused by one stupid piece of code.

Exit mobile version