British Inside

An Englishman living in small town America

James Shaw

News

  • Copyright James Shaw 2004-2007

    Creative Commons License

    View James Shaw's profile on LinkedIn

Time to revisit ANTS Profiler

I recently moved my sites to Windows 2008 server and although I am repressing the memory of the pain and suffering caused by my lack of knowledge of IIS7 (assuming it really is me, not IIS7 that makes some simple tasks so much harder), after it was all done I happened to have Task Manager open. I can't remember why I did, but it was very lucky.

At that point, I hit one of my web pages and the CPU hit 80%.

Eighty per cent.

Then, back to zero.

I refreshed the page - same result. Holy shit, I have a big friggin problem here. The server is brand new and kickass, I'm running the latest and greatest everything and my CPU is pegged refreshing one normal aspx page.

Now, on this site I make heavy use of nvelocity (huge thanks again to scottw for that tip many moons ago) - the same scripting engine used in Telligent's Graffiti CMS. Immediately I thought of that. Recently I've been moving more and more of the page rendering into nvelocity's hands - had I overdone it?

Coincidentally (really, this was pure fluke) that same day I got an email from Chris Massey at Red Gate introducing himself and sending me an updated license file. I ran over to their site to see what the latest SQL Compare included (how could it get better?) ...and noticed ANTS Profiler.

Hmmm, profiling. I literally haven't done this for (I'm guessing) 6 or 7 years? I used it extensively in the C, C++ days but I think I grew out of it around the time C# came along. Optimization was never the best use of my time - almost like a way to spot a newbie developer; "Ooooh, let's optimize this loop and maybe save a millisecond every 100,000 iterations".

Uh, no. Compilers just aren't Turbo C 1.5 any more. Let them worry about crap like this.

Now, don't get me wrong, bottlenecks are a different thing. And cache the crap out of everything. But if you build the foundations of an application correctly I believe you can pretty much ignore optimization until something bites you in the ass.

Like a CPU at 80%.

So, like I said, finding ANTS Profiler was fortuitous. I downloaded it, installed and ran it, expecting something that had a lot of buttons, switches and swinging needles. I'm a very optimistic guy, but I somehow thought I'd be here for a few evenings.

..But of course you know what I'm going to say - and you're right. It was EASY. dumb, in fact. You couldn't dumb this down if you tried. You, er, have to type in the URL of your web app and hit Start.

I'm not kidding. I don't think there are any options on that main screen.

And what happens next is (I'd love to swear here) *&^#$%^$# GENIUS!

It starts recording everything that your app does while you click around your web site. I can't imagine where all that data gets stored so fast. Then you can select an area of the timeline and inspect it - although again, not much inspecting is needed since it just says (in red) <-THIS IS YOUR PROBLEM RIGHT HERE. It might even blink too, I'm not sure.

Yet again, development gets simpler and my vast experience means nothing - my mom could do this. lol

In case you are interested, I had screwed something up a few months back and not noticed. My app was instantiating a new VelocityEngine on every request - and that baby is expensive!  By making it static and leaving just the VelocityContext in Context.Items my CPU load disappeared.

Of course, then I couldn't help just looking into the next "bottleneck"..and the next..oh crap...

Posted: Wednesday, April 22, 2009 8:39 AM by James
Filed under:

Comments

No Comments

New Comments to this post are disabled