Sunday, April 18, 2010

Tracking Down Bottlenecks

My friend Taras does some really intriguing work on Firefox, and of late has been working hard to reduce cold startup time, which involves a lot of tracing. And anyone who reads this blog every now and then will realise I have serious issues with my network stack, which got me thinking.

One of Taras’ posts, “When in Trouble, Draw a Picture” could equally apply to my current problem. It’s pretty easy to use the rdtsc instruction to get relative timing information, and a pretty graph should be fairly easy to produce from timestamped debug messages.

As an indication of how disastrous my network stack is, I added a little bit of code in my IRC module to reply to CTCP pings. The result? Between 30-60s for a CTCP ping reply. Ridiculous!

Unfortunately, I can’t work on it right now as I managed to inadvertently forkbomb my unbuntu install and need to physically restart the machine. Easier said than done, as it requires a trip in to work to do. The fork() system call can be dangerous in the hands of the uninitiated, but lesson learned.